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
|
Rev | Line | |
---|
[1] | 1 | #include "systemc.h" |
---|
| 2 | #include <iostream> |
---|
| 3 | #include <fstream> |
---|
| 4 | #include <vector> |
---|
| 5 | |
---|
| 6 | #define ASSERT(x) { if (!(x)) { \ |
---|
| 7 | cerr << "ASSERT : " #x \ |
---|
| 8 | << " in function '" << __FUNCTION__ \ |
---|
| 9 | << "'\n"; exit (-1); \ |
---|
| 10 | } \ |
---|
| 11 | } |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | using namespace std; |
---|
| 15 | |
---|
| 16 | struct D : sc_module |
---|
| 17 | { |
---|
| 18 | D (sc_module_name n) |
---|
| 19 | { |
---|
| 20 | } |
---|
| 21 | }; |
---|
| 22 | |
---|
| 23 | struct C : sc_module |
---|
| 24 | { |
---|
| 25 | C (sc_module_name n) |
---|
| 26 | { |
---|
| 27 | } |
---|
| 28 | }; |
---|
| 29 | |
---|
| 30 | struct B : sc_module |
---|
| 31 | { |
---|
| 32 | D d1; |
---|
| 33 | D d2; |
---|
| 34 | C c; |
---|
| 35 | B (sc_module_name n) : d1("d1"), d2("d2"), c("c") |
---|
| 36 | { |
---|
| 37 | } |
---|
| 38 | }; |
---|
| 39 | |
---|
| 40 | struct A : sc_module |
---|
| 41 | { |
---|
| 42 | B b; |
---|
| 43 | C c; |
---|
| 44 | A (sc_module_name n) : b("b"), c("c") |
---|
| 45 | { |
---|
| 46 | } |
---|
| 47 | }; |
---|
| 48 | |
---|
| 49 | struct top_level1 : sc_module |
---|
| 50 | { |
---|
| 51 | A a; |
---|
| 52 | D d; |
---|
| 53 | top_level1(sc_module_name insname) : sc_module (insname), a("a"), d("d") |
---|
| 54 | { |
---|
| 55 | ASSERT(strcmp ((const char*)insname,"top1") == 0); |
---|
| 56 | } |
---|
| 57 | }; |
---|
| 58 | |
---|
| 59 | struct top_level2 : sc_module |
---|
| 60 | { |
---|
| 61 | B b1; |
---|
| 62 | B b2; |
---|
| 63 | C c; |
---|
| 64 | top_level2(sc_module_name insname) : b1("b1"), b2("b2"), c("c") |
---|
| 65 | { |
---|
| 66 | ASSERT(strcmp ((const char*)insname,"top2") == 0); |
---|
| 67 | ofstream o; |
---|
| 68 | o.open ("results.txt"); |
---|
| 69 | o << (const char*)insname << endl; |
---|
| 70 | o << insname << endl; |
---|
| 71 | o.close (); |
---|
| 72 | } |
---|
| 73 | }; |
---|
| 74 | |
---|
| 75 | int |
---|
| 76 | sc_main (int argc, char ** argv) |
---|
| 77 | { |
---|
| 78 | if (argc < 1) |
---|
| 79 | { |
---|
| 80 | cerr << "Usage : " << argv[0] << "\n"; |
---|
| 81 | exit (-1); |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | sc_clock clk("clock"); |
---|
| 85 | top_level1 top1("top1"); |
---|
| 86 | top_level2 top2("top2"); |
---|
| 87 | |
---|
| 88 | sc_start(0); |
---|
| 89 | |
---|
| 90 | return 0; |
---|
| 91 | } |
---|
| 92 | |
---|
Note: See
TracBrowser
for help on using the repository browser.