Seq-2 - Sequential Circuits Part 2 State machines with...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Jon Turner/David M. Zar State machines with registers Debouncing input signals Knob interface for S3 board Sequential Circuits – Part 2
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 State Machines with Registers State machines are often used as controllers for more complex circuits containing registers » controls register values » state changes may depend on register values Useful to specify using high level state diagrams » general conditions on transitions » actions performed on registers Example – pulse counter » input N loaded on first tick » event output goes high after N pulses state machine cnt N load –1 =0 reset dIn event clk reset N dIn 0 1 0 1 event 2 0
Background image of page 2
3 High Level State diagram state machine cnt N load –1 =0 reset dIn event End of pulse detected by down-transition on dIn » but if dIn starts high, ignore first down-transition States » reset – enter on reset high and stay until drops » start1 – enter if dIn=1 after reset » prev0, prev1 – track previous dIn value event<=1 if cnt=0, else 0 prev0 prev1 dIn=1/. .. dIn=0/ if cnt/=0, cnt<=cnt–1 reset start1 dIn=1/cnt<=N dIn=0 /cnt<=N dIn=1/. .. dIn=0/. .. dIn=1/. .. dIn=0/. ..
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
entity pulseCount is . .. end pulseCount; architecture arch of pulseCount is type stateType is (resetState, start1, prev0, prev1); signal state: stateType; signal cnt: unsigned(3 downto 0); begin process (clk) begin if rising_edge(clk) then if reset = '1' then state <= resetState; cnt <= (others > ‘1’); else case state is when resetState => cnt <= N; if dIn = '0' then state <= prev0; else state <= start1; end if; when start1 => if dIn = '0' then state <= prev0; end if; when prev0 => if dIn = '1' then state <= prev1; end if; when prev1 => if dIn = '0' then state <= prev0; if cnt /= 0 then cnt <= cnt - 1; end if; end if; when others => end case; end if; end if; end process; event <= '1' when cnt = 0 else '0'; end arch; event<=1 if cnt=0, else 0 prev0 prev1 dIn=1/. .. dIn=0/
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 16

Seq-2 - Sequential Circuits Part 2 State machines with...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online