mirror of
https://github.com/YosysHQ/sby.git
synced 2025-07-17 20:16:42 +00:00
Update remaining quickstart examples
Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
parent
45a11da8ea
commit
2fa29974dd
7 changed files with 22 additions and 14 deletions
53
docs/examples/quickstart/prove.sv
Normal file
53
docs/examples/quickstart/prove.sv
Normal file
|
@ -0,0 +1,53 @@
|
|||
module testbench (
|
||||
input clk,
|
||||
input reset,
|
||||
input [7:0] din,
|
||||
output reg [7:0] dout
|
||||
);
|
||||
demo uut (
|
||||
.clk (clk ),
|
||||
.reset(reset),
|
||||
.din (din ),
|
||||
.dout (dout )
|
||||
);
|
||||
|
||||
reg init = 1;
|
||||
always @(posedge clk) begin
|
||||
if (init) assume (reset);
|
||||
if (!reset) assert (!dout[1:0]);
|
||||
init <= 0;
|
||||
end
|
||||
endmodule
|
||||
|
||||
module demo (
|
||||
input clk,
|
||||
input reset,
|
||||
input [7:0] din,
|
||||
output reg [7:0] dout
|
||||
);
|
||||
reg [7:0] buffer;
|
||||
reg [1:0] state;
|
||||
|
||||
always @(posedge clk) begin
|
||||
if (reset) begin
|
||||
dout <= 0;
|
||||
state <= 0;
|
||||
end else
|
||||
case (state)
|
||||
0: begin
|
||||
buffer <= din;
|
||||
state <= 1;
|
||||
end
|
||||
1: begin
|
||||
if (buffer[1:0])
|
||||
buffer <= buffer + 1;
|
||||
else
|
||||
state <= 2;
|
||||
end
|
||||
2: begin
|
||||
dout <= dout + buffer;
|
||||
state <= 0;
|
||||
end
|
||||
endcase
|
||||
end
|
||||
endmodule
|
Loading…
Add table
Add a link
Reference in a new issue