-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests directory with additional tests
- Loading branch information
1 parent
7bae1b8
commit 8c5b65c
Showing
21 changed files
with
3,453 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/both_ex*/ | ||
/cover*/ | ||
/demo*/ | ||
/memory*/ | ||
/mixed*/ | ||
/preunsat*/ | ||
/prv32fmcmp*/ | ||
/redxor*/ | ||
/stopfirst*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
SBY_FILES=$(wildcard *.sby) | ||
SBY_TESTS=$(addprefix test_,$(SBY_FILES:.sby=)) | ||
|
||
.PHONY: test $(SBY_TESTS) | ||
|
||
test: $(SBY_TESTS) | ||
|
||
test_%: %.sby | ||
python3 ../sbysrc/sby.py -f $< |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[tasks] | ||
btormc bmc | ||
pono bmc | ||
cover | ||
|
||
[options] | ||
bmc: mode bmc | ||
cover: mode cover | ||
depth 5 | ||
expect pass | ||
|
||
[engines] | ||
btormc: btor btormc | ||
pono: btor pono | ||
cover: btor btormc | ||
|
||
[script] | ||
read_verilog -sv both_ex.v | ||
prep -top test | ||
|
||
[files] | ||
both_ex.v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module test( | ||
input clk, | ||
input [7:0] data | ||
); | ||
|
||
localparam MAX_COUNT = 8'd111; | ||
reg [7:0] count = 8'd0; | ||
reg [7:0] margin = MAX_COUNT; | ||
|
||
always @ (posedge clk) begin | ||
if (data > margin) begin | ||
count <= 8'd0; | ||
margin <= MAX_COUNT; | ||
end else begin | ||
count <= count + data; | ||
margin <= margin - data; | ||
end | ||
|
||
assume (data < 8'd40); | ||
assert (count <= MAX_COUNT); | ||
cover (count == 8'd42); | ||
cover (count == 8'd111); | ||
end | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[options] | ||
mode cover | ||
expect pass | ||
|
||
[engines] | ||
btor btormc | ||
|
||
[script] | ||
read -formal cover.sv | ||
prep -top top | ||
|
||
[files] | ||
cover.sv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module top ( | ||
input clk, | ||
input [7:0] din | ||
); | ||
reg [31:0] state = 0; | ||
|
||
always @(posedge clk) begin | ||
state <= ((state << 5) + state) ^ din; | ||
end | ||
|
||
`ifdef FORMAL | ||
always @(posedge clk) begin | ||
cover (state == 'd 12345678); | ||
cover (state == 'h 12345678); | ||
end | ||
`endif | ||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[tasks] | ||
btormc | ||
pono | ||
|
||
[options] | ||
mode bmc | ||
depth 100 | ||
expect fail | ||
|
||
[engines] | ||
btormc: btor btormc | ||
pono: btor pono | ||
|
||
[script] | ||
read -formal demo.sv | ||
prep -top demo | ||
|
||
[files] | ||
demo.sv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module demo ( | ||
input clk, | ||
output reg [5:0] counter | ||
); | ||
initial counter = 0; | ||
|
||
always @(posedge clk) begin | ||
if (counter == 15) | ||
counter <= 0; | ||
else | ||
counter <= counter + 1; | ||
end | ||
|
||
`ifdef FORMAL | ||
always @(posedge clk) begin | ||
assert (counter < 7); | ||
end | ||
`endif | ||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[tasks] | ||
btormc | ||
pono | ||
|
||
[options] | ||
mode bmc | ||
depth 10 | ||
expect fail | ||
|
||
[engines] | ||
btormc: btor btormc | ||
pono: btor pono | ||
|
||
[script] | ||
read -formal memory.sv | ||
prep -top testbench | ||
|
||
[files] | ||
memory.sv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
module testbench ( | ||
input clk, wen, | ||
input [9:0] addr, | ||
input [7:0] wdata, | ||
output [7:0] rdata | ||
); | ||
memory uut ( | ||
.clk (clk ), | ||
.wen (wen ), | ||
.addr (addr ), | ||
.wdata(wdata), | ||
.rdata(rdata) | ||
); | ||
|
||
(* anyconst *) reg [9:0] test_addr; | ||
reg test_data_valid = 0; | ||
reg [7:0] test_data; | ||
|
||
always @(posedge clk) begin | ||
if (addr == test_addr) begin | ||
if (wen) begin | ||
test_data <= wdata; | ||
test_data_valid <= 1; | ||
end | ||
if (test_data_valid) begin | ||
assert(test_data == rdata); | ||
end | ||
end | ||
end | ||
endmodule | ||
|
||
module memory ( | ||
input clk, wen, | ||
input [9:0] addr, | ||
input [7:0] wdata, | ||
output [7:0] rdata | ||
); | ||
reg [7:0] bank0 [0:255]; | ||
reg [7:0] bank1 [0:255]; | ||
reg [7:0] bank2 [0:255]; | ||
reg [7:0] bank3 [0:255]; | ||
|
||
wire [1:0] mem_sel = addr[9:8]; | ||
wire [7:0] mem_addr = addr[7:0]; | ||
|
||
always @(posedge clk) begin | ||
case (mem_sel) | ||
0: if (wen) bank0[mem_addr] <= wdata; | ||
1: if (wen) bank1[mem_addr] <= wdata; | ||
2: if (wen) bank1[mem_addr] <= wdata; // BUG: Should assign to bank2 | ||
3: if (wen) bank3[mem_addr] <= wdata; | ||
endcase | ||
end | ||
|
||
assign rdata = | ||
mem_sel == 0 ? bank0[mem_addr] : | ||
mem_sel == 1 ? bank1[mem_addr] : | ||
mem_sel == 2 ? bank2[mem_addr] : | ||
mem_sel == 3 ? bank3[mem_addr] : 'bx; | ||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[tasks] | ||
cover | ||
btormc bmc | ||
pono bmc | ||
|
||
[options] | ||
cover: mode cover | ||
bmc: mode bmc | ||
bmc: depth 1 | ||
|
||
[engines] | ||
cover: btor btormc | ||
btormc: btor btormc | ||
pono: btor pono | ||
|
||
[script] | ||
read -formal mixed.v | ||
prep -top test | ||
|
||
[files] | ||
mixed.v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module test (input CP, CN, CX, input A, B, output reg XP, XN, YP, YN); | ||
always @* begin | ||
assume (A || B); | ||
assume (!A || !B); | ||
assert (A != B); | ||
cover (A); | ||
cover (B); | ||
end | ||
always @(posedge CP) | ||
XP <= A; | ||
always @(negedge CN) | ||
XN <= B; | ||
always @(posedge CX) | ||
YP <= A; | ||
always @(negedge CX) | ||
YN <= B; | ||
endmodule |
Oops, something went wrong.