Last change
on this file since 65 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
|
Line | |
---|
1 | |
---|
2 | #include <iostream> |
---|
3 | #include <cstring> |
---|
4 | |
---|
5 | #include "systemc.h" |
---|
6 | #include "test.h" |
---|
7 | |
---|
8 | |
---|
9 | using namespace std; |
---|
10 | |
---|
11 | |
---|
12 | void check_time(int i) { |
---|
13 | const sc_time & t = sc_time_stamp(); |
---|
14 | cout << i << endl; |
---|
15 | |
---|
16 | #ifdef SYSTEMCASS_SPECIFIC |
---|
17 | ASSERT((int) (t.to_double()) == i); |
---|
18 | #else |
---|
19 | ASSERT((int) (t.to_double()) == i * 1000); |
---|
20 | #endif |
---|
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 | |
---|
29 | #ifdef SYSTEMCASS_SPECIFIC |
---|
30 | unit = "NS"; |
---|
31 | #else |
---|
32 | if (i == 0) { |
---|
33 | unit = "s"; |
---|
34 | } |
---|
35 | else { |
---|
36 | unit = "ns"; |
---|
37 | } |
---|
38 | #endif |
---|
39 | |
---|
40 | sprintf(s, "%d %s", i, unit); |
---|
41 | |
---|
42 | ASSERT(strcmp(t.to_string().c_str(), s) == 0); |
---|
43 | } |
---|
44 | |
---|
45 | |
---|
46 | int sc_main (int argc, char ** argv) { |
---|
47 | sc_clock clk("clock"); |
---|
48 | |
---|
49 | // Setup number of threads open-mp to 1 with the macro threads_omp() |
---|
50 | threads_omp(); |
---|
51 | |
---|
52 | check_time(0); |
---|
53 | sc_start(sc_time(0, sc_core::SC_NS)); |
---|
54 | |
---|
55 | check_time(0); |
---|
56 | sc_start(sc_time(1, sc_core::SC_NS)); |
---|
57 | check_time(1); |
---|
58 | |
---|
59 | sc_start(sc_time(15, sc_core::SC_NS)); |
---|
60 | check_time(16); |
---|
61 | |
---|
62 | sc_start(sc_time(7, sc_core::SC_NS)); |
---|
63 | check_time(23); |
---|
64 | |
---|
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; |
---|
72 | } |
---|
73 | |
---|
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.