-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtw_vgg_2iq_test.sv
94 lines (86 loc) · 2.2 KB
/
tw_vgg_2iq_test.sv
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
`timescale 1ns / 1ps
module tw_vgg_2iq_test();
`include "input_hex.sv"
// `include "conv1_hex.sv"
// `include "conv1_bn_relu_hex.sv"
// `include "mp1_hex.sv"
// `include "conv2_hex.sv"
// `include "conv2_bn_relu_hex.sv"
// `include "mp2_hex.sv"
// `include "conv3_hex.sv"
// `include "mp3_hex.sv"
// `include "conv4_hex.sv"
// `include "mp4_hex.sv"
// `include "conv5_hex.sv"
// `include "mp5_hex.sv"
// `include "conv6_hex.sv"
// `include "mp6_hex.sv"
// `include "conv7_hex.sv"
// `include "mp7_hex.sv"
// `include "dense_1_hex.sv"
// `include "dense_1_bn_hex.sv"
// `include "dense_2_hex.sv"
// `include "dense_2_bn_hex.sv"
`include "dense_3_hex.sv"
reg clk;
reg rst;
reg vld_in;
reg [2*CH_IN-1:0][BW_IN-1:0] data_in;
wire vld_out;
wire [CH_OUT-1:0][BW_OUT-1:0] data_out;
reg [CNTR_BW_IN-2:0] in_cntr;
localparam CNTR_BW_OUT_TRIM = (( CNTR_BW_OUT - 1 ) < 0 ) ? 0 : CNTR_BW_OUT - 1;
wire [CNTR_BW_OUT:0] out_cntr_sig;
reg [CNTR_BW_OUT:0] out_cntr;
assign out_cntr_sig = (CNTR_BW_OUT == 0) ? 0 : out_cntr[CNTR_BW_OUT_TRIM:0];
wire [CNTR_BW_IN-1:0] in_cntr_a, in_cntr_b;
assign in_cntr_a = in_cntr << 1;
assign in_cntr_b = in_cntr_a + 1;
always @( posedge clk ) begin
data_in[3:2] <= signal_in[in_cntr_a];
data_in[1:0] <= signal_in[in_cntr_b];
if ( rst ) begin
vld_in <= 0;
in_cntr <= 0;
out_cntr <= 0;
end else begin
vld_in <= 1;
in_cntr <= in_cntr + 1;
if ( vld_out ) begin
out_cntr <= out_cntr + 1;
if ( data_out != signal_out[out_cntr_sig] ) begin
$display( "ASSERTION FAILED: data_out = %h, expected_out = %h", data_out, signal_out[out_cntr_sig] );
end else begin
$display( "ASSERTION PASSED: data_out = %h, expected_out = %h", data_out, signal_out[out_cntr_sig]);
end
if ( out_cntr == 2*SIG_LEN_OUT - 1 ) begin
$finish;
end
end
end
end
tw_vgg_2iq
#(
.BW(BW_IN),
.L2_IMG(10),
.R_SHIFT(8),
.CH_OUT(CH_OUT)
) dut (
.clk(clk),
.rst(rst),
.vld_in(vld_in),
.data_in(data_in),
.vld_out(vld_out),
.data_out(data_out)
);
initial begin
clk = 1;
rst = 1;
#10;
rst = 0;
end
always begin
#1;
clk = !clk;
end
endmodule