source: sources/src/sc_trace_ext.h @ 55

Last change on this file since 55 was 52, checked in by meunier, 12 years ago

Code formatting in all source files.

File size: 6.3 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 <vector>
41#include <iostream>
42#include <string>
43#include <sstream>
44
[52]45#include "sc_fwd.h"
46#include "alias.h"
[1]47#include "sc_module_ext.h"
48#include "sc_localvar.h"
49
50
[52]51
[1]52namespace sc_core {
53
[52]54using namespace sc_dt;
[4]55
[1]56
[52]57
58struct signal2trace {
59    const sc_interface * inter;
60    const char * alias;
61    unsigned int bit_size;
62    tab_t * pointer;
63    std::string nomSig;
[1]64};
65
66
67
[52]68template< typename T > struct bits_number_getter {};
69
70
71#define BITS_NUMBER_GETTER_DEF(newt, typ, expr)           \
72    template<newt> struct bits_number_getter<typ> {       \
73        typedef typ val_t;                                \
74        static inline unsigned int get() { return expr; } \
75    }
76
77
78BITS_NUMBER_GETTER_DEF(, bool          , 1);
79BITS_NUMBER_GETTER_DEF(, char          , 8 * sizeof(val_t));
80BITS_NUMBER_GETTER_DEF(, signed   char , 8 * sizeof(val_t));
81BITS_NUMBER_GETTER_DEF(, unsigned char , 8 * sizeof(val_t));
82BITS_NUMBER_GETTER_DEF(, unsigned short, 8 * sizeof(val_t));
83BITS_NUMBER_GETTER_DEF(, signed   short, 8 * sizeof(val_t));
84BITS_NUMBER_GETTER_DEF(, signed   int  , 8 * sizeof(val_t));
85BITS_NUMBER_GETTER_DEF(, unsigned int  , 8 * sizeof(val_t));
86BITS_NUMBER_GETTER_DEF(, signed   long , 8 * sizeof(val_t));
87BITS_NUMBER_GETTER_DEF(, unsigned long , 8 * sizeof(val_t));
88BITS_NUMBER_GETTER_DEF(, float         , 8 * sizeof(val_t));
89BITS_NUMBER_GETTER_DEF(, sc_unsigned   , 8 * sizeof(unsigned int));
90BITS_NUMBER_GETTER_DEF(, sc_signed     , 8 * sizeof(int));
91BITS_NUMBER_GETTER_DEF(, double        , 8 * sizeof(val_t));
92BITS_NUMBER_GETTER_DEF(, uint64        , 8 * sizeof(val_t));
93BITS_NUMBER_GETTER_DEF(, int64         , 8 * sizeof(val_t));
94BITS_NUMBER_GETTER_DEF(typename inval_t, sc_in<inval_t>    , bits_number_getter<inval_t>::get());
95BITS_NUMBER_GETTER_DEF(typename inval_t, sc_out<inval_t>   , bits_number_getter<inval_t>::get());
96BITS_NUMBER_GETTER_DEF(typename inval_t, sc_inout<inval_t> , bits_number_getter<inval_t>::get());
97BITS_NUMBER_GETTER_DEF(typename inval_t, sc_signal<inval_t>, bits_number_getter<inval_t>::get());
98BITS_NUMBER_GETTER_DEF(int W, sc_int<W>, W);
99BITS_NUMBER_GETTER_DEF(int W, sc_uint<W>, W);
100BITS_NUMBER_GETTER_DEF(int W, sc_bigint<W>, W);
101BITS_NUMBER_GETTER_DEF(int W, sc_biguint<W>, W);
102BITS_NUMBER_GETTER_DEF(int W, sc_bv<W>, W);
103BITS_NUMBER_GETTER_DEF(int W, sc_lv<W>, W);
[1]104#undef BITS_NUMBER_GETTER_DEF
[52]105
106
107template < typename T >
108inline unsigned int get_bits_number (const T & object) {
[1]109    return bits_number_getter<T>::get();
110}
111
112
[52]113
[1]114struct sc_trace_file;
115
116
[52]117extern void sc_trace(sc_trace_file * tf, const signal2trace & t, const std::string & name);
[1]118
[52]119
120template < class T > /*inline*/
121void sc_trace(sc_trace_file * tf, const sc_in< T > & port, const std::string & name) {
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);
[1]128}
129
130
[52]131
[1]132template <class T> /*inline*/
[52]133void sc_trace(sc_trace_file * tf, const sc_out< T > & out, const std::string & name) {
134    signal2trace t;
135    t.inter = (const sc_interface *) &out;
136    t.alias = alias();
137    t.bit_size = get_bits_number(out);
138    t.nomSig = name;
139    sc_trace (tf, t, name);
[1]140}
141
142
[52]143
[1]144template <typename T> /*inline*/
[52]145void sc_trace(sc_trace_file * tf, const sc_inout< T > & inout, const std::string & name) {
146    signal2trace t;
147    t.inter = (const sc_interface *) &inout;
148    t.alias = alias();
149    t.bit_size = get_bits_number(inout);
150    t.nomSig = name;
151    sc_trace (tf, t, name);
[1]152}
153
154
[52]155
[1]156template <typename T> /*inline*/
[52]157void sc_trace( sc_trace_file * tf, const sc_signal< T > & signal, const std::string & name) {
158    signal2trace t;
159    t.inter = (const sc_interface *) &signal;
160    t.alias = alias();
161    t.bit_size = get_bits_number(signal);
162    t.nomSig = name;
163    sc_trace (tf, t, name);
[1]164}
165
166
167
[52]168#define DEF_SC_TRACE(T) /*inline \*/       \
169    extern void sc_trace (sc_trace_file *, \
170        const T & object,                  \
171        const std::string &);
[1]172
[52]173    DEF_SC_TRACE(bool)
174    DEF_SC_TRACE(float)
175    DEF_SC_TRACE(double)
176    DEF_SC_TRACE(unsigned char)
177    DEF_SC_TRACE(unsigned short)
178    DEF_SC_TRACE(unsigned int)
179    DEF_SC_TRACE(unsigned long)
180    DEF_SC_TRACE(char)
181    DEF_SC_TRACE(short)
182    DEF_SC_TRACE(int)
183    DEF_SC_TRACE(long)
184    DEF_SC_TRACE(uint64)
185    DEF_SC_TRACE(int64)
[1]186#undef DEF_SC_TRACE
187
188} // end of sc_core namespace
189
[52]190
[1]191#endif
192
[52]193/*
194# Local Variables:
195# tab-width: 4;
196# c-basic-offset: 4;
197# c-file-offsets:((innamespace . 0)(inline-open . 0));
198# indent-tabs-mode: nil;
199# End:
200#
201# vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
202*/
203
Note: See TracBrowser for help on using the repository browser.