1 | /* |
---|
2 | * $Id: test.cpp 88 2008-12-10 18:31:39Z rosiere $ |
---|
3 | * |
---|
4 | * [ Description ] |
---|
5 | * |
---|
6 | * Test |
---|
7 | */ |
---|
8 | |
---|
9 | #define NB_ITERATION 1 |
---|
10 | #define CYCLE_MAX (2048*NB_ITERATION) |
---|
11 | |
---|
12 | #include "Behavioural/Generic/Queue/SelfTest/include/test.h" |
---|
13 | #include "Common/include/Test.h" |
---|
14 | |
---|
15 | void test (string name, |
---|
16 | morpheo::behavioural::generic::queue::Parameters * _param) |
---|
17 | { |
---|
18 | cout << "<" << name << "> : Simulation SystemC" << endl; |
---|
19 | |
---|
20 | #ifdef STATISTICS |
---|
21 | morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,50); |
---|
22 | #endif |
---|
23 | |
---|
24 | Tusage_t _usage = USE_ALL; |
---|
25 | |
---|
26 | // _usage = usage_unset(_usage,USE_SYSTEMC ); |
---|
27 | // _usage = usage_unset(_usage,USE_VHDL ); |
---|
28 | // _usage = usage_unset(_usage,USE_VHDL_TESTBENCH ); |
---|
29 | // _usage = usage_unset(_usage,USE_VHDL_TESTBENCH_ASSERT); |
---|
30 | // _usage = usage_unset(_usage,USE_POSITION ); |
---|
31 | // _usage = usage_unset(_usage,USE_STATISTICS ); |
---|
32 | // _usage = usage_unset(_usage,USE_INFORMATION ); |
---|
33 | |
---|
34 | Queue * _Queue = new Queue |
---|
35 | (name.c_str(), |
---|
36 | #ifdef STATISTICS |
---|
37 | _parameters_statistics, |
---|
38 | #endif |
---|
39 | _param, |
---|
40 | _usage); |
---|
41 | |
---|
42 | #ifdef SYSTEMC |
---|
43 | /********************************************************************* |
---|
44 | * Déclarations des signaux |
---|
45 | *********************************************************************/ |
---|
46 | string rename; |
---|
47 | |
---|
48 | sc_clock * in_CLOCK = new sc_clock ("clock", 1.0, 0.5); |
---|
49 | sc_signal<Tcontrol_t> * in_NRESET = new sc_signal<Tcontrol_t> ("NRESET"); |
---|
50 | sc_signal<Tcontrol_t> * in_INSERT_VAL = new sc_signal<Tcontrol_t> ( "in_INSERT_VAL" ); |
---|
51 | sc_signal<Tcontrol_t> * out_INSERT_ACK = new sc_signal<Tcontrol_t> ("out_INSERT_ACK" ); |
---|
52 | sc_signal<Tdata_t > * in_INSERT_DATA = new sc_signal<Tdata_t > ( "in_INSERT_DATA"); |
---|
53 | sc_signal<Tcontrol_t> * out_RETIRE_VAL = new sc_signal<Tcontrol_t> ("out_RETIRE_VAL" ); |
---|
54 | sc_signal<Tcontrol_t> * in_RETIRE_ACK = new sc_signal<Tcontrol_t> ( "in_RETIRE_ACK" ); |
---|
55 | sc_signal<Tdata_t > * out_RETIRE_DATA = new sc_signal<Tdata_t > ("out_RETIRE_DATA"); |
---|
56 | |
---|
57 | /******************************************************** |
---|
58 | * Instanciation |
---|
59 | ********************************************************/ |
---|
60 | |
---|
61 | cout << "<" << name << "> Instanciation of _Queue" << endl; |
---|
62 | |
---|
63 | (*(_Queue->in_CLOCK)) (*(in_CLOCK)); |
---|
64 | (*(_Queue->in_NRESET)) (*(in_NRESET)); |
---|
65 | |
---|
66 | (*(_Queue-> in_INSERT_VAL )) (*( in_INSERT_VAL )); |
---|
67 | (*(_Queue->out_INSERT_ACK )) (*(out_INSERT_ACK )); |
---|
68 | (*(_Queue-> in_INSERT_DATA)) (*( in_INSERT_DATA)); |
---|
69 | (*(_Queue->out_RETIRE_VAL )) (*(out_RETIRE_VAL )); |
---|
70 | (*(_Queue-> in_RETIRE_ACK )) (*( in_RETIRE_ACK )); |
---|
71 | (*(_Queue->out_RETIRE_DATA)) (*(out_RETIRE_DATA)); |
---|
72 | |
---|
73 | cout << "<" << name << "> Start Simulation ............" << endl; |
---|
74 | Time * _time = new Time(); |
---|
75 | |
---|
76 | /******************************************************** |
---|
77 | * Simulation - Begin |
---|
78 | ********************************************************/ |
---|
79 | |
---|
80 | // Initialisation |
---|
81 | const int32_t percent_insert_transaction = 75; |
---|
82 | const int32_t percent_retire_transaction = 75; |
---|
83 | const uint32_t nb_request = 3*_param->_size_queue; |
---|
84 | |
---|
85 | const uint32_t seed = 0; |
---|
86 | //const uint32_t seed = static_cast<uint32_t>(time(NULL)); |
---|
87 | |
---|
88 | srand(seed); |
---|
89 | |
---|
90 | SC_START(0); |
---|
91 | LABEL("Initialisation"); |
---|
92 | |
---|
93 | in_INSERT_VAL -> write(0); |
---|
94 | in_RETIRE_ACK -> write(0); |
---|
95 | |
---|
96 | LABEL("Reset"); |
---|
97 | in_NRESET->write(0); |
---|
98 | SC_START(5); |
---|
99 | in_NRESET->write(1); |
---|
100 | |
---|
101 | LABEL("Loop of Test"); |
---|
102 | |
---|
103 | uint32_t data_in = 0; |
---|
104 | uint32_t data_out = 0; |
---|
105 | |
---|
106 | for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++) |
---|
107 | { |
---|
108 | LABEL("Iteration %d",iteration); |
---|
109 | |
---|
110 | while (data_out <= nb_request) |
---|
111 | { |
---|
112 | in_INSERT_VAL -> write((rand()%100)<percent_insert_transaction); |
---|
113 | in_INSERT_DATA -> write(data_in); |
---|
114 | in_RETIRE_ACK -> write((rand()%100)<percent_retire_transaction); |
---|
115 | |
---|
116 | SC_START(0); // genMoore |
---|
117 | |
---|
118 | if ( in_INSERT_VAL->read() and out_INSERT_ACK->read()) |
---|
119 | { |
---|
120 | LABEL ("Transaction with interface : INSERT"); |
---|
121 | data_in ++; |
---|
122 | } |
---|
123 | if (out_RETIRE_VAL->read() and in_RETIRE_ACK->read()) |
---|
124 | { |
---|
125 | LABEL ("Transaction with interface : RETIRE"); |
---|
126 | TEST(Tdata_t, out_RETIRE_DATA->read(), data_out); |
---|
127 | data_out++; |
---|
128 | } |
---|
129 | |
---|
130 | SC_START(1); |
---|
131 | } |
---|
132 | } |
---|
133 | |
---|
134 | /******************************************************** |
---|
135 | * Simulation - End |
---|
136 | ********************************************************/ |
---|
137 | |
---|
138 | TEST_OK ("End of Simulation"); |
---|
139 | delete _time; |
---|
140 | cout << "<" << name << "> ............ Stop Simulation" << endl; |
---|
141 | |
---|
142 | delete in_CLOCK; |
---|
143 | delete in_NRESET; |
---|
144 | #endif |
---|
145 | |
---|
146 | delete _Queue; |
---|
147 | #ifdef STATISTICS |
---|
148 | delete _parameters_statistics; |
---|
149 | #endif |
---|
150 | } |
---|