source: trunk/IPs/systemC/Environnement/Queue/selftest/main.cpp @ 79

Last change on this file since 79 was 78, checked in by rosiere, 17 years ago

Add :

  • Execute_loop (must be test systemC)
  • Prediction
    • Direction : predifined scheme
    • Branch Target Buffer
  • iFetch_unit
    • ifetch_queue
    • pc management
  • Decod_unit
    • coming soon : support for custom operation
  • Rename_unit
    • RAT
    • Free_list
    • Dependence RAW check
    • Load store unit pointer
  • New Environnement (hierarchy_memory will remove in a next version)


Modif :

  • Manage Custom Operation
  • All component in execute_loop to use the new statistics management

Not Finish :

  • Return Address Stack
  • Environnement
File size: 10.9 KB
Line 
1#include <iostream>
2#include "../include/Sort_Queue.h"
3#include "../include/Sort_Queue_Dynamic.h"
4
5using namespace std;
6using namespace environnement;
7using namespace environnement::queue;
8
9
10#define TEST(x,y)                               \
11  {                                             \
12    cout << "Line " << __LINE__ << " : ";       \
13    if (x==y)                                   \
14      {                                         \
15        cout << "Test OK" << endl;              \
16      }                                         \
17    else                                        \
18      {                                         \
19        cout << "Test KO" << endl;              \
20        exit (EXIT_FAILURE);                    \
21      }                                         \
22  } while (0)
23
24class Entry
25{
26public : uint32_t _trdid;  // number of thread
27public : uint32_t _pktid;  // number of packet
28public : uint64_t _data;
29
30  Entry (void)
31  {
32    _trdid = 0;
33    _pktid = 0;
34    _data  = 0;
35  };
36 
37  Entry (uint32_t trdid ,
38         uint32_t pktid ,
39         uint64_t data  )
40  {
41    _trdid = trdid;
42    _pktid = pktid;
43    _data  = data ;
44  };
45 
46  friend std::ostream& operator<< (std::ostream& output, Entry x)
47  {
48    output << x._trdid << " " << x._pktid << " " << std::hex << x._data << std::dec;
49    return output;
50  }
51};
52
53
54int main (void)
55{
56  cout << "<main> Begin" << endl;
57
58  {
59    cout << "<main> * create and print a slot_t" << endl;
60    slot_t<uint32_t> * my_slot = new slot_t<uint32_t> (12, 0xdeadbeef);
61    cout << *my_slot << endl;
62   
63    delete my_slot;
64  }
65 
66  {
67    cout << "==================================" << endl; 
68    cout << "=====[ Sort_Queue ]===============" << endl;
69    cout << "==================================" << endl;     
70    cout << "<main>  * create a queue, size = 5" << endl;
71    Parameters * param = new Parameters (5);
72   
73    Sort_Queue <Entry> * my_Sort_Queue = new Sort_Queue <Entry> ("my_queue",param);
74   
75    cout << " * must be empty ..." << endl;
76    TEST(my_Sort_Queue->empty(),true );
77    TEST(my_Sort_Queue->full (),false);
78   
79    cout << " * insert 6 elements" << endl;
80   
81    TEST(my_Sort_Queue->push((uint32_t)5,Entry(1,1,0x33333333)),true ); cout << *my_Sort_Queue << endl;
82    TEST(my_Sort_Queue->push((uint32_t)6,Entry(2,2,0x55555555)),true ); cout << *my_Sort_Queue << endl;
83    TEST(my_Sort_Queue->push((uint32_t)3,Entry(3,3,0x22222222)),true ); cout << *my_Sort_Queue << endl;
84    TEST(my_Sort_Queue->push((uint32_t)5,Entry(4,4,0x44444444)),true ); cout << *my_Sort_Queue << endl;
85    TEST(my_Sort_Queue->push((uint32_t)1,Entry(5,5,0x11111111)),true ); cout << *my_Sort_Queue << endl;
86    TEST(my_Sort_Queue->push((uint32_t)4,Entry(6,6,0x00000BAD)),false); cout << *my_Sort_Queue << endl;
87   
88    cout << " * extract 6 elements" << endl;
89    TEST(my_Sort_Queue->pop()._data,0x11111111); cout << *my_Sort_Queue << endl;
90    TEST(my_Sort_Queue->empty(),false);
91    TEST(my_Sort_Queue->pop()._data,0x22222222); cout << *my_Sort_Queue << endl;
92    TEST(my_Sort_Queue->empty(),false);
93    TEST(my_Sort_Queue->pop()._data,0x33333333); cout << *my_Sort_Queue << endl;
94    TEST(my_Sort_Queue->empty(),false);
95    TEST(my_Sort_Queue->pop()._data,0x44444444); cout << *my_Sort_Queue << endl;
96    TEST(my_Sort_Queue->empty(),false);
97    TEST(my_Sort_Queue->pop()._data,0x55555555); cout << *my_Sort_Queue << endl;
98    TEST(my_Sort_Queue->empty(),true );
99   
100    cout << " * ajout de 8 elements (reset apres le deuxieme)" << endl;
101   
102    TEST(my_Sort_Queue->push((uint32_t)5,Entry(1,1,0x44444444)),true ); cout << *my_Sort_Queue << endl;
103    TEST(my_Sort_Queue->push((uint32_t)6,Entry(2,2,0x55555555)),true ); cout << *my_Sort_Queue << endl;
104    my_Sort_Queue->reset();                                               
105    TEST(my_Sort_Queue->push((uint32_t)3,Entry(3,3,0x22222222)),true ); cout << *my_Sort_Queue << endl;
106    TEST(my_Sort_Queue->push((uint32_t)5,Entry(4,4,0x33333333)),true ); cout << *my_Sort_Queue << endl;
107    TEST(my_Sort_Queue->push((uint32_t)5,Entry(1,1,0x44444444)),true ); cout << *my_Sort_Queue << endl;
108    TEST(my_Sort_Queue->push((uint32_t)7,Entry(2,2,0x55555555)),true ); cout << *my_Sort_Queue << endl;
109    TEST(my_Sort_Queue->push((uint32_t)1,Entry(5,5,0x11111111)),true ); cout << *my_Sort_Queue << endl;
110    TEST(my_Sort_Queue->push((uint32_t)4,Entry(6,6,0x00000BAD)),false); cout << *my_Sort_Queue << endl;
111   
112    cout << " * 3 transitions" << endl;
113   
114    my_Sort_Queue->transition(); cout << *my_Sort_Queue << endl;
115    my_Sort_Queue->transition(); cout << *my_Sort_Queue << endl;
116    my_Sort_Queue->transition(); cout << *my_Sort_Queue << endl;
117   
118    cout << " * extract 1 element" << endl;
119   
120    TEST(my_Sort_Queue->pop()._data,0x11111111);
121   
122    cout << *my_Sort_Queue << endl;
123   
124    for (uint32_t it = 0; it < my_Sort_Queue->nb_slot_use(); it ++)
125      {
126        slot_t<Entry> val = my_Sort_Queue->read(it);
127        cout << val._delay << " " << val._data << endl;
128      }
129   
130    cout << " * Test pop(n)" << endl;
131   
132    TEST(my_Sort_Queue->pop(1)._data, 0x33333333);
133    TEST(my_Sort_Queue->pop(2)._data, 0x55555555);
134    TEST(my_Sort_Queue->pop(0)._data, 0x22222222);
135    TEST(my_Sort_Queue->pop(0)._data, 0x44444444);
136   
137    delete my_Sort_Queue;
138    delete param;
139  }
140
141  {
142    cout << "==================================" << endl; 
143    cout << "=====[ Sort_Queue_Dynamic ]=======" << endl;
144    cout << "==================================" << endl;     
145    cout << "<main>  * create a queue, size = 5" << endl;
146    Parameters * param = new Parameters (5);
147   
148    Sort_Queue_Dynamic <Entry> * my_Sort_Queue_Dynamic = new Sort_Queue_Dynamic <Entry> ("my_queue",param);
149
150    cout << " * must be empty ..." << endl;
151   
152    TEST(my_Sort_Queue_Dynamic->empty(),true);
153    TEST(my_Sort_Queue_Dynamic->full (),false);
154
155    TEST(my_Sort_Queue_Dynamic->push(5,Entry(1,1, 4)),true ); cout << *my_Sort_Queue_Dynamic << endl;
156    TEST(my_Sort_Queue_Dynamic->push(6,Entry(2,2, 6)),true ); cout << *my_Sort_Queue_Dynamic << endl;
157    TEST(my_Sort_Queue_Dynamic->push(3,Entry(3,3, 2)),true ); cout << *my_Sort_Queue_Dynamic << endl;
158    TEST(my_Sort_Queue_Dynamic->push(5,Entry(4,4, 5)),true ); cout << *my_Sort_Queue_Dynamic << endl;
159    TEST(my_Sort_Queue_Dynamic->push(1,Entry(5,5, 1)),true ); cout << *my_Sort_Queue_Dynamic << endl;
160    TEST(my_Sort_Queue_Dynamic->push(4,Entry(6,6, 3)),true ); cout << *my_Sort_Queue_Dynamic << endl;
161    TEST(my_Sort_Queue_Dynamic->push(9,Entry(1,1,12)),true ); cout << *my_Sort_Queue_Dynamic << endl;
162    TEST(my_Sort_Queue_Dynamic->push(6,Entry(2,2, 7)),true ); cout << *my_Sort_Queue_Dynamic << endl;
163    TEST(my_Sort_Queue_Dynamic->push(7,Entry(3,3, 8)),true ); cout << *my_Sort_Queue_Dynamic << endl;
164    TEST(my_Sort_Queue_Dynamic->push(7,Entry(4,4, 9)),true ); cout << *my_Sort_Queue_Dynamic << endl;
165    TEST(my_Sort_Queue_Dynamic->push(8,Entry(5,5,11)),true ); cout << *my_Sort_Queue_Dynamic << endl;
166    TEST(my_Sort_Queue_Dynamic->push(7,Entry(6,6,10)),true ); cout << *my_Sort_Queue_Dynamic << endl;
167
168    TEST(my_Sort_Queue_Dynamic->pop()._data, 1 ); cout << *my_Sort_Queue_Dynamic << endl;
169    TEST(my_Sort_Queue_Dynamic->pop()._data, 2 ); cout << *my_Sort_Queue_Dynamic << endl;
170    TEST(my_Sort_Queue_Dynamic->pop()._data, 3 ); cout << *my_Sort_Queue_Dynamic << endl;
171    TEST(my_Sort_Queue_Dynamic->pop()._data, 4 ); cout << *my_Sort_Queue_Dynamic << endl;
172    TEST(my_Sort_Queue_Dynamic->pop()._data, 5 ); cout << *my_Sort_Queue_Dynamic << endl;
173    TEST(my_Sort_Queue_Dynamic->pop()._data, 6 ); cout << *my_Sort_Queue_Dynamic << endl;
174    TEST(my_Sort_Queue_Dynamic->pop()._data, 7 ); cout << *my_Sort_Queue_Dynamic << endl;
175    TEST(my_Sort_Queue_Dynamic->pop()._data, 8 ); cout << *my_Sort_Queue_Dynamic << endl;
176    TEST(my_Sort_Queue_Dynamic->pop()._data, 9 ); cout << *my_Sort_Queue_Dynamic << endl;
177    TEST(my_Sort_Queue_Dynamic->pop()._data,10 ); cout << *my_Sort_Queue_Dynamic << endl;
178    TEST(my_Sort_Queue_Dynamic->pop()._data,11 ); cout << *my_Sort_Queue_Dynamic << endl;
179    TEST(my_Sort_Queue_Dynamic->pop()._data,12 ); cout << *my_Sort_Queue_Dynamic << endl;
180
181
182    TEST(my_Sort_Queue_Dynamic->push(5,Entry(1,1, 4)),true ); cout << *my_Sort_Queue_Dynamic << endl;
183    TEST(my_Sort_Queue_Dynamic->push(6,Entry(2,2, 6)),true ); cout << *my_Sort_Queue_Dynamic << endl;
184    TEST(my_Sort_Queue_Dynamic->push(3,Entry(3,3, 2)),true ); cout << *my_Sort_Queue_Dynamic << endl;
185    TEST(my_Sort_Queue_Dynamic->push(5,Entry(4,4, 5)),true ); cout << *my_Sort_Queue_Dynamic << endl;
186    TEST(my_Sort_Queue_Dynamic->push(1,Entry(5,5, 1)),true ); cout << *my_Sort_Queue_Dynamic << endl;
187    TEST(my_Sort_Queue_Dynamic->push(4,Entry(6,6, 3)),true ); cout << *my_Sort_Queue_Dynamic << endl;
188    TEST(my_Sort_Queue_Dynamic->push(9,Entry(1,1,12)),true ); cout << *my_Sort_Queue_Dynamic << endl;
189    TEST(my_Sort_Queue_Dynamic->push(6,Entry(2,2, 7)),true ); cout << *my_Sort_Queue_Dynamic << endl;
190    TEST(my_Sort_Queue_Dynamic->push(7,Entry(3,3, 8)),true ); cout << *my_Sort_Queue_Dynamic << endl;
191    TEST(my_Sort_Queue_Dynamic->push(7,Entry(4,4, 9)),true ); cout << *my_Sort_Queue_Dynamic << endl;
192    TEST(my_Sort_Queue_Dynamic->push(8,Entry(5,5,11)),true ); cout << *my_Sort_Queue_Dynamic << endl;
193    TEST(my_Sort_Queue_Dynamic->push(7,Entry(6,6,10)),true ); cout << *my_Sort_Queue_Dynamic << endl;
194
195    TEST(my_Sort_Queue_Dynamic->pop()._data, 1 )            ; cout << *my_Sort_Queue_Dynamic << endl;
196    TEST(my_Sort_Queue_Dynamic->pop()._data, 2 )            ; cout << *my_Sort_Queue_Dynamic << endl;
197
198    TEST(my_Sort_Queue_Dynamic->push(0,Entry(1,1, 1)),true ); cout << *my_Sort_Queue_Dynamic << endl;
199    TEST(my_Sort_Queue_Dynamic->push(0,Entry(2,2, 2)),true ); cout << *my_Sort_Queue_Dynamic << endl;
200    TEST(my_Sort_Queue_Dynamic->pop()._data, 1 )            ; cout << *my_Sort_Queue_Dynamic << endl;
201    TEST(my_Sort_Queue_Dynamic->pop()._data, 2 )            ; cout << *my_Sort_Queue_Dynamic << endl;
202    TEST(my_Sort_Queue_Dynamic->push(0,Entry(1,1, 1)),true ); cout << *my_Sort_Queue_Dynamic << endl;
203    TEST(my_Sort_Queue_Dynamic->push(0,Entry(2,2, 2)),true ); cout << *my_Sort_Queue_Dynamic << endl;
204    TEST(my_Sort_Queue_Dynamic->pop()._data, 1 )            ; cout << *my_Sort_Queue_Dynamic << endl;
205    TEST(my_Sort_Queue_Dynamic->pop()._data, 2 )            ; cout << *my_Sort_Queue_Dynamic << endl;
206    TEST(my_Sort_Queue_Dynamic->push(0,Entry(1,1, 1)),true ); cout << *my_Sort_Queue_Dynamic << endl;
207    TEST(my_Sort_Queue_Dynamic->push(0,Entry(2,2, 2)),true ); cout << *my_Sort_Queue_Dynamic << endl;
208    TEST(my_Sort_Queue_Dynamic->pop()._data, 1 )            ; cout << *my_Sort_Queue_Dynamic << endl;
209    TEST(my_Sort_Queue_Dynamic->pop()._data, 2 )            ; cout << *my_Sort_Queue_Dynamic << endl;
210    TEST(my_Sort_Queue_Dynamic->push(0,Entry(1,1, 1)),true ); cout << *my_Sort_Queue_Dynamic << endl;
211    TEST(my_Sort_Queue_Dynamic->push(0,Entry(2,2, 2)),true ); cout << *my_Sort_Queue_Dynamic << endl;
212    TEST(my_Sort_Queue_Dynamic->pop()._data, 1 )            ; cout << *my_Sort_Queue_Dynamic << endl;
213    TEST(my_Sort_Queue_Dynamic->pop()._data, 2 )            ; cout << *my_Sort_Queue_Dynamic << endl;
214    TEST(my_Sort_Queue_Dynamic->pop()._data, 3 )            ; cout << *my_Sort_Queue_Dynamic << endl;
215    TEST(my_Sort_Queue_Dynamic->pop(2)._data, 6 )           ; cout << *my_Sort_Queue_Dynamic << endl;
216
217    delete my_Sort_Queue_Dynamic;
218    delete param;
219  }
220
221  cout << "<main> End" << endl;
222
223  return EXIT_SUCCESS;
224}
Note: See TracBrowser for help on using the repository browser.