mirror of
https://github.com/YosysHQ/sby.git
synced 2026-05-23 04:29:45 +00:00
Add deadlock detection example using SymbiYosys
This commit is contained in:
parent
6424d15aae
commit
be18475e70
3 changed files with 164 additions and 0 deletions
47
docs/examples/deadlock_detection/fsm.v
Normal file
47
docs/examples/deadlock_detection/fsm.v
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
module fsm (
|
||||
input clk,
|
||||
input rst,
|
||||
input req,
|
||||
output reg grant
|
||||
);
|
||||
|
||||
parameter IDLE = 2'b00;
|
||||
parameter WAIT = 2'b01;
|
||||
parameter GRANT = 2'b10;
|
||||
|
||||
reg [1:0] state;
|
||||
|
||||
always @(posedge clk) begin
|
||||
if (rst) begin
|
||||
state <= IDLE;
|
||||
grant <= 0;
|
||||
end else begin
|
||||
case (state)
|
||||
IDLE: begin
|
||||
if (req)
|
||||
state <= WAIT;
|
||||
end
|
||||
|
||||
WAIT: begin
|
||||
// Deadlock: no exit from WAIT state
|
||||
state <= WAIT;
|
||||
end
|
||||
|
||||
GRANT: begin
|
||||
grant <= 1;
|
||||
state <= IDLE;
|
||||
end
|
||||
endcase
|
||||
end
|
||||
end
|
||||
|
||||
`ifdef FORMAL
|
||||
|
||||
// Check if GRANT state is reachable
|
||||
always @(posedge clk) begin
|
||||
cover(grant);
|
||||
end
|
||||
|
||||
`endif
|
||||
|
||||
endmodule
|
||||
Loading…
Add table
Add a link
Reference in a new issue