-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestBench.v
executable file
·108 lines (98 loc) · 2.93 KB
/
testBench.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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
`timescale 1ns / 1ps
`define VERIFICATION
module testBench;
reg clk = 0;
reg rstb = 0;
wire [7 : 0] symbol;
wire [7 : 0] noisySymbol;
reg pass = 1;
reg valid = 0;
reg wnr = 0;
always #5 clk = ~clk;
always @(posedge clk or negedge rstb) begin
if (~rstb) begin
valid <= 1'b0;
wnr <= 1'b0;
end
else begin
valid <= 1'b1;
wnr <= 1'b1;
end
end
initial begin
rstb = 1'b0;
repeat (5) @(posedge clk);
rstb <= 1'b1;
repeat (1000) @(posedge clk);
//Check all the addresses
if (!((testBench.sdm.memoryCells[0].memcell.softLocation[7:0] == 'hff) ||
(testBench.sdm.memoryCells[1].memcell.softLocation[7:0] == 'hff) ||
(testBench.sdm.memoryCells[2].memcell.softLocation[7:0] == 'hff) ||
(testBench.sdm.memoryCells[3].memcell.softLocation[7:0] == 'hff)
)) begin
pass = 0;
end
if (!((testBench.sdm.memoryCells[0].memcell.softLocation[7:0] == 'hf0) ||
(testBench.sdm.memoryCells[1].memcell.softLocation[7:0] == 'hf0) ||
(testBench.sdm.memoryCells[2].memcell.softLocation[7:0] == 'hf0) ||
(testBench.sdm.memoryCells[3].memcell.softLocation[7:0] == 'hf0)
)) begin
pass = 0;
end
if (!((testBench.sdm.memoryCells[0].memcell.softLocation[7:0] == 'haa) ||
(testBench.sdm.memoryCells[1].memcell.softLocation[7:0] == 'haa) ||
(testBench.sdm.memoryCells[2].memcell.softLocation[7:0] == 'haa) ||
(testBench.sdm.memoryCells[3].memcell.softLocation[7:0] == 'haa)
)) begin
pass = 0;
end
if (!((testBench.sdm.memoryCells[0].memcell.softLocation[7:0] == 'hcc) ||
(testBench.sdm.memoryCells[1].memcell.softLocation[7:0] == 'hcc) ||
(testBench.sdm.memoryCells[2].memcell.softLocation[7:0] == 'hcc) ||
(testBench.sdm.memoryCells[3].memcell.softLocation[7:0] == 'hcc)
)) begin
pass = 0;
end
if (!((testBench.sdm.memoryCells[3].memcell.strength[7:0] == 'hff) &&
(testBench.sdm.memoryCells[2].memcell.strength[7:0] == 'hff) &&
(testBench.sdm.memoryCells[1].memcell.strength[7:0] == 'hff) &&
(testBench.sdm.memoryCells[0].memcell.strength[7:0] == 'hff)
)) pass = 0;
if (pass) $display("Test Passed Simulation!!!");
else $display("Test Failed Simulation!!!");
$finish;
end
symbolGenerator symbolG (
.clk(clk),
.rstb(rstb),
.symbol(symbol)
);
channel chan (
.clk(clk),
.rstb(rstb),
.symbol(symbol),
.noisySymbol(noisySymbol)
);
trainedSDM #(
.BIT_WIDTH(8),
.BIT_WIDTH_SIZE(3),
.THRESHOLD(2),
.HYSTERISIS(4),
.COUNTER_WIDTH(8),
.NUM_LOCATIONS(4),
.NUM_LOCATIONS_BIT_SIZE(2)
) sdm (
.clk(clk),
.rstb(rstb),
.address(noisySymbol),
.valid(valid),
.wnr(wnr),
.readValid(readValid),
.readSuccess(readSuccess),
.data(data)
);
initial begin
//$shm_open("waves.shm");
//$shm_probe("AC");
end
endmodule