Commit a1401c27 authored by Oran Garrity's avatar Oran Garrity
Browse files

Lab#10 Game

parent e71ca919
LEDs count down from 5-1, then will reset when when the key is not pressed and reaches 1.
If the key is pressed only chance_s then the system will go to hit0_s. When the key is pressed in this state in a second it will revert back to the chance_s, if not the system will go to hit1_s after a second. This will loop if the key is not pressed. If the key is pressed then the system will go back to the chance_s state.
\ No newline at end of file
......@@ -8,14 +8,14 @@
<itransition ypos="253" endx="579" xpos="519" endy="253"/>
<state pencolor="0" exit_actions="" radius="40" description="" finalstate="0" entry_actions="" moore_outputs="0" ypos="253" code="0" xpos="619" linewidth="1">State_0</state>
<state pencolor="0" exit_actions="" radius="40" description="" finalstate="0" entry_actions="" moore_outputs="0" ypos="250" code="1" xpos="846" linewidth="1">State_1</state>
<state pencolor="0" exit_actions="" radius="40" description="" finalstate="0" entry_actions="" moore_outputs="0" ypos="253" code="2" xpos="1057" linewidth="1">State_2</state>
<state pencolor="0" exit_actions="" radius="40" description="" finalstate="0" entry_actions="" moore_outputs="1" ypos="253" code="2" xpos="1057" linewidth="1">State_2</state>
<transition c1x="708.0182001432086" c2y="252.3030044559592" c1y="252.3872081270176" description="" straight="1" type="0" ypos="252.4714117980759" endx="806.0615858717836" xpos="658.9965072789211" endy="252.2188007849009" c2x="757.0398930074961">
<from>0</from>
<to>1</to>
<inputs default="0" any="0" invert="0">1</inputs>
<outputs></outputs>
</transition>
<transition c1x="567.7078797600276" c2y="167.6969236895434" c1y="144.5144322903354" description="" straight="1" type="0" ypos="213.6452035960037" endx="638.815407674784" xpos="611.8445824720006" endy="218.253063175553" c2x="703.4001491229276">
<transition c1x="567.7078797600275" c2y="167.6969236895434" c1y="144.5144322903355" description="" straight="1" type="0" ypos="213.6452035960037" endx="638.815407674784" xpos="611.8445824720006" endy="218.253063175553" c2x="703.4001491229276">
<from>0</from>
<to>0</to>
<inputs default="0" any="0" invert="0">0</inputs>
......@@ -27,7 +27,7 @@
<inputs default="0" any="0" invert="0">0</inputs>
<outputs></outputs>
</transition>
<transition c1x="780.961764770772" c2y="154.3924965778037" c1y="149.1534434982156" description="" straight="1" type="0" ypos="211.9188575485894" endx="861.1014212426043" xpos="833.7596327834751" endy="212.9601960527135" c2x="918.5203784420264">
<transition c1x="780.9617647707719" c2y="154.3924965778037" c1y="149.1534434982156" description="" straight="1" type="0" ypos="211.9188575485894" endx="861.1014212426043" xpos="833.7596327834751" endy="212.9601960527135" c2x="918.5203784420263">
<from>1</from>
<to>1</to>
<inputs default="0" any="0" invert="0">1</inputs>
......
library IEEE;
use IEEE.std_logic_1164.all;
architecture fsm of falling_edge_detector is
signal q0,q1 : std_ulogic;
architecture rtl of falling_edge_detector is
TYPE state_t IS (state_0, state_1, state_2);
signal current_state, new_state : state_t;
begin
process(current_state, x_i)
BEGIN
new_state <= state_0;
fall_o <= '0';
CASE current_state IS
WHEN state_0 =>
IF x_i = '1' THEN new_state <= state_1; END if;
WHEN state_1 =>
IF x_i = '0' THEN new_state <= state_2;
ELSIF x_i = '1' THEN new_state <= state_1; END if;
q0 <= '1' when rst_ni = '0' else x_i when rising_edge(clk_i);
q1 <= '1' when rst_ni = '0' else q0 when rising_edge(clk_i);
fall_o <= '1' when q1 = '1' and q0 = '0' else '0';
WHEN state_2 =>
fall_o <= '1';
WHEN OTHERS => new_state <= state_0;
END case;
END process;
current_state <= state_0 WHEN rst_ni = '0' ELSE
new_state WHEN rising_edge(clk_i);
end architecture;
<?xml version='1.0'?>
<!DOCTYPE qfsmproject SYSTEM 'qfsm.dtd'>
<qfsmproject version="0.55" author="Qfsm">
<machine nummooreout="5" transfontitalic="0" draw_it="1" statefontsize="8" transfont="Helvetica" statefontitalic="0" author="" description="" version="" name="play_state" arrowtype="1" numbits="3" statefontweight="50" statefont="Helvetica" numin="2" transfontsize="8" transfontweight="50" type="0" numout="0" initialstate="0">
<outputnames_moore>led_o_0,led_o_1,led_o_2,led_o_3,led_o_4</outputnames_moore>
<inputnames>key_i,onesec_i</inputnames>
<outputnames></outputnames>
<itransition ypos="312" endx="182" xpos="122" endy="312"/>
<state pencolor="0" exit_actions="" radius="40" description="" finalstate="0" entry_actions="" moore_outputs="10000" ypos="312" code="0" xpos="222" linewidth="1">start_s</state>
<state pencolor="0" exit_actions="" radius="40" description="" finalstate="0" entry_actions="" moore_outputs="01000" ypos="312" code="1" xpos="416" linewidth="1">one_s</state>
<state pencolor="0" exit_actions="" radius="40" description="" finalstate="0" entry_actions="" moore_outputs="00100" ypos="315" code="2" xpos="570" linewidth="1">chance_s</state>
<state pencolor="0" exit_actions="" radius="40" description="" finalstate="0" entry_actions="" moore_outputs="00010" ypos="318" code="3" xpos="734" linewidth="1">four_s</state>
<state pencolor="0" exit_actions="" radius="40" description="" finalstate="0" entry_actions="" moore_outputs="00001" ypos="315" code="4" xpos="877" linewidth="1">last_s</state>
<state pencolor="0" exit_actions="" radius="40" description="" finalstate="0" entry_actions="" moore_outputs="10000" ypos="314" code="5" xpos="1021" linewidth="1">hit0_s</state>
<state pencolor="0" exit_actions="" radius="40" description="" finalstate="0" entry_actions="" moore_outputs="00001" ypos="314" code="6" xpos="1170" linewidth="1">hit1_s</state>
<transition c1x="155.8812154219565" c2y="215.6182792431281" c1y="211.8585683848974" description="" straight="1" type="0" ypos="274.0526680779794" endx="236.7022938635366" xpos="209.3508893593265" endy="274.799965656599" c2x="293.4882081461298">
<from>0</from>
<to>0</to>
<inputs default="0" any="0" invert="0">x0</inputs>
<outputs></outputs>
</transition>
<transition c1x="300" c2y="312" c1y="312" description="" straight="1" type="0" ypos="312" endx="376" xpos="262" endy="312" c2x="338">
<from>0</from>
<to>1</to>
<inputs default="0" any="0" invert="0">x1</inputs>
<outputs></outputs>
</transition>
<transition c1x="480.7236730917299" c2y="311.6893709966876" c1y="312.2317097877828" description="" straight="1" type="0" ypos="312.7740485788781" endx="530.1859994577881" xpos="455.9925099087009" endy="311.1470322055924" c2x="505.454836274759">
<from>1</from>
<to>2</to>
<inputs default="0" any="0" invert="0">x1</inputs>
<outputs></outputs>
</transition>
<transition c1x="356.3150051927187" c2y="220.3086895810126" c1y="207.8957186526183" description="" straight="1" type="0" ypos="273.3317908855395" endx="433.0144427529944" xpos="405.7642975873487" endy="275.7990505952527" c2x="493.4125544963405">
<from>1</from>
<to>1</to>
<inputs default="0" any="0" invert="0">x0</inputs>
<outputs></outputs>
</transition>
<transition c1x="637.9998655265008" c2y="316.5618211991595" c1y="316.1489464300209" description="" straight="1" type="0" ypos="315.7360716608824" endx="694.0131427636207" xpos="609.9932269079409" endy="316.974695968298" c2x="666.0065041450608">
<from>2</from>
<to>3</to>
<inputs default="0" any="0" invert="0">01</inputs>
<outputs></outputs>
</transition>
<transition c1x="636.1187845790656" c2y="411.3817207576016" c1y="415.1414316144278" description="" straight="1" type="0" ypos="352.9473319220206" endx="555.2977061364634" xpos="582.6491106406735" endy="352.200034343401" c2x="498.511791854854">
<from>2</from>
<to>2</to>
<inputs default="0" any="0" invert="0">00</inputs>
<outputs></outputs>
</transition>
<transition c1x="737.5149601041628" c2y="250.5733202383101" c1y="255.7286453881055" description="" straight="0" type="0" ypos="298.2999931379716" endx="998.8119921509908" xpos="606.3470737585325" endy="280.7179882264862" c2x="877.4899392483105">
<from>2</from>
<to>5</to>
<inputs default="0" any="0" invert="0">1x</inputs>
<outputs></outputs>
</transition>
<transition c1x="794.9941336787234" c2y="315.7203412551183" c1y="316.4406825102366" description="" straight="1" type="0" ypos="317.1610237653549" endx="837" xpos="773.9912005180852" endy="315" c2x="815.9970668393618">
<from>3</from>
<to>4</to>
<inputs default="0" any="0" invert="0">x1</inputs>
<outputs></outputs>
</transition>
<transition c1x="808.2066875542354" c2y="419.985567542628" c1y="412.3046527072131" description="" straight="1" type="0" ypos="354.7658012007223" endx="722.4377861164462" xpos="749.7567719431667" endy="356.2924954803282" c2x="670.7627956578718">
<from>3</from>
<to>3</to>
<inputs default="0" any="0" invert="0">x0</inputs>
<outputs></outputs>
</transition>
<transition c1x="727.9924987244274" c2y="503.8227800505479" c1y="499.5539791681363" description="" straight="0" type="0" ypos="348.6118659289698" endx="226.4172610429939" xpos="855.3149252071163" endy="351.7553493869448" c2x="383.771988528247">
<from>4</from>
<to>0</to>
<inputs default="0" any="0" invert="0">x1</inputs>
<outputs></outputs>
</transition>
<transition c1x="959.9661265160412" c2y="422.615274377232" c1y="401.6984535670865" description="" straight="1" type="0" ypos="350.0724963468527" endx="869.1893999027936" xpos="896.2333044482741" endy="354.2300207254791" c2x="823.906189431224">
<from>4</from>
<to>4</to>
<inputs default="0" any="0" invert="0">x0</inputs>
<outputs></outputs>
</transition>
<transition c1x="946.9870099266043" c2y="181.2890297985962" c1y="174.5306192457552" description="" straight="0" type="0" ypos="274.0732601347524" endx="594.2980043028319" xpos="1023.419802416076" endy="283.2256866809121" c2x="687.2401779249046">
<from>5</from>
<to>2</to>
<inputs default="0" any="0" invert="0">1x</inputs>
<outputs></outputs>
</transition>
<transition c1x="1097.528900189061" c2y="417.5266063267256" c1y="406.4301219075941" description="" straight="1" type="0" ypos="350.3625929157714" endx="1010.393616844486" xpos="1037.666188419729" endy="352.568181657403" c2x="960.3185219158995">
<from>5</from>
<to>5</to>
<inputs default="0" any="0" invert="0">00</inputs>
<outputs></outputs>
</transition>
<transition c1x="1082.447365012249" c2y="297.4033849066415" c1y="296.9523780763346" description="" straight="1" type="0" ypos="296.5013712460278" endx="1133.403287937083" xpos="1056.969403549832" endy="297.8543917369483" c2x="1107.925326474666">
<from>5</from>
<to>6</to>
<inputs default="0" any="0" invert="0">01</inputs>
<outputs></outputs>
</transition>
<transition c1x="1079.939384608372" c2y="46.4197291353467" c1y="117.7098290389106" description="" straight="0" type="0" ypos="274.025485826098" endx="566.9321400446105" xpos="1171.427661220496" endy="275.1178205799367" c2x="705.9555310792742">
<from>6</from>
<to>2</to>
<inputs default="0" any="0" invert="0">1x</inputs>
<outputs></outputs>
</transition>
<transition c1x="1108.421085912365" c2y="333.188981103684" c1y="332.9522449602226" description="" straight="1" type="0" ypos="332.7155088167613" endx="1055.966291044861" xpos="1134.648483346117" endy="333.4257172471453" c2x="1082.193688478613">
<from>6</from>
<to>5</to>
<inputs default="0" any="0" invert="0">01</inputs>
<outputs></outputs>
</transition>
<transition c1x="1239.779882890377" c2y="412.9615805473661" c1y="411.625652078771" description="" straight="1" type="0" ypos="351.4531671027618" endx="1156.684614693844" xpos="1184.044937663536" endy="351.7187024451877" c2x="1102.128020689189">
<from>6</from>
<to>6</to>
<inputs default="0" any="0" invert="0">00</inputs>
<outputs></outputs>
</transition>
</machine>
</qfsmproject>
......@@ -27,11 +27,14 @@ end component;
-- definition of a clock period
constant period : time := 10 ns;
constant onesec : time := 20 ns;
-- switch for clock generator
signal clken_p : boolean := true;
signal clk_i : std_ulogic;
signal onesec_i : std_ulogic;
signal rst_ni : std_ulogic;
signal key : std_ulogic;
signal ledr : std_ulogic_vector(4 downto 0);
......@@ -55,6 +58,15 @@ begin
wait;
end process;
onesec_proc : process
begin
while clken_p loop
onesec_i <= '0'; wait for onesec/2;
onesec_i <= '1'; wait for onesec/2;
end loop;
wait;
end process;
-- initial reset, always necessary at the beginning of a simulation
reset : rst_ni <= '0', '1' AFTER period;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment