forked from YosysHQ/riscv-formal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dmemcheck.sv
71 lines (59 loc) · 1.57 KB
/
dmemcheck.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
module testbench (
input clk,
input mem_ready,
output mem_valid,
output mem_instr,
output [31:0] mem_addr,
output [31:0] mem_wdata,
output [3:0] mem_wstrb,
input [31:0] mem_rdata
);
reg resetn = 0;
wire trap;
always @(posedge clk)
resetn <= 1;
`RVFI_WIRES
wire [31:0] dmem_addr;
reg [31:0] dmem_data;
rvfi_dmem_check checker_inst (
.clock (clk ),
.reset (!resetn ),
.enable (1'b1 ),
.dmem_addr (dmem_addr),
`RVFI_CONN
);
always @(posedge clk) begin
if (resetn && mem_valid && mem_ready && mem_addr == dmem_addr) begin
if (mem_wstrb[0]) dmem_data[ 7: 0] <= mem_wdata[ 7: 0];
if (mem_wstrb[1]) dmem_data[15: 8] <= mem_wdata[15: 8];
if (mem_wstrb[2]) dmem_data[23:16] <= mem_wdata[23:16];
if (mem_wstrb[3]) dmem_data[31:24] <= mem_wdata[31:24];
end
end
always @* begin
if (resetn && mem_valid && mem_ready && mem_addr == dmem_addr && !mem_wstrb)
assume(dmem_data == mem_rdata);
end
picorv32 #(
.REGS_INIT_ZERO(1),
.COMPRESSED_ISA(1),
.BARREL_SHIFTER(1)
) uut (
.clk (clk ),
.resetn (resetn ),
.trap (trap ),
.mem_valid (mem_valid ),
.mem_instr (mem_instr ),
.mem_ready (mem_ready ),
.mem_addr (mem_addr ),
.mem_wdata (mem_wdata ),
.mem_wstrb (mem_wstrb ),
.mem_rdata (mem_rdata ),
`RVFI_CONN
);
reg [4:0] mem_wait = 0;
always @(posedge clk) begin
mem_wait <= {mem_wait, mem_valid && !mem_ready};
// restrict(~mem_wait && !trap);
end
endmodule