-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfsm1.v
31 lines (26 loc) · 813 Bytes
/
fsm1.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
module top_module(
input clk,
input areset, // Asynchronous reset to state B
input in,
output out);//
parameter A=0, B=1;
reg state, next_state;
always @(*) begin // This is a combinational always block
// State transition logic
case (state)
A: begin out = 0; next_state = in ? A : B; end
B: begin out = 1; next_state = in ? B : A; end
endcase
end
always @(posedge clk, posedge areset) begin // This is a sequential always block
// State flip-flops with asynchronous reset
if (areset) begin
state <= B;
end
else begin
state <= next_state;
end
end
// Output logic
// assign out = (state == ...);
endmodule