source: sources/src/sc_trace_ext.h @ 5

Last change on this file since 5 was 4, checked in by nipo, 17 years ago

Towards SystemC-2.2 LRM:

  • Implement sc_time with units
  • Have a systemc header with no namespace pollution
File size: 6.6 KB
RevLine 
[1]1/*------------------------------------------------------------\
2|                                                             |
3| Tool    :                  systemcass                       |
4|                                                             |
5| File    :                   sc_trace.h                      |
6|                                                             |
7| Author  :                 Kingbo Paul-Jerome                |
8|                           Buchmann Richard                  |
9|                                                             |
10| Date    :                   09_07_2004                      |
11|                                                             |
12\------------------------------------------------------------*/
13
14/*
15 * This file is part of the Disydent Project
16 * Copyright (C) Laboratoire LIP6 - Département ASIM
17 * Universite Pierre et Marie Curie
18 *
19 * Home page          : http://www-asim.lip6.fr/disydent
20 * E-mail             : mailto:richard.buchmann@lip6.fr
21 *
22 * This library is free software; you  can redistribute it and/or modify it
23 * under the terms  of the GNU Library General Public  License as published
24 * by the Free Software Foundation; either version 2 of the License, or (at
25 * your option) any later version.
26 *
27 * Disydent is distributed  in the hope  that it  will be
28 * useful, but WITHOUT  ANY WARRANTY; without even the  implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
30 * Public License for more details.
31 *
32 * You should have received a copy  of the GNU General Public License along
33 * with the GNU C Library; see the  file COPYING. If not, write to the Free
34 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
35 */
36
37#ifndef __SC_TRACE_EXT_H__
38#define __SC_TRACE_EXT_H__
39
40#include "sc_fwd.h"
41#include "alias.h"
42#include <vector>
43#include <iostream>
44#include <string>
45#include <sstream>
46
47#include "sc_module_ext.h"
48#include "sc_localvar.h"
49
50//---------------------------------------------------------------------------
51
52namespace sc_core {
53
[4]54        using namespace sc_dt;
55
[1]56//---------------------------------------------------------------------------
57
58struct signal2trace
59{
60        const sc_interface   *inter;
61        const char           *alias;
62        unsigned int          bit_size;
63  tab_t                *pointer;
64  std::string           nomSig;
65};
66
67//---------------------------------------------------------------------------
68
69template<typename T> struct bits_number_getter {};
70 
71#define BITS_NUMBER_GETTER_DEF(newt,typ, expr)      \
72template<newt> struct bits_number_getter<typ> {     \
73    typedef typ val_t;                              \
74    static inline unsigned int get() {return expr;} \
75}
76
77 BITS_NUMBER_GETTER_DEF(, bool          ,1);
78 BITS_NUMBER_GETTER_DEF(, char          ,8*sizeof(val_t));
79 BITS_NUMBER_GETTER_DEF(, signed   char ,8*sizeof(val_t));
80 BITS_NUMBER_GETTER_DEF(, unsigned char ,8*sizeof(val_t));
81 BITS_NUMBER_GETTER_DEF(, unsigned short,8*sizeof(val_t));
82 BITS_NUMBER_GETTER_DEF(, signed   short,8*sizeof(val_t));
83 BITS_NUMBER_GETTER_DEF(, signed   int  ,8*sizeof(val_t));
84 BITS_NUMBER_GETTER_DEF(, unsigned int  ,8*sizeof(val_t));
85 BITS_NUMBER_GETTER_DEF(, signed   long ,8*sizeof(val_t));
86 BITS_NUMBER_GETTER_DEF(, unsigned long ,8*sizeof(val_t));
87 BITS_NUMBER_GETTER_DEF(, float         ,8*sizeof(val_t));
88 BITS_NUMBER_GETTER_DEF(, sc_unsigned   ,8*sizeof(unsigned int));
89 BITS_NUMBER_GETTER_DEF(, sc_signed     ,8*sizeof(int));
90 BITS_NUMBER_GETTER_DEF(, double        ,8*sizeof(val_t));
91 BITS_NUMBER_GETTER_DEF(, uint64        ,8*sizeof(val_t));
92 BITS_NUMBER_GETTER_DEF(, int64         ,8*sizeof(val_t));
93 BITS_NUMBER_GETTER_DEF(typename inval_t, sc_in<inval_t>    ,bits_number_getter<inval_t>::get());
94 BITS_NUMBER_GETTER_DEF(typename inval_t, sc_out<inval_t>   ,bits_number_getter<inval_t>::get());
95 BITS_NUMBER_GETTER_DEF(typename inval_t, sc_inout<inval_t> ,bits_number_getter<inval_t>::get());
96 BITS_NUMBER_GETTER_DEF(typename inval_t, sc_signal<inval_t>,bits_number_getter<inval_t>::get());
97 BITS_NUMBER_GETTER_DEF(int W, sc_int<W>,W);
98 BITS_NUMBER_GETTER_DEF(int W, sc_uint<W>,W);
99 BITS_NUMBER_GETTER_DEF(int W, sc_bigint<W>,W);
100 BITS_NUMBER_GETTER_DEF(int W, sc_biguint<W>,W);
101 BITS_NUMBER_GETTER_DEF(int W, sc_bv<W>,W);
102 BITS_NUMBER_GETTER_DEF(int W, sc_lv<W>,W);
103#undef BITS_NUMBER_GETTER_DEF
104 
105template < typename T > inline
106unsigned int get_bits_number (const T & object)
107{
108    return bits_number_getter<T>::get();
109}
110
111//---------------------------------------------------------------------------
112
113struct sc_trace_file;
114
115//---------------------------------------------------------------------------
116
117extern void
118sc_trace( sc_trace_file* tf, const signal2trace &t, const std::string &name );
119
120template <class T> /*inline*/
121void
122sc_trace( sc_trace_file* tf, const sc_in<T>& port, const std::string &name )
123{
124        signal2trace t;
125        t.inter = (const sc_interface*) &port;
126        t.alias = alias();
127        t.bit_size = get_bits_number(port);
128        t.nomSig = name;
129        sc_trace (tf, t, name);
130}
131
132//----------------------------------------------------------------------------
133
134template <class T> /*inline*/
135void
136sc_trace( sc_trace_file* tf, const sc_out<T>& out, const std::string &name )
137{
138        signal2trace t;
139        t.inter = (const sc_interface*) &out;
140        t.alias = alias();
141        t.bit_size = get_bits_number(out);
142        t.nomSig = name;
143        sc_trace (tf, t, name);
144}
145
146//----------------------------------------------------------------------------
147
148template <typename T> /*inline*/
149void
150sc_trace( sc_trace_file* tf, const sc_inout<T>& inout, const std::string &name )
151{
152        signal2trace t;
153        t.inter = (const sc_interface*) &inout;
154        t.alias = alias();
155        t.bit_size = get_bits_number(inout);
156        t.nomSig = name;
157        sc_trace (tf, t, name);
158}
159
160//----------------------------------------------------------------------------
161
162template <typename T> /*inline*/
163void
164sc_trace( sc_trace_file* tf, const sc_signal<T>& signal, const std::string &name )
165{
166        signal2trace t;
167        t.inter = (const sc_interface*) &signal;
168        t.alias = alias();
169        t.bit_size = get_bits_number(signal);
170        t.nomSig = name;
171        sc_trace (tf, t, name);
172}
173
174//----------------------------------------------------------------------------
175
176#define DEF_SC_TRACE(T) /*inline \*/ \
177  extern void   \
178  sc_trace (sc_trace_file*,      \
179            const T& object,     \
180            const std::string&);
181
182        DEF_SC_TRACE(bool)
183        DEF_SC_TRACE(float)
184        DEF_SC_TRACE(double)
185        DEF_SC_TRACE(unsigned char)
186        DEF_SC_TRACE(unsigned short)
187        DEF_SC_TRACE(unsigned int)
188        DEF_SC_TRACE(unsigned long)
189        DEF_SC_TRACE(char)
190        DEF_SC_TRACE(short)
191        DEF_SC_TRACE(int)
192        DEF_SC_TRACE(long)
193        DEF_SC_TRACE(uint64)
194        DEF_SC_TRACE(int64)
195
196#undef DEF_SC_TRACE
197
198} // end of sc_core namespace
199
200//----------------------------------------------------------------------------
201#endif
202
Note: See TracBrowser for help on using the repository browser.