[67] | 1 | /* |
---|
| 2 | * $Id: top_test.cpp 113 2009-04-14 18:39:12Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | * Test |
---|
| 7 | */ |
---|
| 8 | |
---|
[113] | 9 | #include "Behavioural/Generic/Queue/SelfTest/include/top.h" |
---|
[100] | 10 | #include "Behavioural/include/Allocation.h" |
---|
[67] | 11 | |
---|
[113] | 12 | void top::test (void) |
---|
[67] | 13 | { |
---|
| 14 | #ifdef SYSTEMC |
---|
[113] | 15 | if (usage_is_set(_usage,USE_SYSTEMC)) |
---|
[67] | 16 | { |
---|
[113] | 17 | msgInformation(_("<%s> : Start Simulation ............\n"),name.c_str()); |
---|
| 18 | |
---|
| 19 | Time * _time = new Time(); |
---|
| 20 | |
---|
| 21 | /******************************************************** |
---|
| 22 | * Simulation - Begin |
---|
| 23 | ********************************************************/ |
---|
| 24 | |
---|
| 25 | // Initialisation |
---|
| 26 | const int32_t percent_insert_transaction = 75; |
---|
| 27 | const int32_t percent_retire_transaction = 75; |
---|
| 28 | const uint32_t nb_request = 3*_param->_size_queue; |
---|
| 29 | |
---|
| 30 | const uint32_t seed = 0; |
---|
| 31 | //const uint32_t seed = static_cast<uint32_t>(time(NULL)); |
---|
| 32 | |
---|
| 33 | srand(seed); |
---|
| 34 | |
---|
| 35 | SC_CYCLE(0); |
---|
| 36 | LABEL("Initialisation"); |
---|
| 37 | |
---|
| 38 | in_INSERT_VAL -> write(0); |
---|
| 39 | in_RETIRE_ACK -> write(0); |
---|
| 40 | |
---|
| 41 | LABEL("Reset"); |
---|
| 42 | in_NRESET->write(0); |
---|
| 43 | SC_CYCLE(5); |
---|
| 44 | in_NRESET->write(1); |
---|
| 45 | |
---|
| 46 | LABEL("Loop of Test"); |
---|
| 47 | |
---|
| 48 | uint32_t data_in = 0; |
---|
| 49 | uint32_t data_out = 0; |
---|
| 50 | uint32_t nb_elt = 0; |
---|
| 51 | |
---|
| 52 | for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++) |
---|
| 53 | { |
---|
| 54 | LABEL("Iteration %d",iteration); |
---|
| 55 | |
---|
| 56 | while (data_out <= nb_request) |
---|
[100] | 57 | { |
---|
[113] | 58 | in_INSERT_VAL -> write((rand()%100)<percent_insert_transaction); |
---|
| 59 | in_INSERT_DATA -> write(data_in); |
---|
| 60 | in_RETIRE_ACK -> write((rand()%100)<percent_retire_transaction); |
---|
| 61 | |
---|
| 62 | SC_CYCLE(0); // genMoore |
---|
| 63 | |
---|
| 64 | for (uint32_t i=0; i<_param->_nb_port_slot; ++i) |
---|
| 65 | { |
---|
| 66 | TEST(Tcontrol_t, out_SLOT_VAL [i]->read(), (i<nb_elt)); |
---|
| 67 | if (i<nb_elt) |
---|
| 68 | TEST(Tdata_t , out_SLOT_DATA[i]->read(), data_out+i); |
---|
| 69 | |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | if ( in_INSERT_VAL->read() and out_INSERT_ACK->read()) |
---|
| 73 | { |
---|
| 74 | LABEL ("Transaction with interface : INSERT"); |
---|
| 75 | data_in ++; |
---|
| 76 | nb_elt ++; |
---|
| 77 | } |
---|
| 78 | if (out_RETIRE_VAL->read() and in_RETIRE_ACK->read()) |
---|
| 79 | { |
---|
| 80 | LABEL ("Transaction with interface : RETIRE"); |
---|
| 81 | TEST(Tdata_t, out_RETIRE_DATA->read(), data_out); |
---|
| 82 | data_out++; |
---|
| 83 | nb_elt --; |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | SC_CYCLE(1); |
---|
[100] | 87 | } |
---|
[113] | 88 | } |
---|
| 89 | |
---|
| 90 | /******************************************************** |
---|
| 91 | * Simulation - End |
---|
| 92 | ********************************************************/ |
---|
| 93 | |
---|
| 94 | TEST_OK (""); |
---|
| 95 | |
---|
| 96 | sc_stop(); |
---|
| 97 | delete _time; |
---|
| 98 | |
---|
| 99 | msgInformation(_("<%s> : ............ Stop Simulation\n"),name.c_str()); |
---|
[67] | 100 | } |
---|
| 101 | #endif |
---|
| 102 | } |
---|