source: latest/test_regression/16062005/system2.cpp @ 1

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

Initial import from CVS repository

File size: 2.6 KB
Line 
1#include "systemc.h"
2#include <iostream>
3#include <fstream>
4#include <vector>
5
6using namespace std;
7
8struct intramoldu : sc_module
9{
10  sc_signal<long> reg_long;
11  intramoldu (sc_module_name n)
12  { }
13};
14
15
16struct moldu : sc_module
17{
18  sc_in<bool>             i_bool;
19  sc_in<int >             i_int;
20  sc_in<sc_int<17> >      i_sc_int17;
21  sc_out<int >            o_int;
22  sc_out<sc_uint<38> >    o_sc_uint38;
23  sc_signal<sc_lv<8> >    reg_lv8;
24  sc_signal<int>          reg_int;
25  sc_signal<unsigned int> reg_uint;
26  sc_signal<sc_uint<3> >  reg_sc_uint3;
27  sc_signal<sc_int<31> >  reg_sc_int31;
28  sc_in_clk               i_clk;
29  intramoldu              microarchitecture;
30  moldu (sc_module_name n) :
31                       microarchitecture ("intern_module_of_moldu"),
32                       i_bool     ("i_bool"),
33                       i_int      ("i_int"),
34                       i_sc_int17 ("i_sc_int17"),
35                       o_int      ("o_int"),
36                       o_sc_uint38("o_sc_uint38"),
37                       reg_lv8    ("reg_lv8"),
38                       reg_int    ("reg_int"),
39                       reg_uint   ("reg_uint"),
40                       reg_sc_uint3 ("reg_sc_uint3"),
41                       reg_sc_int31 ("reg_sc_int31")
42  {
43  }
44};
45
46void
47dump_objects (ofstream &o, const vector<sc_object*> &obj_list)
48{
49  for (unsigned i = 0; i < obj_list.size(); i++)
50  {
51    const sc_object *obj = obj_list[i];
52    if (obj == NULL)
53      o << "\nError : NULL pointer in objects list !\n"; 
54    else
55      o << ((i != 0)?", ":"") << obj->name ();
56  }
57  o << "\n";
58}
59
60int
61sc_main (int argc, char ** argv)
62{
63  if (argc < 2)
64  {
65    cerr << "Usage : " << argv[0] << " <filename>\n";
66    exit (-1);
67  }
68 
69  ofstream o;
70  o.open (argv[1],ios::out | ios::trunc);
71  if (o.is_open () == false)
72  {
73    cerr << "Unable to open '" << argv[1] << "'.\n";
74    return 1;
75  }
76
77  sc_clock s_clk("s_clk");
78  sc_signal<bool>            s_bool;
79  sc_signal<int >            s_int;
80  sc_signal<sc_int<17> >     s_sc_int17;
81  sc_signal<sc_uint<38> >    s_sc_uint38;
82  moldu m("m");
83  intramoldu              microarchitecture("top_level_module");
84  m.i_clk      (s_clk);
85  m.i_bool     (s_bool);
86  m.i_int      (s_int);
87  m.i_sc_int17 (s_sc_int17);
88  m.o_int      (s_int);
89  m.o_sc_uint38(s_sc_uint38);
90
91  sc_start(0);
92  o << "Top level :\n";
93  dump_objects(o,sc_get_top_level_objects());
94  o << "\nChild of \"m\" :\n";
95  dump_objects(o,m.get_child_objects());
96  o << "\nChild of \"m.intern_module_of_moldu\" :\n";
97  dump_objects(o,m.microarchitecture.get_child_objects());
98  o << "\nChild of \"top_level_module\" :\n";
99  dump_objects(o,microarchitecture.get_child_objects());
100
101  o.close ();
102
103  return 0;
104}
105
Note: See TracBrowser for help on using the repository browser.