Last change
on this file since 56 was
55,
checked in by meunier, 11 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
|
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 | check_time(0); |
---|
50 | sc_start(sc_time(0, sc_core::SC_NS)); |
---|
51 | |
---|
52 | check_time(0); |
---|
53 | sc_start(sc_time(1, sc_core::SC_NS)); |
---|
54 | check_time(1); |
---|
55 | |
---|
56 | sc_start(sc_time(15, sc_core::SC_NS)); |
---|
57 | check_time(16); |
---|
58 | |
---|
59 | sc_start(sc_time(7, sc_core::SC_NS)); |
---|
60 | check_time(23); |
---|
61 | |
---|
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; |
---|
69 | } |
---|
70 | |
---|
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.