-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtop_level_tb.v
65 lines (59 loc) · 1.71 KB
/
top_level_tb.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
///////////////////////////////////////////////////////////////////////////////////////////////////
//
// MODULE: top_level_tb
// DESCRIPTION: tset bench for 8*8 dadda
// IO SIGNALS: ---
// AUTHOR: YOUR NAME (),
// ORGANIZATION:
// VERSION: 1.0
// CREATED: Sunday 11 November 2018 04:05:03 IST
// REVISION: ---
///////////////////////////////////////////////////////////////////////////////////////////////////
`timescale 1ps/100fs
module top_level_tb(); //testbench doesnt have any inputs or outputs
reg [7:0] A; //inputs are takens as reqisters ( they need to hold the value)
reg [7:0] B;
reg[15:0] M;
wire [16:0] RES; //outputs are takens as wires in tb .
reg[7:0] ain_array[0:250];
reg[7:0] bin_array[0:250];
reg[16:0] res_array[0:250];
reg[15:0] M_array[0:250];
top_level dut(.*); //since all the inputs to the dut are the wires of same name
integer i;
initial begin
$dumpfile("top_level_tb.vcd");
$dumpvars(0,top_level_tb); //first argument is the level of debugging
//level 0 will log all the variable even in
$monitor(A,B,M,RES);
$readmemb("ain.txt",ain_array);
$readmemb("bin.txt",bin_array);
$readmemb("res.txt",res_array);
$readmemb("m.txt",M_array);
//sub modules
//whereas level 1 will log only the ones in the top module
A = 8'h0;
B = 8'h0;
M = 16'h0;
#2000;
A = 8'hff;
B = 8'haa;
#2000;
B = 8'hff;
#200;
#1000;
M = 16'h02;
$display("starting....");
for(i = 0;i<250;i = i+1)begin
A = ain_array[i];
B = bin_array[i];
M = M_array[i];
#1000;
$display("A = %h, B = %h, M = %h , RES = %h",A,B,M,RES);
if(RES != res_array[i])
$display("error");
else
$display("test passed");
end
end
endmodule