Last change
on this file since 64 was
60,
checked in by meunier, 8 years ago
|
- Intégration des modifications de Clément,
qui a intégré la version parallélisée de systemcass
faite par Manuel.
|
File size:
1.5 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 | |
---|
[60] | 49 | // Setup number of threads open-mp to 1 with the macro threads_omp() |
---|
| 50 | threads_omp(); |
---|
| 51 | |
---|
[55] | 52 | check_time(0); |
---|
| 53 | sc_start(sc_time(0, sc_core::SC_NS)); |
---|
[1] | 54 | |
---|
[55] | 55 | check_time(0); |
---|
| 56 | sc_start(sc_time(1, sc_core::SC_NS)); |
---|
| 57 | check_time(1); |
---|
[1] | 58 | |
---|
[55] | 59 | sc_start(sc_time(15, sc_core::SC_NS)); |
---|
| 60 | check_time(16); |
---|
[1] | 61 | |
---|
[55] | 62 | sc_start(sc_time(7, sc_core::SC_NS)); |
---|
| 63 | check_time(23); |
---|
[1] | 64 | |
---|
[55] | 65 | sc_start(sc_time(100, sc_core::SC_NS)); |
---|
| 66 | check_time(123); |
---|
| 67 | |
---|
| 68 | sc_start(sc_time(1000, sc_core::SC_NS)); |
---|
| 69 | check_time(1123); |
---|
| 70 | |
---|
| 71 | return 0; |
---|
[1] | 72 | } |
---|
| 73 | |
---|
[55] | 74 | |
---|
| 75 | /* |
---|
| 76 | # Local Variables: |
---|
| 77 | # tab-width: 4; |
---|
| 78 | # c-basic-offset: 4; |
---|
| 79 | # c-file-offsets:((innamespace . 0)(inline-open . 0)); |
---|
| 80 | # indent-tabs-mode: nil; |
---|
| 81 | # End: |
---|
| 82 | # |
---|
| 83 | # vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 84 | */ |
---|
| 85 | |
---|
Note: See
TracBrowser
for help on using the repository browser.