source: latest/test_regression/09092005b/system.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: 1.4 KB
Line 
1#include "systemc.h"
2
3#define ASSERT(x) \
4  { errnum++; \
5    if (!(x)) \
6    { \
7    cerr << "ASSERT : " #x "\n"; \
8    exit (errnum); \
9    } \
10  }
11
12using namespace std;
13
14struct hard : sc_module
15{
16  sc_in_clk    clk;
17  sc_in <int>  i1, i2;
18  sc_out<int>  o1, o2;
19
20  void f ()
21  {
22    o1 = i1;
23    o2 = i2;
24  }
25
26  SC_HAS_PROCESS(hard);
27  hard(sc_module_name)
28  {
29    SC_METHOD(f);
30    dont_initialize();
31    sensitive << i1 << i2;
32#ifdef SYSTEMCASS_SPECIFIC
33    o1 (i1);
34    o2 (i2);
35#endif
36  }
37};
38
39int
40sc_main (int argc, char ** argv)
41{
42  sc_clock        clk1("clk1");
43  sc_clock        clk2("clk2", 1, 0.5, 0, false);
44  sc_signal<int>  s[10];
45  hard a("a");
46  hard b("b");
47  hard c("c");
48
49  a.clk (clk1);
50  b.clk (clk2);
51  c.clk (clk2);
52
53  a.i1 (s[0]);
54
55  a.o1 (s[1]);
56  b.i1 (s[1]);
57
58  b.o1 (s[2]);
59
60  b.i2 (s[3]);
61
62  b.o2 (s[4]);
63  a.i2 (s[4]);
64
65  a.o2 (s[5]);
66
67  c.i1 (s[6]);
68  c.o1 (s[7]);
69  c.i2 (s[8]);
70  c.o2 (s[9]);
71
72        /* Open trace file */
73        sc_trace_file *system_trace_file;
74        system_trace_file = sc_create_vcd_trace_file ("trace_file");
75       
76        /* clks waveforms are always useful */
77        sc_trace(system_trace_file, clk1, "clk1");
78        sc_trace(system_trace_file, clk2, "clk2");
79
80  /* others signals */ 
81  for (int i = 0; i < 10; ++i)
82    sc_trace(system_trace_file, s[i], sc_gen_unique_name ("s"));
83 
84  /* initilization */
85  sc_initialize ();
86
87  s[0] = 1;
88  s[3] = 1;
89
90  sc_start (1);
91
92  s[0] = 123;
93  s[3] = 321;
94
95  sc_start (1);
96
97  return 0;
98}
99
Note: See TracBrowser for help on using the repository browser.