1 |
2 |
acastong |
//main.cpp for history_buffer_l3 testbench
|
2 |
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
3 |
|
|
* Version: MPL 1.1
|
4 |
|
|
*
|
5 |
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
6 |
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
7 |
|
|
* the License. You may obtain a copy of the License at
|
8 |
|
|
* http://www.mozilla.org/MPL/
|
9 |
|
|
*
|
10 |
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
11 |
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
12 |
|
|
* for the specific language governing rights and limitations under the
|
13 |
|
|
* License.
|
14 |
|
|
*
|
15 |
|
|
* The Original Code is HyperTransport Tunnel IP Core.
|
16 |
|
|
*
|
17 |
|
|
* The Initial Developer of the Original Code is
|
18 |
|
|
* Ecole Polytechnique de Montreal.
|
19 |
|
|
* Portions created by the Initial Developer are Copyright (C) 2005
|
20 |
|
|
* the Initial Developer. All Rights Reserved.
|
21 |
|
|
*
|
22 |
|
|
* Contributor(s):
|
23 |
|
|
* Ami Castonguay <acastong@grm.polymtl.ca>
|
24 |
|
|
*
|
25 |
|
|
* Alternatively, the contents of this file may be used under the terms
|
26 |
|
|
* of the Polytechnique HyperTransport Tunnel IP Core Source Code License
|
27 |
|
|
* (the "PHTICSCL License", see the file PHTICSCL.txt), in which case the
|
28 |
|
|
* provisions of PHTICSCL License are applicable instead of those
|
29 |
|
|
* above. If you wish to allow use of your version of this file only
|
30 |
|
|
* under the terms of the PHTICSCL License and not to allow others to use
|
31 |
|
|
* your version of this file under the MPL, indicate your decision by
|
32 |
|
|
* deleting the provisions above and replace them with the notice and
|
33 |
|
|
* other provisions required by the PHTICSCL License. If you do not delete
|
34 |
|
|
* the provisions above, a recipient may use your version of this file
|
35 |
|
|
* under either the MPL or the PHTICSCL License."
|
36 |
|
|
*
|
37 |
|
|
* ***** END LICENSE BLOCK ***** */
|
38 |
|
|
|
39 |
|
|
#include "../../../rtl/systemc/core_synth/synth_datatypes.h"
|
40 |
|
|
#include "../../../rtl/systemc/core_synth/constants.h"
|
41 |
|
|
|
42 |
|
|
#include "../../../rtl/systemc/flow_control_l2/history_buffer_l3.h"
|
43 |
|
|
#include "history_buffer_l3_tb.h"
|
44 |
|
|
|
45 |
|
|
#include <iostream>
|
46 |
|
|
#include <string>
|
47 |
|
|
#include <sstream>
|
48 |
|
|
#include <iomanip>
|
49 |
|
|
|
50 |
|
|
using namespace std;
|
51 |
|
|
|
52 |
|
|
int sc_main( int argc, char* argv[] ){
|
53 |
|
|
|
54 |
|
|
//The Design Under Test
|
55 |
|
|
history_buffer_l3* dut = new history_buffer_l3("history_buffer_l3");
|
56 |
|
|
//The TestBench
|
57 |
|
|
history_buffer_l3_tb* tb = new history_buffer_l3_tb("history_buffer_l3_tb");
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
//Signals used to link the design to the testbench
|
61 |
|
|
sc_clock clk("clk", 1); // system clk
|
62 |
|
|
sc_signal <sc_bv<32> > history_packet;
|
63 |
|
|
sc_signal <bool > history_playback_done;
|
64 |
|
|
sc_signal <bool > begin_history_playback;
|
65 |
|
|
sc_signal <bool > stop_history_playback;
|
66 |
|
|
sc_signal <bool > history_playback_ready;
|
67 |
|
|
sc_signal <bool > consume_history;
|
68 |
|
|
sc_signal <bool > room_available_in_history;
|
69 |
|
|
sc_signal <bool > add_to_history;
|
70 |
|
|
|
71 |
|
|
sc_signal <bool > new_history_entry;
|
72 |
|
|
sc_signal <sc_uint<5> > new_history_entry_size_m1;
|
73 |
|
|
sc_signal<sc_bv<32> > fc_dword_lk;
|
74 |
|
|
sc_signal<bool> nop_received;
|
75 |
|
|
sc_signal<sc_uint<8> > ack_value;
|
76 |
|
|
sc_signal<bool> resetx;
|
77 |
|
|
|
78 |
|
|
sc_signal<bool> history_memory_write;
|
79 |
|
|
sc_signal<sc_uint<LOG2_HISTORY_MEMORY_SIZE> > history_memory_write_address;
|
80 |
|
|
sc_signal<sc_bv<32> > history_memory_write_data;
|
81 |
|
|
sc_signal<sc_uint<LOG2_HISTORY_MEMORY_SIZE> > history_memory_read_address;
|
82 |
|
|
sc_signal<sc_bv<32> > history_memory_output;
|
83 |
|
|
|
84 |
|
|
////////////////////////////////////////////////////////////////
|
85 |
|
|
////////////////////////////////////////////////////////////////
|
86 |
|
|
// DUT connections
|
87 |
|
|
////////////////////////////////////////////////////////////////
|
88 |
|
|
////////////////////////////////////////////////////////////////
|
89 |
|
|
|
90 |
|
|
//Signals used to link the design to the testbench
|
91 |
|
|
dut->clk(clk);
|
92 |
|
|
dut->history_packet(history_packet);
|
93 |
|
|
dut->history_playback_done(history_playback_done);
|
94 |
|
|
dut->begin_history_playback(begin_history_playback);
|
95 |
|
|
dut->stop_history_playback(stop_history_playback);
|
96 |
|
|
dut->history_playback_ready(history_playback_ready);
|
97 |
|
|
dut->consume_history(consume_history);
|
98 |
|
|
dut->room_available_in_history(room_available_in_history);
|
99 |
|
|
dut->add_to_history(add_to_history);
|
100 |
|
|
|
101 |
|
|
dut->new_history_entry(new_history_entry);
|
102 |
|
|
dut->new_history_entry_size_m1(new_history_entry_size_m1);
|
103 |
|
|
dut->fc_dword_lk(fc_dword_lk);
|
104 |
|
|
dut->nop_received(nop_received);
|
105 |
|
|
dut->ack_value(ack_value);
|
106 |
|
|
dut->resetx(resetx);
|
107 |
|
|
|
108 |
|
|
dut->history_memory_write(history_memory_write);
|
109 |
|
|
dut->history_memory_write_address(history_memory_write_address);
|
110 |
|
|
dut->history_memory_write_data(history_memory_write_data);
|
111 |
|
|
dut->history_memory_read_address(history_memory_read_address);
|
112 |
|
|
dut->history_memory_output(history_memory_output);
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
////////////////////////////////////////////////////////////////
|
116 |
|
|
////////////////////////////////////////////////////////////////
|
117 |
|
|
// TB connections
|
118 |
|
|
////////////////////////////////////////////////////////////////
|
119 |
|
|
////////////////////////////////////////////////////////////////
|
120 |
|
|
|
121 |
|
|
tb->clk(clk);
|
122 |
|
|
tb->history_packet(history_packet);
|
123 |
|
|
tb->history_playback_done(history_playback_done);
|
124 |
|
|
tb->begin_history_playback(begin_history_playback);
|
125 |
|
|
tb->history_playback_ready(history_playback_ready);
|
126 |
|
|
tb->consume_history(consume_history);
|
127 |
|
|
tb->room_available_in_history(room_available_in_history);
|
128 |
|
|
tb->add_to_history(add_to_history);
|
129 |
|
|
|
130 |
|
|
tb->new_history_entry(new_history_entry);
|
131 |
|
|
tb->new_history_entry_size_m1(new_history_entry_size_m1);
|
132 |
|
|
tb->fc_dword_lk(fc_dword_lk);
|
133 |
|
|
tb->nop_received(nop_received);
|
134 |
|
|
tb->ack_value(ack_value);
|
135 |
|
|
tb->resetx(resetx);
|
136 |
|
|
|
137 |
|
|
tb->history_memory_write(history_memory_write);
|
138 |
|
|
tb->history_memory_write_address(history_memory_write_address);
|
139 |
|
|
tb->history_memory_write_data(history_memory_write_data);
|
140 |
|
|
tb->history_memory_read_address(history_memory_read_address);
|
141 |
|
|
tb->history_memory_output(history_memory_output);
|
142 |
|
|
|
143 |
|
|
////////////////////////////////////////////////////////////////
|
144 |
|
|
////////////////////////////////////////////////////////////////
|
145 |
|
|
// Trace signals
|
146 |
|
|
////////////////////////////////////////////////////////////////
|
147 |
|
|
////////////////////////////////////////////////////////////////
|
148 |
|
|
|
149 |
|
|
sc_trace_file *tf = sc_create_vcd_trace_file("sim_history_buffer_l3");
|
150 |
|
|
|
151 |
|
|
sc_trace(tf,clk,"clk");
|
152 |
|
|
sc_trace(tf,history_packet,"history_packet");
|
153 |
|
|
sc_trace(tf,history_playback_done,"history_playback_done");
|
154 |
|
|
sc_trace(tf,begin_history_playback,"begin_history_playback");
|
155 |
|
|
sc_trace(tf,history_playback_ready,"history_playback_ready");
|
156 |
|
|
|
157 |
|
|
sc_trace(tf,consume_history,"consume_history");
|
158 |
|
|
sc_trace(tf,room_available_in_history,"room_available_in_history");
|
159 |
|
|
sc_trace(tf,add_to_history,"add_to_history");
|
160 |
|
|
|
161 |
|
|
sc_trace(tf,new_history_entry,"new_history_entry");
|
162 |
|
|
sc_trace(tf,new_history_entry_size_m1,"new_history_entry_size_m1");
|
163 |
|
|
sc_trace(tf,fc_dword_lk,"fc_dword_lk");
|
164 |
|
|
sc_trace(tf,nop_received,"nop_received");
|
165 |
|
|
sc_trace(tf,ack_value,"ack_value");
|
166 |
|
|
sc_trace(tf,resetx,"resetx");
|
167 |
|
|
|
168 |
|
|
sc_trace(tf,history_memory_write,"history_memory_write");
|
169 |
|
|
sc_trace(tf,history_memory_write_address,"history_memory_write_address");
|
170 |
|
|
sc_trace(tf,history_memory_write_data,"history_memory_write_data");
|
171 |
|
|
sc_trace(tf,history_memory_read_address,"history_memory_read_address");
|
172 |
|
|
sc_trace(tf,history_memory_output,"history_memory_output");
|
173 |
|
|
|
174 |
|
|
sc_trace(tf,dut->idle_read_pointer,"DUT.idle_read_pointer");
|
175 |
|
|
sc_trace(tf,dut->write_pointer,"DUT.write_pointer");
|
176 |
|
|
|
177 |
|
|
//------------------------------------------
|
178 |
|
|
// Start simulation
|
179 |
|
|
//------------------------------------------
|
180 |
|
|
cout << "Start of History Buffer simulation" << endl;
|
181 |
|
|
sc_start(400);
|
182 |
|
|
|
183 |
|
|
|
184 |
|
|
sc_close_vcd_trace_file(tf);
|
185 |
|
|
cout << "End of simulation" << endl;
|
186 |
|
|
|
187 |
|
|
delete dut;
|
188 |
|
|
delete tb;
|
189 |
|
|
return 0;
|
190 |
|
|
}
|
191 |
|
|
|