-
Notifications
You must be signed in to change notification settings - Fork 0
/
MAIN_CTRL.vhd
102 lines (93 loc) · 2.54 KB
/
MAIN_CTRL.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 13.04.2019 00:45:36
-- Design Name:
-- Module Name: MAIN_CTRL - RTL
-- Project Name:
-- Target Devices:
-- Tool Versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity MAIN_CTRL is
port(CLK : in std_ulogic;
RESET : in std_ulogic;
TRIGGER : in std_ulogic;
EXPOSE : in std_ulogic;
MOTOR_READY : in std_ulogic;
MOTOR_ERROR : in std_ulogic;
ERROR : out std_ulogic;
TIMER_GO : out std_ulogic;
MOTOR_GO : out std_ulogic);
end MAIN_CTRL;
architecture RTL of MAIN_CTRL is
type T_STATE is (IDLE, TAKE_PIC, DELAY,
WAIT_EXP_TIME, FILM_TRANSPORT,
WAIT_TRANSPORT, BROKEN);
signal STATE: T_STATE;
signal NEXT_STATE: T_STATE;
begin
process (STATE, TRIGGER, EXPOSE,
MOTOR_ERROR, MOTOR_READY)
begin
NEXT_STATE <= STATE;
case STATE is
when IDLE =>
if TRIGGER = '1' then
NEXT_STATE <= TAKE_PIC;
end if;
when TAKE_PIC =>
NEXT_STATE <= DELAY;
when DELAY =>
NEXT_STATE <= WAIT_EXP_TIME;
when WAIT_EXP_TIME =>
if EXPOSE = '0' then
NEXT_STATE <= FILM_TRANSPORT;
end if;
when FILM_TRANSPORT =>
NEXT_STATE <= WAIT_TRANSPORT;
when WAIT_TRANSPORT =>
if MOTOR_ERROR = '1' then
NEXT_STATE <= BROKEN;
elsif MOTOR_READY = '1' then
NEXT_STATE <= IDLE;
end if;
when others =>
NULL;
end case;
end process;
process (CLK, RESET)
begin
if (RESET = '1') then
STATE <= IDLE;
elsif (CLK'event and CLK = '1') then
STATE <= NEXT_STATE;
end if; -- end of clocked process
end process;
with STATE select
TIMER_GO <= '1' when TAKE_PIC,
'0' when others;
with STATE select
MOTOR_GO <= '1' when FILM_TRANSPORT,
'0' when others;
with STATE select
ERROR <= '1' when BROKEN,
'0' when others;
end RTL;