Last change
on this file since 26 was
21,
checked in by buchmann, 16 years ago
|
Add 2 another testbench to check various operators on sc_uint :
- system2.cpp works with SystemCASS
- systemCASS doesn't compile system3.cpp but using SystemC works fine.
SystemCASS needs a fix.
Implicit cast is not implicitly called when using SystemCASS. The workaround
is to call read() method.
|
File size:
988 bytes
|
Rev | Line | |
---|
[21] | 1 | #include "systemc.h" |
---|
| 2 | #include <iostream> |
---|
| 3 | |
---|
| 4 | using namespace std; |
---|
| 5 | |
---|
| 6 | #define ASSERT(x) \ |
---|
| 7 | { errnum++; \ |
---|
| 8 | if (!(x)) \ |
---|
| 9 | { \ |
---|
| 10 | cerr << "ASSERT : " #x "\n"; \ |
---|
| 11 | exit (errnum); \ |
---|
| 12 | } \ |
---|
| 13 | } |
---|
| 14 | |
---|
| 15 | using namespace std; |
---|
| 16 | |
---|
| 17 | typedef sc_uint<36> data_type; |
---|
| 18 | |
---|
| 19 | class param_t |
---|
| 20 | { |
---|
| 21 | public: |
---|
| 22 | static const unsigned int B = 36; |
---|
| 23 | typedef sc_dt::sc_uint<B> be_t; |
---|
| 24 | }; |
---|
| 25 | |
---|
| 26 | template <typename param_t> |
---|
| 27 | class test_t |
---|
| 28 | { |
---|
| 29 | public: |
---|
| 30 | typedef typename param_t::be_t test_be_t; |
---|
| 31 | |
---|
| 32 | test_be_t test_be; |
---|
| 33 | }; |
---|
| 34 | |
---|
| 35 | int |
---|
| 36 | sc_main (int argc, char ** argv) |
---|
| 37 | { |
---|
| 38 | sc_uint<36> a; |
---|
| 39 | const long long int ca = 0xf00000000LLU; |
---|
| 40 | a = ca; |
---|
| 41 | |
---|
| 42 | test_t<param_t> test1, test2; |
---|
| 43 | test1.test_be = a; |
---|
| 44 | test2.test_be = ca; |
---|
| 45 | |
---|
| 46 | if (test1.test_be != test2.test_be) |
---|
| 47 | return 1; |
---|
| 48 | |
---|
| 49 | bool ret = (test1.test_be == a); |
---|
| 50 | if (!ret) |
---|
| 51 | return 1; |
---|
| 52 | |
---|
| 53 | return 0; |
---|
| 54 | |
---|
| 55 | /* the following should be compiled and not executed */ |
---|
| 56 | sc_signal<test_t<param_t>::test_be_t > sig_test; |
---|
| 57 | sig_test = test1.test_be; |
---|
| 58 | |
---|
| 59 | ret = (sig_test == test2.test_be); |
---|
| 60 | if (!ret) |
---|
| 61 | return 1; |
---|
| 62 | } |
---|
| 63 | |
---|
Note: See
TracBrowser
for help on using the repository browser.