Skip to content

Commit 873bcc6

Browse files
committed
Add INC
Signed-off-by: Matej Marusak <[email protected]>
1 parent d6aed91 commit 873bcc6

File tree

5 files changed

+323
-0
lines changed

5 files changed

+323
-0
lines changed

INC/accterm.bin

39.8 KB
Binary file not shown.

INC/fsm.vhd

+322
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,322 @@
1+
-- fsm.vhd: Finite State Machine
2+
-- Author(s): Matej Marusak, xmarus06
3+
-- Kod1=1102112033 kod2= 7714784232
4+
--
5+
library ieee;
6+
use ieee.std_logic_1164.all;
7+
-- ----------------------------------------------------------------------------
8+
-- Entity declaration
9+
-- ----------------------------------------------------------------------------
10+
entity fsm is
11+
port(
12+
CLK : in std_logic;
13+
RESET : in std_logic;
14+
15+
-- Input signals
16+
KEY : in std_logic_vector(15 downto 0);
17+
CNT_OF : in std_logic;
18+
19+
-- Output signals
20+
FSM_CNT_CE : out std_logic;
21+
FSM_MX_MEM : out std_logic;
22+
FSM_MX_LCD : out std_logic;
23+
FSM_LCD_WR : out std_logic;
24+
FSM_LCD_CLR : out std_logic
25+
);
26+
end entity fsm;
27+
28+
-- ----------------------------------------------------------------------------
29+
-- Architecture declaration
30+
-- ----------------------------------------------------------------------------
31+
architecture behavioral of fsm is
32+
type t_state is (START,TEST1A,TEST1B,TEST2A,TEST2B,TEST3A,TEST3B,TEST4A,TEST4B,TEST5A, TEST5B,TEST6A,TEST6B,TEST7A,TEST7B,TEST8A,TEST8B,TEST9A,TEST9B,CORRECT,WRONG, PRINT_MESSAGE_WRONG,PRINT_MESSAGE_RIGHT, FINISH);
33+
--sem daslie TEST1,TEST2...
34+
signal present_state, next_state : t_state;
35+
36+
begin
37+
-- -------------------------------------------------------
38+
sync_logic : process(RESET, CLK)
39+
begin
40+
if (RESET = '1') then
41+
present_state <= START;
42+
elsif (CLK'event AND CLK = '1') then
43+
present_state <= next_state;
44+
end if;
45+
end process sync_logic;
46+
47+
-- Kod1=1102112033 kod2= 7714784232
48+
-- -------------------------------------------------------
49+
next_state_logic : process(present_state, KEY, CNT_OF)
50+
begin
51+
case (present_state) is
52+
-- - - - - - - - - - - - - - - - - - - - - - -
53+
when START =>
54+
next_state <= START;
55+
if (KEY(1) = '1') then
56+
next_state <= TEST1A;
57+
elsif (KEY(7) = '1') then
58+
next_state <= TEST1B;
59+
elsif (KEY(15) = '1') then
60+
next_state <= PRINT_MESSAGE_WRONG;
61+
elsif (KEY(15 downto 0) /= "0000000000000000") then
62+
next_state <= WRONG;
63+
end if;
64+
-- - - - - - - - - - - - - - - - - - - - - - -
65+
-- - - - - - - - - - - - - - - - - - - - - - -
66+
when TEST1A =>
67+
next_state <= TEST1A;
68+
if (KEY(1) = '1') then
69+
next_state <= TEST2A;
70+
elsif (KEY(15) = '1') then
71+
next_state <= PRINT_MESSAGE_WRONG;
72+
elsif (KEY(15 downto 0) /= "0000000000000000") then
73+
next_state <= WRONG;
74+
end if;
75+
-- - - - - - - - - - - - - - - - - - - - - - -
76+
when TEST2A =>
77+
next_state <= TEST2A;
78+
if (KEY(0) = '1') then
79+
next_state <= TEST3A;
80+
elsif (KEY(15) = '1') then
81+
next_state <= PRINT_MESSAGE_WRONG;
82+
elsif (KEY(15 downto 0) /= "0000000000000000") then
83+
next_state <= WRONG;
84+
end if;
85+
-- - - - - - - - - - - - - - - - - - - - - - -
86+
when TEST3A =>
87+
next_state <= TEST3A;
88+
if (KEY(2) = '1') then
89+
next_state <= TEST4A;
90+
elsif (KEY(15) = '1') then
91+
next_state <= PRINT_MESSAGE_WRONG;
92+
elsif (KEY(15 downto 0) /= "0000000000000000") then
93+
next_state <= WRONG;
94+
end if;
95+
-- - - - - - - - - - - - - - - - - - - - - - -
96+
when TEST4A =>
97+
next_state <= TEST4A;
98+
if (KEY(1) = '1') then
99+
next_state <= TEST5A;
100+
elsif (KEY(15) = '1') then
101+
next_state <= PRINT_MESSAGE_WRONG;
102+
elsif (KEY(15 downto 0) /= "0000000000000000") then
103+
next_state <= WRONG;
104+
end if;
105+
-- - - - - - - - - - - - - - - - - - - - - - -
106+
when TEST5A =>
107+
next_state <= TEST5A;
108+
if (KEY(1) = '1') then
109+
next_state <= TEST6A;
110+
elsif (KEY(15) = '1') then
111+
next_state <= PRINT_MESSAGE_WRONG;
112+
elsif (KEY(15 downto 0) /= "0000000000000000") then
113+
next_state <= WRONG;
114+
end if;
115+
-- - - - - - - - - - - - - - - - - - - - - - -
116+
when TEST6A =>
117+
next_state <= TEST6A;
118+
if (KEY(2) = '1') then
119+
next_state <= TEST7A;
120+
elsif (KEY(15) = '1') then
121+
next_state <= PRINT_MESSAGE_WRONG;
122+
elsif (KEY(15 downto 0) /= "0000000000000000") then
123+
next_state <= WRONG;
124+
end if;
125+
-- - - - - - - - - - - - - - - - - - - - - - -
126+
when TEST7A =>
127+
next_state <= TEST7A;
128+
if (KEY(0) = '1') then
129+
next_state <= TEST8A;
130+
elsif (KEY(15) = '1') then
131+
next_state <= PRINT_MESSAGE_WRONG;
132+
elsif (KEY(15 downto 0) /= "0000000000000000") then
133+
next_state <= WRONG;
134+
end if;
135+
-- - - - - - - - - - - - - - - - - - - - - - -
136+
when TEST8A =>
137+
next_state <= TEST8A;
138+
if (KEY(3) = '1') then
139+
next_state <= TEST9A;
140+
elsif (KEY(15) = '1') then
141+
next_state <= PRINT_MESSAGE_WRONG;
142+
elsif (KEY(15 downto 0) /= "0000000000000000") then
143+
next_state <= WRONG;
144+
end if;
145+
-- - - - - - - - - - - - - - - - - - - - - - -
146+
when TEST9A =>
147+
next_state <= TEST9A;
148+
if (KEY(3) = '1') then
149+
next_state <= CORRECT;
150+
elsif (KEY(15) = '1') then
151+
next_state <= PRINT_MESSAGE_WRONG;
152+
elsif (KEY(15 downto 0) /= "0000000000000000") then
153+
next_state <= WRONG;
154+
end if;
155+
-- - - - - - - - - - - - - - - - - - - - - - -
156+
-- - - - - - - - - - - - - - - - - - - - - - -
157+
when TEST1B =>
158+
next_state <= TEST1B;
159+
if (KEY(7) = '1') then
160+
next_state <= TEST2B;
161+
elsif (KEY(15) = '1') then
162+
next_state <= PRINT_MESSAGE_WRONG;
163+
elsif (KEY(15 downto 0) /= "0000000000000000") then
164+
next_state <= WRONG;
165+
end if;
166+
-- - - - - - - - - - - - - - - - - - - - - - -
167+
when TEST2B =>
168+
next_state <= TEST2B;
169+
if (KEY(1) = '1') then
170+
next_state <= TEST3B;
171+
elsif (KEY(15) = '1') then
172+
next_state <= PRINT_MESSAGE_WRONG;
173+
elsif (KEY(15 downto 0) /= "0000000000000000") then
174+
next_state <= WRONG;
175+
end if;
176+
-- - - - - - - - - - - - - - - - - - - - - - -
177+
when TEST3B =>
178+
next_state <= TEST3B;
179+
if (KEY(4) = '1') then
180+
next_state <= TEST4B;
181+
elsif (KEY(15) = '1') then
182+
next_state <= PRINT_MESSAGE_WRONG;
183+
elsif (KEY(15 downto 0) /= "0000000000000000") then
184+
next_state <= WRONG;
185+
end if;
186+
-- - - - - - - - - - - - - - - - - - - - - - -
187+
when TEST4B =>
188+
next_state <= TEST4B;
189+
if (KEY(7) = '1') then
190+
next_state <= TEST5B;
191+
elsif (KEY(15) = '1') then
192+
next_state <= PRINT_MESSAGE_WRONG;
193+
elsif (KEY(15 downto 0) /= "0000000000000000") then
194+
next_state <= WRONG;
195+
end if;
196+
-- - - - - - - - - - - - - - - - - - - - - - -
197+
when TEST5B =>
198+
next_state <= TEST5B;
199+
if (KEY(8) = '1') then
200+
next_state <= TEST6B;
201+
elsif (KEY(15) = '1') then
202+
next_state <= PRINT_MESSAGE_WRONG;
203+
elsif (KEY(15 downto 0) /= "0000000000000000") then
204+
next_state <= WRONG;
205+
end if;
206+
-- - - - - - - - - - - - - - - - - - - - - - -
207+
when TEST6B =>
208+
next_state <= TEST6B;
209+
if (KEY(4) = '1') then
210+
next_state <= TEST7B;
211+
elsif (KEY(15) = '1') then
212+
next_state <= PRINT_MESSAGE_WRONG;
213+
elsif (KEY(15 downto 0) /= "0000000000000000") then
214+
next_state <= WRONG;
215+
end if;
216+
-- - - - - - - - - - - - - - - - - - - - - - -
217+
when TEST7B =>
218+
next_state <= TEST7B;
219+
if (KEY(2) = '1') then
220+
next_state <= TEST8B;
221+
elsif (KEY(15) = '1') then
222+
next_state <= PRINT_MESSAGE_WRONG;
223+
elsif (KEY(15 downto 0) /= "0000000000000000") then
224+
next_state <= WRONG;
225+
end if;
226+
-- - - - - - - - - - - - - - - - - - - - - - -
227+
when TEST8B =>
228+
next_state <= TEST8B;
229+
if (KEY(3) = '1') then
230+
next_state <= TEST9B;
231+
elsif (KEY(15) = '1') then
232+
next_state <= PRINT_MESSAGE_WRONG;
233+
elsif (KEY(15 downto 0) /= "0000000000000000") then
234+
next_state <= WRONG;
235+
end if;
236+
-- - - - - - - - - - - - - - - - - - - - - - -
237+
when TEST9B =>
238+
next_state <= TEST9B;
239+
if (KEY(2) = '1') then
240+
next_state <= CORRECT;
241+
elsif (KEY(15) = '1') then
242+
next_state <= PRINT_MESSAGE_WRONG;
243+
elsif (KEY(15 downto 0) /= "0000000000000000") then
244+
next_state <= WRONG;
245+
end if;
246+
-- - - - - - - - - - - - - - - - - - - - - - -
247+
when PRINT_MESSAGE_WRONG =>
248+
next_state <= PRINT_MESSAGE_WRONG;
249+
if (CNT_OF = '1') then
250+
next_state <= FINISH;
251+
end if;
252+
-- - - - - - - - - - - - - - - - - - - - - - -
253+
when CORRECT =>
254+
next_state <= CORRECT;
255+
if (KEY(15) = '1') then
256+
next_state <= PRINT_MESSAGE_RIGHT;
257+
elsif (KEY(15 downto 0) /= "0000000000000000") then
258+
next_state <= WRONG;
259+
end if;
260+
-- - - - - - - - - - - - - - - - - - - - - - -
261+
when WRONG =>
262+
next_state <= WRONG;
263+
if (KEY(15) = '1') then
264+
next_state <= PRINT_MESSAGE_WRONG;
265+
end if;
266+
-- - - - - - - - - - - - - - - - - - - - - - -
267+
when PRINT_MESSAGE_RIGHT =>
268+
next_state <= PRINT_MESSAGE_RIGHT;
269+
if (CNT_OF = '1') then
270+
next_state <= FINISH;
271+
end if;
272+
-- - - - - - - - - - - - - - - - - - - - - - -
273+
when FINISH =>
274+
next_state <= FINISH;
275+
if (KEY(15) = '1') then
276+
next_state <= START;
277+
end if;
278+
-- - - - - - - - - - - - - - - - - - - - - - -
279+
when others =>
280+
next_state <= START;
281+
end case;
282+
end process next_state_logic;
283+
284+
-- -------------------------------------------------------
285+
output_logic : process(present_state, KEY)
286+
begin
287+
FSM_CNT_CE <= '0';
288+
FSM_MX_MEM <= '0';
289+
FSM_MX_LCD <= '0';
290+
FSM_LCD_WR <= '0';
291+
FSM_LCD_CLR <= '0';
292+
293+
case (present_state) is
294+
-- - - - - - - - - - - - - - - - - - - - - - -
295+
when PRINT_MESSAGE_WRONG =>
296+
FSM_CNT_CE <= '1';
297+
FSM_MX_LCD <= '1';
298+
FSM_LCD_WR <= '1';
299+
-- - - - - - - - - - - - - - - - - - - - - - -
300+
when PRINT_MESSAGE_RIGHT =>
301+
FSM_CNT_CE <= '1';
302+
FSM_MX_LCD <= '1';
303+
FSM_MX_MEM <= '1';
304+
FSM_LCD_WR <= '1';
305+
-- - - - - - - - - - - - - - - - - - - - - - -
306+
when FINISH =>
307+
if (KEY(15) = '1') then
308+
FSM_LCD_CLR <= '1';
309+
end if;
310+
-- - - - - - - - - - - - - - - - - - - - - - -
311+
when others =>
312+
if (KEY(14 downto 0) /= "000000000000000") then
313+
FSM_LCD_WR <= '1';
314+
end if;
315+
if (KEY(15) = '1') then
316+
FSM_LCD_CLR <= '1';
317+
end if;
318+
end case;
319+
end process output_logic;
320+
321+
end architecture behavioral;
322+

INC/zadani.pdf

472 KB
Binary file not shown.

INC/zprava.pdf

129 KB
Binary file not shown.

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ IZP no.2 | 10/10 |
1010
IZP no.3 | 10/10 |
1111
ITO | 15/15 |
1212
IUS | 18/20 | Missing some links between entities
13+
INC | 20/20 |

0 commit comments

Comments
 (0)