1 | --Baseball Scorekeeper
|
2 | --STRIKES
|
3 | library IEEE;
|
4 | use ieee.std_logic_1164.all;
|
5 |
|
6 | entity strikes is
|
7 |
|
8 | port (button_press : in std_logic;
|
9 | reset : in std_logic;
|
10 | led_out : out std_logic_vector (1 downto 0)
|
11 |
|
12 | );
|
13 |
|
14 | end entity;
|
15 | architecture strikes_arch of strikes is
|
16 | signal tempLED : std_logic_vector (1 downto 0);
|
17 | begin
|
18 |
|
19 | process ( button_press)
|
20 | begin
|
21 |
|
22 | if reset='1' then tempLED <="00";
|
23 | elsif rising_edge(button_press) then
|
24 |
|
25 |
|
26 | case tempLED is
|
27 |
|
28 | when "00" => tempLED <="01";
|
29 | when "01" => tempLED <="11";
|
30 | when "10" => tempLED <="00";
|
31 | when "11" => tempLED <="00";
|
32 | when others => tempLED <= "00";
|
33 | end case;
|
34 | end if;
|
35 | end process;
|
36 | led_out <= tempLED;
|
37 | end strikes_arch;
|
38 |
|
39 |
|
40 | --BALLS
|
41 | library IEEE;
|
42 | use ieee.std_logic_1164.all;
|
43 |
|
44 | entity balls is
|
45 |
|
46 | port (button_press : in std_logic;
|
47 | reset : in std_logic;
|
48 | led_out : out std_logic_vector (2 downto 0)
|
49 |
|
50 | );
|
51 |
|
52 | end entity;
|
53 | architecture balls_arch of balls is
|
54 | signal tempLED : std_logic_vector (2 downto 0);
|
55 | begin
|
56 |
|
57 | process ( button_press)
|
58 | begin
|
59 |
|
60 | if reset='1' then tempLED <="000";
|
61 | elsif rising_edge(button_press) then
|
62 |
|
63 |
|
64 | case tempLED is
|
65 |
|
66 |
|
67 | when "000" => tempLED <="001";
|
68 | when "001" => tempLED <="011";
|
69 | when "010" => tempLED <="000";
|
70 | when "011" => tempLED <="111";
|
71 | when others => tempLED <= "000";
|
72 | end case;
|
73 | end if;
|
74 | end process;
|
75 | led_out <= tempLED;
|
76 | end balls_arch;
|
77 |
|
78 |
|
79 | library IEEE;
|
80 | use ieee.std_logic_1164.all;
|
81 |
|
82 | entity Baseball is
|
83 | port ( b1, b2, b3 : in std_logic;
|
84 | --mst_rst : in std_logic;
|
85 | strikes : out std_logic_vector (1 downto 0);
|
86 | balls : out std_logic_vector (2 downto 0)
|
87 |
|
88 | );
|
89 |
|
90 | end entity;
|
91 |
|
92 | architecture Baseball_arch of Baseball is
|
93 | --signal tempStrikes : std_logic_vector (1 downto 0);
|
94 | --signal tempBalls : std_logic_vector (2 downto 0);
|
95 | --signal temprst : std_logic;
|
96 |
|
97 | component strikes is
|
98 |
|
99 | port (button_press : in std_logic;
|
100 | reset : in std_logic;
|
101 | led_out : out std_logic_vector (1 downto 0)
|
102 |
|
103 | );
|
104 | end component;
|
105 |
|
106 | component balls is
|
107 |
|
108 | port (button_press : in std_logic;
|
109 | reset : in std_logic;
|
110 | led_out : out std_logic_vector (2 downto 0)
|
111 |
|
112 | );
|
113 |
|
114 | end component;
|
115 |
|
116 | begin
|
117 |
|
118 | UX0: port map strikes (button_press=> b1, reset=>b3, led_out=>strikes);
|
119 | UX1: port map balls (button_press=> b2, reset=>b3, led_out=>balls );
|
120 |
|
121 | end Baseball_arch;
|