3
0
Fork 0
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:
Clifford Wolf 2018-06-29 18:21:38 +02:00
parent 45a11da8ea
commit 2fa29974dd
7 changed files with 22 additions and 14 deletions

View 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