-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfsm1s.v
37 lines (31 loc) · 967 Bytes
/
fsm1s.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
32
33
34
35
36
37
// Note the Verilog-1995 module declaration syntax here:
module top_module(clk, reset, in, out);
input clk;
input reset; // Synchronous reset to state B
input in;
output out;//
reg out;
// Fill in state name declarations
parameter A=0, B=1;
reg present_state, next_state;
always @(posedge clk) begin
if (reset) begin
// Fill in reset logic
present_state = B;
out = 1;
end else begin
case (present_state)
// Fill in state transition logic
A: next_state = in ? A : B;
B: next_state = in ? B : A;
endcase
// State flip-flops
present_state = next_state;
case (present_state)
// Fill in output logic
A: out = 0;
B: out = 1;
endcase
end
end
endmodule