Last change
on this file since 21 was
18,
checked in by buchmann, 16 years ago
|
Fix:
- Disable checkings about the SOCVIEW environment variable. SOCVIEW is
optional.
- Add missing system header includes
- Add some potential signal order and signal graph to the testbench 29032005
- Add a new testbench : 15042009
- Check sc_uint operators with size = 36 (> 32)
|
File size:
1.2 KB
|
Rev | Line | |
---|
[1] | 1 | #include "systemc.h" |
---|
| 2 | #include <iostream> |
---|
[18] | 3 | #include <cstring> |
---|
[1] | 4 | |
---|
| 5 | #define ASSERT(x) \ |
---|
| 6 | { errnum++; \ |
---|
| 7 | if (!(x)) \ |
---|
| 8 | { \ |
---|
| 9 | cerr << "ASSERT : " #x "\n"; \ |
---|
| 10 | exit (errnum); \ |
---|
| 11 | } \ |
---|
| 12 | } |
---|
| 13 | |
---|
| 14 | #ifdef DEBUG |
---|
| 15 | #define CERR(x) \ |
---|
| 16 | { cerr << "" #x " = " << x << "\n"; } |
---|
| 17 | #else |
---|
| 18 | #define CERR(x) |
---|
| 19 | #endif |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | using namespace std; |
---|
| 23 | |
---|
| 24 | static int errnum = 0; |
---|
| 25 | |
---|
| 26 | void |
---|
| 27 | check_time (int i) |
---|
| 28 | { |
---|
| 29 | const sc_time &t = sc_time_stamp (); |
---|
| 30 | CERR(i); |
---|
| 31 | CERR(t.to_double()); |
---|
| 32 | ASSERT((int) (t.to_double ()) == i * 1000); |
---|
| 33 | CERR(t.to_seconds ()); |
---|
| 34 | double seconds = t.to_seconds()*1000000000; |
---|
| 35 | CERR(seconds); |
---|
| 36 | ASSERT(((int)seconds) == i); |
---|
| 37 | char s[256]; |
---|
| 38 | const char *unit; |
---|
| 39 | if (i == 0) |
---|
| 40 | unit = "s"; |
---|
| 41 | else if (i < 1000) |
---|
| 42 | unit = "ns"; |
---|
| 43 | else |
---|
| 44 | unit = "ns"; |
---|
| 45 | sprintf (s, "%d %s", i,unit); |
---|
| 46 | CERR(s); |
---|
| 47 | CERR(t.to_string()); |
---|
| 48 | ASSERT(strcmp (t.to_string ().c_str(), s)== 0); |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | int |
---|
| 52 | sc_main (int argc, char ** argv) |
---|
| 53 | { |
---|
| 54 | sc_clock clk ("clock"); |
---|
| 55 | |
---|
| 56 | check_time (0); |
---|
| 57 | sc_start (0); |
---|
| 58 | |
---|
| 59 | check_time (0); |
---|
| 60 | sc_start (1); |
---|
| 61 | check_time (1); |
---|
| 62 | |
---|
| 63 | sc_start (15); |
---|
| 64 | check_time (16); |
---|
| 65 | |
---|
| 66 | sc_start (7); |
---|
| 67 | check_time (23); |
---|
| 68 | |
---|
| 69 | sc_start (100); |
---|
| 70 | check_time (123); |
---|
| 71 | |
---|
| 72 | sc_start (1000); |
---|
| 73 | check_time (1123); |
---|
| 74 | cerr << "Test OK.\n"; |
---|
| 75 | return 0; |
---|
| 76 | } |
---|
| 77 | |
---|
Note: See
TracBrowser
for help on using the repository browser.