Documente Academic
Documente Profesional
Documente Cultură
FSMs
structural t t l view i (FF (FFs separate t from f combinational bi ti l logic) l i ) behavioral view (synthesis of sequencers not in this course)
Problem: Pressing button (b) once turns on laser for 3 clock cycles Step 1: Capture the FSM Step 2: Create architecture Step 3: Encode the states Step St 4: 4 Minimize Mi i i l logic i Step 5: Implement & test How about synthesis into FPGA?
x clk
laser
patient
Inputs: b; Outputs: x x=0 00 b Off b x=1 01 On1 x=1 10 On2 x=1 11 On3
a
FSM M outputs 3
FSM M input ts
// state register procedure always @(posedge rst or posedge clk) begin if (rst==1) // initial state currentstate <= S_Off; else currentstate <= < nextstate; end
Moore
zero [0] 1 0 0 one1 [0] 1 two1s [1] 1 0 0/0
Mealy
0/0
1/1
// state variables
always @(state) case ( (state) ) zero: out = 0; one1: out = 0; two1s: out = 1; endcase endmodule
0/0
1/1
highway
Reset
TS / ST FY TS'
TL+C' / ST
(one-hot)
= = = =
specify state bits and codes for each state as well as connections to outputs
module main(HR, HY, HG, FR, FY, FG, reset, C, Clk); output t t HR HR, HY HY, HG HG, FR FR, FY FY, FG FG; input reset, C, Clk; Timer part1(TS, TL, ST, Clk); part2(HR, p ( , HY, , HG, , FR, , FY, , FG, , ST, , TS, , TL, , C, , reset, , Clk); ); FSM endmodule