1 |
5 |
ktt1 |
--------------------------------------------------------------------------------
|
2 |
|
|
-- _ _ __ ____ --
|
3 |
|
|
-- / / | | / _| | __| --
|
4 |
|
|
-- | |_| | _ _ / / | |_ --
|
5 |
|
|
-- | _ | | | | | | | | _| --
|
6 |
|
|
-- | | | | | |_| | \ \_ | |__ --
|
7 |
|
|
-- |_| |_| \_____| \__| |____| microLab --
|
8 |
|
|
-- --
|
9 |
|
|
-- Bern University of Applied Sciences (BFH) --
|
10 |
|
|
-- Quellgasse 21 --
|
11 |
|
|
-- Room HG 4.33 --
|
12 |
|
|
-- 2501 Biel/Bienne --
|
13 |
|
|
-- Switzerland --
|
14 |
|
|
-- --
|
15 |
|
|
-- http://www.microlab.ch --
|
16 |
|
|
--------------------------------------------------------------------------------
|
17 |
|
|
-- GECKO4com
|
18 |
|
|
--
|
19 |
|
|
-- 2010/2011 Dr. Theo Kluter
|
20 |
|
|
--
|
21 |
|
|
-- This VHDL code is free code: you can redistribute it and/or modify
|
22 |
|
|
-- it under the terms of the GNU General Public License as published by
|
23 |
|
|
-- the Free Software Foundation, either version 3 of the License, or
|
24 |
|
|
-- (at your option) any later version.
|
25 |
|
|
--
|
26 |
|
|
-- This VHDL code is distributed in the hope that it will be useful,
|
27 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
28 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
29 |
|
|
-- GNU General Public License for more details.
|
30 |
|
|
-- You should have received a copy of the GNU General Public License
|
31 |
|
|
-- along with these sources. If not, see <http://www.gnu.org/licenses/>.
|
32 |
|
|
--
|
33 |
|
|
|
34 |
|
|
ARCHITECTURE no_target_specific OF config_if IS
|
35 |
|
|
|
36 |
|
|
COMPONENT fifo_2kb
|
37 |
|
|
PORT ( clock : IN std_logic;
|
38 |
|
|
reset : IN std_logic;
|
39 |
|
|
-- push port
|
40 |
|
|
push : IN std_logic;
|
41 |
|
|
push_data : IN std_logic_vector( 7 DOWNTO 0 );
|
42 |
|
|
push_size : IN std_logic;
|
43 |
|
|
-- pop port
|
44 |
|
|
pop : IN std_logic;
|
45 |
|
|
pop_data : OUT std_logic_vector( 7 DOWNTO 0 );
|
46 |
|
|
pop_size : OUT std_logic;
|
47 |
|
|
-- control port
|
48 |
|
|
fifo_full : OUT std_logic;
|
49 |
|
|
fifo_empty : OUT std_logic );
|
50 |
|
|
END COMPONENT;
|
51 |
|
|
|
52 |
|
|
TYPE CONFIG_STATE_TYPE IS (IDLE,SEND_START,WAIT_END,SIGNAL_ERROR);
|
53 |
|
|
|
54 |
|
|
SIGNAL s_config_state_reg : CONFIG_STATE_TYPE;
|
55 |
|
|
|
56 |
|
|
SIGNAL s_fifo_full : std_logic;
|
57 |
|
|
SIGNAL s_push : std_logic;
|
58 |
|
|
SIGNAL s_pop : std_logic;
|
59 |
|
|
SIGNAL s_pop_data : std_logic_vector( 7 DOWNTO 0 );
|
60 |
|
|
SIGNAL s_pop_last : std_logic;
|
61 |
|
|
SIGNAL s_fifo_empty : std_logic;
|
62 |
|
|
SIGNAL s_boot_up_config : std_logic;
|
63 |
|
|
SIGNAL s_boot_up_reg : std_logic;
|
64 |
|
|
|
65 |
|
|
BEGIN
|
66 |
|
|
--------------------------------------------------------------------------------
|
67 |
|
|
--- Here the outputs are defined ---
|
68 |
|
|
--------------------------------------------------------------------------------
|
69 |
|
|
flash_start_read <= '1' WHEN s_config_state_reg = SEND_START OR
|
70 |
|
|
(s_config_state_reg = IDLE AND
|
71 |
|
|
flash_u_start_read = '1') ELSE '0';
|
72 |
|
|
flash_u_done <= flash_done WHEN s_config_state_reg = IDLE ELSE '0';
|
73 |
|
|
flash_u_push <= flash_push WHEN s_config_state_reg = IDLE ELSE '0';
|
74 |
|
|
flash_u_push_data<= flash_push_data WHEN s_config_state_reg = IDLE ELSE (OTHERS => '0');
|
75 |
|
|
flash_u_push_size<= flash_push_size WHEN s_config_state_reg = IDLE ELSE '0';
|
76 |
|
|
flash_fifo_full <= flash_u_fifo_full WHEN s_config_state_reg = IDLE ELSE s_fifo_full;
|
77 |
|
|
bitfile_start <= '1' WHEN s_config_state_reg = SEND_START OR
|
78 |
|
|
(s_config_state_reg = IDLE AND
|
79 |
|
|
bitfile_u_start = '1') ELSE '0';
|
80 |
|
|
bitfile_u_pop <= bitfile_pop WHEN s_config_state_reg = IDLE ELSE '0';
|
81 |
|
|
bitfile_pop_data <= bitfile_u_pop_data WHEN s_config_state_reg = IDLE ELSE
|
82 |
|
|
s_pop_data;
|
83 |
|
|
bitfile_last <= bitfile_u_last WHEN s_config_state_reg = IDLE ELSE
|
84 |
|
|
s_pop_last;
|
85 |
|
|
bitfile_fifo_empty <= bitfile_u_fifo_empty WHEN s_config_state_reg = IDLE ELSE
|
86 |
|
|
s_fifo_empty;
|
87 |
|
|
command_error <= '1' WHEN s_config_state_reg = SIGNAL_ERROR ELSE '0';
|
88 |
|
|
|
89 |
|
|
--------------------------------------------------------------------------------
|
90 |
|
|
--- Here the control signals are defined ---
|
91 |
|
|
--------------------------------------------------------------------------------
|
92 |
|
|
s_push <= '1' WHEN s_config_state_reg = WAIT_END AND
|
93 |
|
|
flash_push = '1' AND
|
94 |
|
|
flash_push_size = '0' ELSE '0';
|
95 |
|
|
s_pop <= bitfile_pop WHEN s_config_state_reg = WAIT_END ELSE '0';
|
96 |
|
|
|
97 |
|
|
--------------------------------------------------------------------------------
|
98 |
|
|
--- Here the state machine is defined ---
|
99 |
|
|
--------------------------------------------------------------------------------
|
100 |
|
|
make_state_machine : PROCESS( clock , reset , s_config_state_reg )
|
101 |
|
|
VARIABLE v_next_state : CONFIG_STATE_TYPE;
|
102 |
|
|
BEGIN
|
103 |
|
|
CASE (s_config_state_reg) IS
|
104 |
|
|
WHEN IDLE => IF (start_command = '1' AND
|
105 |
|
|
command_id = "0011001") THEN
|
106 |
|
|
IF (flash_present = '0' OR
|
107 |
|
|
flash_s1_empty = '1' OR
|
108 |
|
|
fpga_type = "111") THEN
|
109 |
|
|
v_next_state := SIGNAL_ERROR;
|
110 |
|
|
ELSE
|
111 |
|
|
v_next_state := SEND_START;
|
112 |
|
|
END IF;
|
113 |
|
|
ELSIF (s_boot_up_config = '1' OR
|
114 |
|
|
start_config = '1') THEN
|
115 |
|
|
v_next_state := SEND_START;
|
116 |
|
|
ELSE
|
117 |
|
|
v_next_state := IDLE;
|
118 |
|
|
END IF;
|
119 |
|
|
WHEN SEND_START => v_next_state := WAIT_END;
|
120 |
|
|
WHEN WAIT_END => IF (s_pop = '1' AND
|
121 |
|
|
s_pop_last = '1') THEN
|
122 |
|
|
v_next_state := IDLE;
|
123 |
|
|
ELSE
|
124 |
|
|
v_next_state := WAIT_END;
|
125 |
|
|
END IF;
|
126 |
|
|
WHEN OTHERS => v_next_state := IDLE;
|
127 |
|
|
END CASE;
|
128 |
|
|
IF (clock'event AND (clock = '1')) THEN
|
129 |
|
|
IF (reset = '1') THEN s_config_state_reg <= IDLE;
|
130 |
|
|
ELSE s_config_state_reg <= v_next_state;
|
131 |
|
|
END IF;
|
132 |
|
|
END IF;
|
133 |
|
|
END PROCESS make_state_machine;
|
134 |
|
|
|
135 |
|
|
--------------------------------------------------------------------------------
|
136 |
|
|
--- Here the boot-up is defined ---
|
137 |
|
|
--------------------------------------------------------------------------------
|
138 |
|
|
s_boot_up_config <= '1' WHEN s_boot_up_reg = '1' AND
|
139 |
|
|
flash_present = '1' AND
|
140 |
|
|
n_bus_power = '0' AND
|
141 |
|
|
flash_s1_empty = '0' AND
|
142 |
|
|
flash_idle = '1' AND
|
143 |
|
|
fpga_idle = '1' AND
|
144 |
|
|
fpga_type /= "111" ELSE '0';
|
145 |
|
|
|
146 |
|
|
make_boot_up_reg : PROCESS( clock , reset , start_command , s_boot_up_config)
|
147 |
|
|
BEGIN
|
148 |
|
|
IF (clock'event AND (clock = '1')) THEN
|
149 |
|
|
IF (reset = '1') THEN s_boot_up_reg <= '1';
|
150 |
|
|
ELSIF (start_command = '1' OR
|
151 |
|
|
s_boot_up_config = '1') THEN s_boot_up_reg <= '0';
|
152 |
|
|
END IF;
|
153 |
|
|
END IF;
|
154 |
|
|
END PROCESS make_boot_up_reg;
|
155 |
|
|
|
156 |
|
|
--------------------------------------------------------------------------------
|
157 |
|
|
--- Here the components are defined ---
|
158 |
|
|
--------------------------------------------------------------------------------
|
159 |
|
|
fifo : fifo_2kb
|
160 |
|
|
PORT MAP ( clock => clock,
|
161 |
|
|
reset => reset,
|
162 |
|
|
-- push port
|
163 |
|
|
push => s_push,
|
164 |
|
|
push_data => flash_push_data,
|
165 |
|
|
push_size => flash_push_last,
|
166 |
|
|
-- pop port
|
167 |
|
|
pop => s_pop,
|
168 |
|
|
pop_data => s_pop_data,
|
169 |
|
|
pop_size => s_pop_last,
|
170 |
|
|
-- control port
|
171 |
|
|
fifo_full => s_fifo_full,
|
172 |
|
|
fifo_empty => s_fifo_empty );
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
END no_target_specific;
|