1 |
6 |
qaztronic |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// Copyright (C) 2009 Authors and OPENCORES.ORG ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// This source file may be used and distributed without ////
|
6 |
|
|
//// restriction provided that this copyright statement is not ////
|
7 |
|
|
//// removed from the file and that any derivative work contains ////
|
8 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
9 |
|
|
//// ////
|
10 |
|
|
//// This source file is free software; you can redistribute it ////
|
11 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
12 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
13 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
14 |
|
|
//// later version. ////
|
15 |
|
|
//// ////
|
16 |
|
|
//// This source is distributed in the hope that it will be ////
|
17 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
18 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
19 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
20 |
|
|
//// details. ////
|
21 |
|
|
//// ////
|
22 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
23 |
|
|
//// Public License along with this source; if not, download it ////
|
24 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
25 |
|
|
//// ////
|
26 |
|
|
//////////////////////////////////////////////////////////////////////
|
27 |
|
|
|
28 |
|
|
`timescale 1ns/10ps
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
module tb_top();
|
32 |
|
|
|
33 |
|
|
parameter CLK_PERIOD = 10;
|
34 |
|
|
|
35 |
|
|
reg tb_clk, tb_rst;
|
36 |
|
|
|
37 |
|
|
initial
|
38 |
|
|
begin
|
39 |
|
|
tb_clk <= 1'b1;
|
40 |
|
|
tb_rst <= 1'b1;
|
41 |
|
|
|
42 |
|
|
#(CLK_PERIOD); #(CLK_PERIOD/3);
|
43 |
|
|
tb_rst = 1'b0;
|
44 |
|
|
|
45 |
|
|
end
|
46 |
|
|
|
47 |
|
|
always
|
48 |
|
|
#(CLK_PERIOD/2) tb_clk = ~tb_clk;
|
49 |
|
|
|
50 |
|
|
// --------------------------------------------------------------------
|
51 |
|
|
// tb_dut
|
52 |
|
|
tb_dut dut( tb_clk, tb_rst );
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
// --------------------------------------------------------------------
|
56 |
|
|
// insert test below
|
57 |
|
|
|
58 |
|
|
initial
|
59 |
|
|
begin
|
60 |
|
|
|
61 |
|
|
wait( ~tb_rst );
|
62 |
|
|
|
63 |
|
|
repeat(2) @(posedge tb_clk);
|
64 |
|
|
|
65 |
|
|
// 8 bit if
|
66 |
|
|
$display("\n^^^- testing 8 bit interface\n");
|
67 |
|
|
|
68 |
|
|
dut.wbm.wb_cmp(0, 0, 32'h6000_0000, 32'h3322_1100);
|
69 |
|
|
dut.wbm.wb_cmp(0, 0, 32'h6000_0004, 32'h7766_5544);
|
70 |
|
|
dut.wbm.wb_cmp(0, 0, 32'h6000_0008, 32'hbbaa_9988);
|
71 |
|
|
dut.wbm.wb_cmp(0, 0, 32'h6000_000c, 32'hffee_ddcc);
|
72 |
|
|
|
73 |
|
|
dut.wbm.wb_write(0, 0, 32'h6000_0010, 32'habba_beef);
|
74 |
|
|
dut.wbm.wb_write(0, 0, 32'h6000_0014, 32'h1a2b_3c4d);
|
75 |
|
|
dut.wbm.wb_write(0, 0, 32'h6000_0018, 32'hcafe_1a7e);
|
76 |
|
|
dut.wbm.wb_write(0, 0, 32'h6000_001c, 32'h5a5a_0f0f);
|
77 |
|
|
|
78 |
|
|
dut.wbm.wb_cmp(0, 0, 32'h6000_0010, 32'habba_beef);
|
79 |
|
|
dut.wbm.wb_cmp(0, 0, 32'h6000_0014, 32'h1a2b_3c4d);
|
80 |
|
|
dut.wbm.wb_cmp(0, 0, 32'h6000_0018, 32'hcafe_1a7e);
|
81 |
|
|
dut.wbm.wb_cmp(0, 0, 32'h6000_001c, 32'h5a5a_0f0f);
|
82 |
|
|
|
83 |
|
|
dut.wbm.wb_write_sel(0, 0, 4'b0001, 32'h6000_0010, 32'hxxxx_xx00);
|
84 |
|
|
dut.wbm.wb_write_sel(0, 0, 4'b0010, 32'h6000_0014, 32'hxxxx_11xx);
|
85 |
|
|
dut.wbm.wb_write_sel(0, 0, 4'b0100, 32'h6000_0018, 32'hxx22_xxxx);
|
86 |
|
|
dut.wbm.wb_write_sel(0, 0, 4'b1000, 32'h6000_001c, 32'h33xx_xxxx);
|
87 |
|
|
|
88 |
|
|
dut.wbm.wb_cmp_sel(0, 0, 4'b0001, 32'h6000_0010, 32'hxxxx_xx00);
|
89 |
|
|
dut.wbm.wb_cmp_sel(0, 0, 4'b0010, 32'h6000_0014, 32'hxxxx_11xx);
|
90 |
|
|
dut.wbm.wb_cmp_sel(0, 0, 4'b0100, 32'h6000_0018, 32'hxx22_xxxx);
|
91 |
|
|
dut.wbm.wb_cmp_sel(0, 0, 4'b1000, 32'h6000_001c, 32'h33xx_xxxx);
|
92 |
|
|
|
93 |
|
|
dut.wbm.wb_write_sel(0, 0, 4'b0011, 32'h6000_0000, 32'hxxxx_0ab1);
|
94 |
|
|
dut.wbm.wb_write_sel(0, 0, 4'b1100, 32'h6000_0004, 32'h2cd3_xxxx);
|
95 |
|
|
dut.wbm.wb_write_sel(0, 0, 4'b0011, 32'h6000_0008, 32'hxxxx_4ef5);
|
96 |
|
|
dut.wbm.wb_write_sel(0, 0, 4'b1100, 32'h6000_000c, 32'h0f0f_xxxx);
|
97 |
|
|
|
98 |
|
|
dut.wbm.wb_cmp_sel(0, 0, 4'b0011, 32'h6000_0000, 32'hxxxx_0ab1);
|
99 |
|
|
dut.wbm.wb_cmp_sel(0, 0, 4'b1100, 32'h6000_0004, 32'h2cd3_xxxx);
|
100 |
|
|
dut.wbm.wb_cmp_sel(0, 0, 4'b0011, 32'h6000_0008, 32'hxxxx_4ef5);
|
101 |
|
|
dut.wbm.wb_cmp_sel(0, 0, 4'b1100, 32'h6000_000c, 32'h0f0f_xxxx);
|
102 |
|
|
|
103 |
|
|
// 16 bit if
|
104 |
|
|
$display("\n^^^- testing 16 bit interface\n");
|
105 |
|
|
|
106 |
|
|
dut.wbm.wb_cmp(0, 0, 32'ha000_0000, 32'h3322_1100);
|
107 |
|
|
dut.wbm.wb_cmp(0, 0, 32'ha000_0004, 32'h7766_5544);
|
108 |
|
|
dut.wbm.wb_cmp(0, 0, 32'ha000_0008, 32'hbbaa_9988);
|
109 |
|
|
dut.wbm.wb_cmp(0, 0, 32'ha000_000c, 32'hffee_ddcc);
|
110 |
|
|
|
111 |
|
|
dut.wbm.wb_write(0, 0, 32'ha000_0010, 32'habba_beef);
|
112 |
|
|
dut.wbm.wb_write(0, 0, 32'ha000_0014, 32'h1a2b_3c4d);
|
113 |
|
|
dut.wbm.wb_write(0, 0, 32'ha000_0018, 32'hcafe_1a7e);
|
114 |
|
|
dut.wbm.wb_write(0, 0, 32'ha000_001c, 32'h5a5a_0f0f);
|
115 |
|
|
|
116 |
|
|
dut.wbm.wb_cmp(0, 0, 32'ha000_0010, 32'habba_beef);
|
117 |
|
|
dut.wbm.wb_cmp(0, 0, 32'ha000_0014, 32'h1a2b_3c4d);
|
118 |
|
|
dut.wbm.wb_cmp(0, 0, 32'ha000_0018, 32'hcafe_1a7e);
|
119 |
|
|
dut.wbm.wb_cmp(0, 0, 32'ha000_001c, 32'h5a5a_0f0f);
|
120 |
|
|
|
121 |
|
|
dut.wbm.wb_write_sel(0, 0, 4'b0011, 32'ha000_0000, 32'hxxxx_0ab1);
|
122 |
|
|
dut.wbm.wb_write_sel(0, 0, 4'b1100, 32'ha000_0004, 32'h2cd3_xxxx);
|
123 |
|
|
dut.wbm.wb_write_sel(0, 0, 4'b0011, 32'ha000_0008, 32'hxxxx_4ef5);
|
124 |
|
|
dut.wbm.wb_write_sel(0, 0, 4'b1100, 32'ha000_000c, 32'h0f0f_xxxx);
|
125 |
|
|
|
126 |
|
|
dut.wbm.wb_cmp_sel(0, 0, 4'b0011, 32'ha000_0000, 32'hxxxx_0ab1);
|
127 |
|
|
dut.wbm.wb_cmp_sel(0, 0, 4'b1100, 32'ha000_0004, 32'h2cd3_xxxx);
|
128 |
|
|
dut.wbm.wb_cmp_sel(0, 0, 4'b0011, 32'ha000_0008, 32'hxxxx_4ef5);
|
129 |
|
|
dut.wbm.wb_cmp_sel(0, 0, 4'b1100, 32'ha000_000c, 32'h0f0f_xxxx);
|
130 |
|
|
|
131 |
|
|
dut.wbm.wb_write_sel(0, 0, 4'b0001, 32'h0000_0010, 32'hxxxx_xx00);
|
132 |
|
|
dut.wbm.wb_write_sel(0, 0, 4'b0010, 32'h0000_0014, 32'hxxxx_11xx);
|
133 |
|
|
dut.wbm.wb_write_sel(0, 0, 4'b0100, 32'h0000_0018, 32'hxx22_xxxx);
|
134 |
|
|
dut.wbm.wb_write_sel(0, 0, 4'b1000, 32'h0000_001c, 32'h33xx_xxxx);
|
135 |
|
|
|
136 |
|
|
dut.wbm.wb_cmp_sel(0, 0, 4'b0001, 32'h0000_0010, 32'hxxxx_xx00);
|
137 |
|
|
dut.wbm.wb_cmp_sel(0, 0, 4'b0010, 32'h0000_0014, 32'hxxxx_11xx);
|
138 |
|
|
dut.wbm.wb_cmp_sel(0, 0, 4'b0100, 32'h0000_0018, 32'hxx22_xxxx);
|
139 |
|
|
dut.wbm.wb_cmp_sel(0, 0, 4'b1000, 32'h0000_001c, 32'h33xx_xxxx);
|
140 |
|
|
|
141 |
|
|
// do illegal byte boundary access
|
142 |
|
|
$display("\n^^^- testing illegal byte boundary access\n");
|
143 |
|
|
dut.wbm.wb_write_sel(0, 0, 4'b0110, 32'ha000_0020, 32'hxxba_adxx);
|
144 |
|
|
|
145 |
|
|
repeat(2) @(posedge tb_clk);
|
146 |
|
|
|
147 |
|
|
$display("\n^^^---------------------------------\n");
|
148 |
|
|
$display("^^^- Testbench done. %t.\n", $time);
|
149 |
|
|
|
150 |
|
|
$stop();
|
151 |
|
|
|
152 |
|
|
end
|
153 |
|
|
|
154 |
|
|
endmodule
|
155 |
|
|
|