source: sources/src/sc_trace_ext.h @ 3

Last change on this file since 3 was 1, checked in by buchmann, 17 years ago

Initial import from CVS repository

File size: 6.6 KB
Line 
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
54//---------------------------------------------------------------------------
55
56struct signal2trace
57{
58        const sc_interface   *inter;
59        const char           *alias;
60        unsigned int          bit_size;
61  tab_t                *pointer;
62  std::string           nomSig;
63};
64
65//---------------------------------------------------------------------------
66
67template<typename T> struct bits_number_getter {};
68 
69#define BITS_NUMBER_GETTER_DEF(newt,typ, expr)      \
70template<newt> struct bits_number_getter<typ> {     \
71    typedef typ val_t;                              \
72    static inline unsigned int get() {return expr;} \
73}
74
75 BITS_NUMBER_GETTER_DEF(, bool          ,1);
76 BITS_NUMBER_GETTER_DEF(, char          ,8*sizeof(val_t));
77 BITS_NUMBER_GETTER_DEF(, signed   char ,8*sizeof(val_t));
78 BITS_NUMBER_GETTER_DEF(, unsigned char ,8*sizeof(val_t));
79 BITS_NUMBER_GETTER_DEF(, unsigned short,8*sizeof(val_t));
80 BITS_NUMBER_GETTER_DEF(, signed   short,8*sizeof(val_t));
81 BITS_NUMBER_GETTER_DEF(, signed   int  ,8*sizeof(val_t));
82 BITS_NUMBER_GETTER_DEF(, unsigned int  ,8*sizeof(val_t));
83 BITS_NUMBER_GETTER_DEF(, signed   long ,8*sizeof(val_t));
84 BITS_NUMBER_GETTER_DEF(, unsigned long ,8*sizeof(val_t));
85 BITS_NUMBER_GETTER_DEF(, float         ,8*sizeof(val_t));
86 BITS_NUMBER_GETTER_DEF(, sc_unsigned   ,8*sizeof(unsigned int));
87 BITS_NUMBER_GETTER_DEF(, sc_signed     ,8*sizeof(int));
88 BITS_NUMBER_GETTER_DEF(, double        ,8*sizeof(val_t));
89 BITS_NUMBER_GETTER_DEF(, uint64        ,8*sizeof(val_t));
90 BITS_NUMBER_GETTER_DEF(, int64         ,8*sizeof(val_t));
91 BITS_NUMBER_GETTER_DEF(typename inval_t, sc_in<inval_t>    ,bits_number_getter<inval_t>::get());
92 BITS_NUMBER_GETTER_DEF(typename inval_t, sc_out<inval_t>   ,bits_number_getter<inval_t>::get());
93 BITS_NUMBER_GETTER_DEF(typename inval_t, sc_inout<inval_t> ,bits_number_getter<inval_t>::get());
94 BITS_NUMBER_GETTER_DEF(typename inval_t, sc_signal<inval_t>,bits_number_getter<inval_t>::get());
95 BITS_NUMBER_GETTER_DEF(int W, sc_int<W>,W);
96 BITS_NUMBER_GETTER_DEF(int W, sc_uint<W>,W);
97 BITS_NUMBER_GETTER_DEF(int W, sc_bigint<W>,W);
98 BITS_NUMBER_GETTER_DEF(int W, sc_biguint<W>,W);
99 BITS_NUMBER_GETTER_DEF(int W, sc_bv<W>,W);
100 BITS_NUMBER_GETTER_DEF(int W, sc_lv<W>,W);
101#undef BITS_NUMBER_GETTER_DEF
102 
103template < typename T > inline
104unsigned int get_bits_number (const T & object)
105{
106    return bits_number_getter<T>::get();
107}
108
109//---------------------------------------------------------------------------
110
111struct sc_trace_file;
112
113//---------------------------------------------------------------------------
114
115extern void
116sc_trace( sc_trace_file* tf, const signal2trace &t, const std::string &name );
117
118template <class T> /*inline*/
119void
120sc_trace( sc_trace_file* tf, const sc_in<T>& port, const std::string &name )
121{
122        signal2trace t;
123        t.inter = (const sc_interface*) &port;
124        t.alias = alias();
125        t.bit_size = get_bits_number(port);
126        t.nomSig = name;
127        sc_trace (tf, t, name);
128}
129
130//----------------------------------------------------------------------------
131
132template <class T> /*inline*/
133void
134sc_trace( sc_trace_file* tf, const sc_out<T>& out, const std::string &name )
135{
136        signal2trace t;
137        t.inter = (const sc_interface*) &out;
138        t.alias = alias();
139        t.bit_size = get_bits_number(out);
140        t.nomSig = name;
141        sc_trace (tf, t, name);
142}
143
144//----------------------------------------------------------------------------
145
146template <typename T> /*inline*/
147void
148sc_trace( sc_trace_file* tf, const sc_inout<T>& inout, const std::string &name )
149{
150        signal2trace t;
151        t.inter = (const sc_interface*) &inout;
152        t.alias = alias();
153        t.bit_size = get_bits_number(inout);
154        t.nomSig = name;
155        sc_trace (tf, t, name);
156}
157
158//----------------------------------------------------------------------------
159
160template <typename T> /*inline*/
161void
162sc_trace( sc_trace_file* tf, const sc_signal<T>& signal, const std::string &name )
163{
164        signal2trace t;
165        t.inter = (const sc_interface*) &signal;
166        t.alias = alias();
167        t.bit_size = get_bits_number(signal);
168        t.nomSig = name;
169        sc_trace (tf, t, name);
170}
171
172//----------------------------------------------------------------------------
173
174#define DEF_SC_TRACE(T) /*inline \*/ \
175  extern void   \
176  sc_trace (sc_trace_file*,      \
177            const T& object,     \
178            const std::string&);
179
180        DEF_SC_TRACE(bool)
181        DEF_SC_TRACE(float)
182        DEF_SC_TRACE(double)
183        DEF_SC_TRACE(unsigned char)
184        DEF_SC_TRACE(unsigned short)
185        DEF_SC_TRACE(unsigned int)
186        DEF_SC_TRACE(unsigned long)
187        DEF_SC_TRACE(char)
188        DEF_SC_TRACE(short)
189        DEF_SC_TRACE(int)
190        DEF_SC_TRACE(long)
191        DEF_SC_TRACE(uint64)
192        DEF_SC_TRACE(int64)
193
194#undef DEF_SC_TRACE
195
196} // end of sc_core namespace
197
198//----------------------------------------------------------------------------
199#endif
200
Note: See TracBrowser for help on using the repository browser.