Last change
on this file since 58 was
55,
checked in by meunier, 12 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:
1.4 KB
|
Rev | Line | |
---|
[55] | 1 | |
---|
[1] | 2 | #include <iostream> |
---|
[18] | 3 | #include <cstring> |
---|
[1] | 4 | |
---|
[55] | 5 | #include "systemc.h" |
---|
| 6 | #include "test.h" |
---|
[1] | 7 | |
---|
| 8 | |
---|
| 9 | using namespace std; |
---|
| 10 | |
---|
| 11 | |
---|
[55] | 12 | void check_time(int i) { |
---|
| 13 | const sc_time & t = sc_time_stamp(); |
---|
| 14 | cout << i << endl; |
---|
| 15 | |
---|
[23] | 16 | #ifdef SYSTEMCASS_SPECIFIC |
---|
[55] | 17 | ASSERT((int) (t.to_double()) == i); |
---|
[23] | 18 | #else |
---|
[55] | 19 | ASSERT((int) (t.to_double()) == i * 1000); |
---|
[23] | 20 | #endif |
---|
[55] | 21 | |
---|
| 22 | cout << t.to_seconds() << endl; |
---|
| 23 | double seconds = t.to_seconds() * 1000000000; |
---|
| 24 | cout << seconds << endl; |
---|
| 25 | ASSERT(((int) seconds) == i); |
---|
| 26 | char s[256]; |
---|
| 27 | const char * unit; |
---|
| 28 | |
---|
[23] | 29 | #ifdef SYSTEMCASS_SPECIFIC |
---|
[55] | 30 | unit = "NS"; |
---|
[23] | 31 | #else |
---|
[55] | 32 | if (i == 0) { |
---|
| 33 | unit = "s"; |
---|
| 34 | } |
---|
| 35 | else { |
---|
| 36 | unit = "ns"; |
---|
| 37 | } |
---|
[23] | 38 | #endif |
---|
[55] | 39 | |
---|
| 40 | sprintf(s, "%d %s", i, unit); |
---|
| 41 | |
---|
| 42 | ASSERT(strcmp(t.to_string().c_str(), s) == 0); |
---|
[1] | 43 | } |
---|
| 44 | |
---|
| 45 | |
---|
[55] | 46 | int sc_main (int argc, char ** argv) { |
---|
| 47 | sc_clock clk("clock"); |
---|
[1] | 48 | |
---|
[55] | 49 | check_time(0); |
---|
| 50 | sc_start(sc_time(0, sc_core::SC_NS)); |
---|
[1] | 51 | |
---|
[55] | 52 | check_time(0); |
---|
| 53 | sc_start(sc_time(1, sc_core::SC_NS)); |
---|
| 54 | check_time(1); |
---|
[1] | 55 | |
---|
[55] | 56 | sc_start(sc_time(15, sc_core::SC_NS)); |
---|
| 57 | check_time(16); |
---|
[1] | 58 | |
---|
[55] | 59 | sc_start(sc_time(7, sc_core::SC_NS)); |
---|
| 60 | check_time(23); |
---|
[1] | 61 | |
---|
[55] | 62 | sc_start(sc_time(100, sc_core::SC_NS)); |
---|
| 63 | check_time(123); |
---|
| 64 | |
---|
| 65 | sc_start(sc_time(1000, sc_core::SC_NS)); |
---|
| 66 | check_time(1123); |
---|
| 67 | |
---|
| 68 | return 0; |
---|
[1] | 69 | } |
---|
| 70 | |
---|
[55] | 71 | |
---|
| 72 | /* |
---|
| 73 | # Local Variables: |
---|
| 74 | # tab-width: 4; |
---|
| 75 | # c-basic-offset: 4; |
---|
| 76 | # c-file-offsets:((innamespace . 0)(inline-open . 0)); |
---|
| 77 | # indent-tabs-mode: nil; |
---|
| 78 | # End: |
---|
| 79 | # |
---|
| 80 | # vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 81 | */ |
---|
| 82 | |
---|
Note: See
TracBrowser
for help on using the repository browser.