mirror of
https://github.com/YosysHQ/sby.git
synced 2025-04-27 07:25:51 +00:00
Improve documentation
This commit is contained in:
parent
062aae5822
commit
1a574ce24a
6 changed files with 148 additions and 36 deletions
2
docs/examples/quickstart/.gitignore
vendored
Normal file
2
docs/examples/quickstart/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
demo
|
||||
memory
|
13
docs/examples/quickstart/demo.sby
Normal file
13
docs/examples/quickstart/demo.sby
Normal file
|
@ -0,0 +1,13 @@
|
|||
[options]
|
||||
mode bmc
|
||||
depth 100
|
||||
|
||||
[engines]
|
||||
smtbmc
|
||||
|
||||
[script]
|
||||
read_verilog -formal demo.v
|
||||
prep -top demo
|
||||
|
||||
[files]
|
||||
demo.v
|
15
docs/examples/quickstart/demo.v
Normal file
15
docs/examples/quickstart/demo.v
Normal file
|
@ -0,0 +1,15 @@
|
|||
module demo (
|
||||
input clk,
|
||||
output [5:0] counter
|
||||
);
|
||||
reg [5:0] counter = 0;
|
||||
|
||||
always @(posedge clk) begin
|
||||
if (counter == 15)
|
||||
counter <= 0;
|
||||
else
|
||||
counter <= counter + 1;
|
||||
end
|
||||
|
||||
assert property (counter < 32);
|
||||
endmodule
|
13
docs/examples/quickstart/memory.sby
Normal file
13
docs/examples/quickstart/memory.sby
Normal file
|
@ -0,0 +1,13 @@
|
|||
[options]
|
||||
mode bmc
|
||||
depth 10
|
||||
|
||||
[engines]
|
||||
smtbmc -s boolector
|
||||
|
||||
[script]
|
||||
read_verilog -formal memory.v
|
||||
prep -top testbench
|
||||
|
||||
[files]
|
||||
memory.v
|
57
docs/examples/quickstart/memory.v
Normal file
57
docs/examples/quickstart/memory.v
Normal file
|
@ -0,0 +1,57 @@
|
|||
module testbench (
|
||||
input clk, wen,
|
||||
input [15:0] addr,
|
||||
input [7:0] wdata,
|
||||
output [7:0] rdata
|
||||
);
|
||||
memory uut (
|
||||
.clk (clk ),
|
||||
.wen (wen ),
|
||||
.addr (addr ),
|
||||
.wdata(wdata),
|
||||
.rdata(rdata)
|
||||
);
|
||||
|
||||
wire [15:0] test_addr = $anyconst;
|
||||
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 [15:0] addr,
|
||||
input [7:0] wdata,
|
||||
output [7:0] rdata
|
||||
);
|
||||
reg [7:0] bank0 [0:'h3fff];
|
||||
reg [7:0] bank1 [0:'h3fff];
|
||||
reg [7:0] bank2 [0:'h3fff];
|
||||
reg [7:0] bank3 [0:'h3fff];
|
||||
|
||||
always @(posedge clk) begin
|
||||
case (addr[15:14])
|
||||
0: if (wen) bank0[addr[13:0]] <= wdata;
|
||||
1: if (wen) bank1[addr[13:0]] <= wdata;
|
||||
2: if (wen) bank1[addr[13:0]] <= wdata; // BUG: Should assign to bank2
|
||||
3: if (wen) bank3[addr[13:0]] <= wdata;
|
||||
endcase
|
||||
end
|
||||
|
||||
assign rdata =
|
||||
addr[15:14] == 0 ? bank0[addr[13:0]] :
|
||||
addr[15:14] == 1 ? bank1[addr[13:0]] :
|
||||
addr[15:14] == 2 ? bank2[addr[13:0]] :
|
||||
addr[15:14] == 3 ? bank3[addr[13:0]] : 'bx;
|
||||
endmodule
|
Loading…
Add table
Add a link
Reference in a new issue