source: sources/test_regression/16062005b/system.cpp @ 55

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

Tried to clean the test_regression directory:

  • Code formatting
  • Supressed warnings
  • Made comprehensible outputs
  • Factorized Makefiles

There's still a lot to do (many tests don't pass for either good or bad reasons)

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