-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathasync_ram_tb.v
89 lines (71 loc) · 1.23 KB
/
async_ram_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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
module async_ram_tb ();
parameter ADDR_WIDTH = 4,
DATA_WIDTH = 8,
DEPTH = 16;
reg cs,we,rst;
reg [ADDR_WIDTH-1:0] addr;
wire [DATA_WIDTH-1:0] data;
reg [DATA_WIDTH-1:0] tempdata;
async_ram_16X8 dut(cs,we,addr,data);
assign data =(we)? tempdata:8'hzz;
task delay(input integer i); //delay task
begin
#i;
end
endtask
task reset(); //reset task
begin
rst=1'b1;
delay(20); rst=1'b0;
end
endtask
/*
task clock(); //clocking task
begin
clk=1'b1;
forever delay(10); clk=~clk;
end
endtask */
task write(
input [DATA_WIDTH-1:0] wdata,
input [ADDR_WIDTH-1:0] waddr); //write task
begin
delay(20);
we=1'b1;
delay(5);
addr= waddr;
tempdata=wdata;
end
endtask
task read(input [ADDR_WIDTH-1:0] raddr ); //read task
begin
delay(20);
we=1'b0;
addr=raddr;
end
endtask
/*
initial begin
clock();
end
*/
initial begin
cs=1'b1;
reset();
delay(10);
we=1'b1;
delay(10);
repeat(8) begin delay(10); write({$random},{$random}); end
delay(20);
we=0;
delay(10);
repeat(6) read({$random});
delay(20);
we=1'b1;
write({$random},{$random});
delay(10);
reset();
delay(10);
$finish;
end
endmodule