Chapter 20 - VHDL for Digital System Design-2x2(1)

# Nextstate 0 else nextstate 3 end if when 4 if rb

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: range 2 to 12; 9 signal Sp: bit; 10 begin 11 process(Rb, Reset, Sum, State) 12 begin 13 Sp &lt;= '0'; Roll &lt;= '0'; Win &lt;= '0'; Lose &lt;= '0'; Figure 19-11: Block Diagram for Dice Game 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 case State is when 0 =&gt; if Rb = '1' then Nextstate &lt;= 1; else nextstate &lt;= 0; end if; when 1 =&gt; if Rb = '1' then Roll &lt;= '1'; Nextstate &lt;= 1; elsif Sum = 7 or Sum = 11 then Nextstate &lt;= 2; elsif Sum = 2 or Sum = 3 or Sum =12 then Nextstate &lt;= 3; else Sp &lt;= '1'; Nextstate &lt;= 4; end if; when 2 =&gt; Win &lt;= '1'; if Reset = '1' then Nextstate &lt;= 0; else nextstate &lt;= 2; end if; when 3 =&gt; Lose &lt;= '1'; if Reset = '1' then Nextstate &lt;= 0; else nextstate &lt;= 3; end if; when 4 =&gt; if Rb = '1' then Nextstate &lt;= 5; else nextstate &lt;= 4; end if; Figure 20-12b VHDL Code for Dice Game Controller Figure 20-12a VHDL Code for Dice Game Controller 29 when 5 =&gt; 30 if Rb = '1' then Roll &lt;= '1'; Nextstate &lt;= 5; 31 elsif Sum = Point then Nextstate &lt;= 2; 32 elsif Sum = 7 then Nextstate &lt;= 3; 33 else Nextstate &lt;= 4; 34 end if; 35 end case; 36 end process; 37 process(CLK) 38 begin 39 if CLK'event and CLK = '1' then 40 State &lt;= Nextstate; 41 if Sp = '1' then Point &lt;= Sum; end if; 42 end if; 43 end proces...
View Full Document

Ask a homework question - tutors are online