1 |
42 |
lmaarsen |
--------------------------------------------------------------------------------
|
2 |
53 |
lmaarsen |
--
|
3 |
|
|
-- This VHDL file was generated by EASE/HDL 7.4 Revision 4 from HDL Works B.V.
|
4 |
|
|
--
|
5 |
|
|
-- Ease library : work
|
6 |
|
|
-- HDL library : work
|
7 |
|
|
-- Host name : S212065
|
8 |
|
|
-- User name : df768
|
9 |
|
|
-- Time stamp : Tue Aug 19 08:05:18 2014
|
10 |
|
|
--
|
11 |
|
|
-- Designed by : L.Maarsen
|
12 |
|
|
-- Company : LogiXA
|
13 |
|
|
-- Project info : eSoC
|
14 |
|
|
--
|
15 |
42 |
lmaarsen |
--------------------------------------------------------------------------------
|
16 |
53 |
lmaarsen |
|
17 |
42 |
lmaarsen |
--------------------------------------------------------------------------------
|
18 |
|
|
-- Object : Entity work.esoc_control
|
19 |
|
|
-- Last modified : Thu Apr 17 12:55:38 2014.
|
20 |
|
|
--------------------------------------------------------------------------------
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
library ieee, std, work;
|
25 |
|
|
use ieee.std_logic_1164.all;
|
26 |
|
|
use std.textio.all;
|
27 |
|
|
use ieee.numeric_std.all;
|
28 |
|
|
use work.package_esoc_configuration.all;
|
29 |
|
|
|
30 |
|
|
entity esoc_control is
|
31 |
|
|
port(
|
32 |
|
|
brom_address : out std_logic_vector(10 downto 0);
|
33 |
|
|
brom_rd : out std_logic;
|
34 |
|
|
brom_rddata : in std_logic_vector(31 downto 0);
|
35 |
|
|
clk_control : in std_logic;
|
36 |
|
|
ctrl_address : out std_logic_vector(15 downto 0);
|
37 |
|
|
ctrl_rd : out std_logic;
|
38 |
|
|
ctrl_rddata : in std_logic_vector(31 downto 0);
|
39 |
|
|
ctrl_wait : in std_logic;
|
40 |
|
|
ctrl_wr : out std_logic;
|
41 |
|
|
ctrl_wrdata : out std_logic_vector(31 downto 0);
|
42 |
|
|
esoc_address : in std_logic_vector(15 downto 0);
|
43 |
|
|
esoc_boot_complete : out std_logic;
|
44 |
|
|
esoc_cs : in std_logic;
|
45 |
|
|
esoc_data : inout std_logic_vector(31 downto 0);
|
46 |
|
|
esoc_rd : in std_logic;
|
47 |
|
|
esoc_wait : out std_logic;
|
48 |
|
|
esoc_wr : in std_logic;
|
49 |
|
|
pll1_locked : in STD_LOGIC;
|
50 |
|
|
pll2_locked : in STD_LOGIC;
|
51 |
|
|
reset : in std_logic);
|
52 |
|
|
end entity esoc_control;
|
53 |
|
|
|
54 |
|
|
--------------------------------------------------------------------------------
|
55 |
|
|
-- Object : Architecture work.esoc_control.esoc_control
|
56 |
|
|
-- Last modified : Thu Apr 17 12:55:38 2014.
|
57 |
|
|
--------------------------------------------------------------------------------
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
---------------------------------------------------------------------------------------------------------------
|
61 |
|
|
-- architecture and declarations
|
62 |
|
|
---------------------------------------------------------------------------------------------------------------
|
63 |
|
|
architecture esoc_control of esoc_control is
|
64 |
|
|
|
65 |
|
|
---------------------------------------------------------------------------------------------------------------
|
66 |
|
|
-- registers
|
67 |
|
|
---------------------------------------------------------------------------------------------------------------
|
68 |
|
|
-- register and bit definitions
|
69 |
|
|
constant reg_ctrl_id_add : integer := 0;
|
70 |
|
|
|
71 |
|
|
constant reg_ctrl_version_add : integer := 1;
|
72 |
|
|
|
73 |
|
|
constant reg_ctrl_stat_ctrl_add : integer := 2;
|
74 |
|
|
|
75 |
|
|
constant reg_ctrl_scratch_add : integer := 3;
|
76 |
|
|
signal reg_ctrl_scratch_dat : std_logic_vector(31 downto 0);
|
77 |
|
|
constant reg_ctrl_scratch_rst : std_logic_vector(31 downto 0) := X"00000000";
|
78 |
|
|
|
79 |
|
|
---------------------------------------------------------------------------------------------------------------
|
80 |
|
|
-- signals
|
81 |
|
|
---------------------------------------------------------------------------------------------------------------
|
82 |
|
|
type ctrl_bus_states is (boot, boot_wait, boot_rd_add, boot_rd_dat, operational);
|
83 |
|
|
signal ctrl_bus_state: ctrl_bus_states;
|
84 |
|
|
|
85 |
|
|
signal esoc_rd_sync: std_logic_vector(2 downto 0);
|
86 |
|
|
signal esoc_wr_sync: std_logic_vector(2 downto 0);
|
87 |
|
|
|
88 |
|
|
signal ctrl_rd_i: std_logic;
|
89 |
|
|
signal ctrl_wr_i: std_logic;
|
90 |
|
|
signal ctrl_rdwr_i: std_logic;
|
91 |
|
|
signal ctrl_rddata_i: std_logic_vector(31 downto 0);
|
92 |
|
|
signal ctrl_wrdata_i: std_logic_vector(31 downto 0);
|
93 |
|
|
signal ctrl_address_i: std_logic_vector(ctrl_address'high downto 0);
|
94 |
|
|
signal ctrl_wait_i: std_logic;
|
95 |
|
|
|
96 |
|
|
constant brom_wait_count_init: integer := 31;
|
97 |
|
|
signal brom_wait_count: integer range brom_wait_count_init downto 0;
|
98 |
|
|
signal brom_address_count: integer range 2**brom_address'length-1 downto 0;
|
99 |
|
|
signal brom_error: std_logic;
|
100 |
|
|
|
101 |
|
|
signal pll1_locked_sync: std_logic_vector(esoc_meta_ffs-1 downto 0);
|
102 |
|
|
signal pll2_locked_sync: std_logic_vector(esoc_meta_ffs-1 downto 0);
|
103 |
|
|
|
104 |
|
|
begin
|
105 |
|
|
|
106 |
|
|
--=============================================================================================================
|
107 |
|
|
-- Process : synchronise asynchronous control inputs
|
108 |
|
|
-- Description :
|
109 |
|
|
--=============================================================================================================
|
110 |
|
|
sync: process(clk_control, reset)
|
111 |
|
|
begin
|
112 |
|
|
if reset = '1' then
|
113 |
|
|
esoc_rd_sync <= (others => '0');
|
114 |
|
|
esoc_wr_sync <= (others => '0');
|
115 |
|
|
|
116 |
|
|
pll1_locked_sync <= (others => '0');
|
117 |
|
|
pll2_locked_sync <= (others => '0');
|
118 |
|
|
|
119 |
|
|
elsif clk_control'event and clk_control = '1' then
|
120 |
|
|
esoc_rd_sync <= (esoc_cs and esoc_rd) & esoc_rd_sync(esoc_rd_sync'high downto 1);
|
121 |
|
|
esoc_wr_sync <= (esoc_cs and esoc_wr) & esoc_wr_sync(esoc_wr_sync'high downto 1);
|
122 |
|
|
|
123 |
|
|
pll1_locked_sync <= pll1_locked & pll1_locked_sync(pll1_locked_sync'high downto 1);
|
124 |
|
|
pll2_locked_sync <= pll2_locked & pll2_locked_sync(pll2_locked_sync'high downto 1);
|
125 |
|
|
end if;
|
126 |
|
|
end process;
|
127 |
|
|
|
128 |
|
|
--=============================================================================================================
|
129 |
|
|
-- Process : control internal bus with external bus signal
|
130 |
|
|
-- Description :
|
131 |
|
|
--=============================================================================================================
|
132 |
|
|
ctrlbus: process(clk_control, reset)
|
133 |
|
|
begin
|
134 |
|
|
if reset = '1' then
|
135 |
|
|
ctrl_rd_i <= '0';
|
136 |
|
|
ctrl_wr_i <= '0';
|
137 |
|
|
ctrl_rdwr_i <= '0';
|
138 |
|
|
ctrl_address_i <= (others => '0');
|
139 |
|
|
ctrl_wrdata_i <= (others => '0');
|
140 |
|
|
ctrl_bus_state <= boot;
|
141 |
|
|
|
142 |
|
|
brom_rd <= '0';
|
143 |
|
|
brom_address <= (others => '0');
|
144 |
|
|
brom_address_count <= 0;
|
145 |
|
|
brom_wait_count <= 0;
|
146 |
|
|
|
147 |
|
|
brom_error <= '0';
|
148 |
|
|
esoc_boot_complete <= '0';
|
149 |
|
|
|
150 |
|
|
elsif clk_control'event and clk_control = '1' then
|
151 |
|
|
|
152 |
|
|
case ctrl_bus_state is
|
153 |
|
|
when boot => -- boot from rom disabled, start read from boot rom
|
154 |
|
|
if esoc_brom_mode = enabled then
|
155 |
|
|
brom_rd <= '1';
|
156 |
|
|
brom_address <= std_logic_vector(to_unsigned(brom_address_count,brom_address'length));
|
157 |
|
|
brom_address_count <= brom_address_count + 1;
|
158 |
|
|
ctrl_bus_state <= boot_wait;
|
159 |
|
|
|
160 |
|
|
-- boot from rom disabled, step to operational state immediately
|
161 |
|
|
else
|
162 |
|
|
esoc_boot_complete <= '1';
|
163 |
|
|
ctrl_bus_state <= operational;
|
164 |
|
|
end if;
|
165 |
|
|
|
166 |
|
|
when boot_wait => -- wait for word from boot rom (the register address), continu read from boot prom
|
167 |
|
|
brom_rd <= '1';
|
168 |
|
|
brom_address <= std_logic_vector(to_unsigned(brom_address_count,brom_address'length));
|
169 |
|
|
brom_address_count <= brom_address_count + 1;
|
170 |
|
|
ctrl_bus_state <= boot_rd_add;
|
171 |
|
|
|
172 |
|
|
when boot_rd_add => -- evaluate word from boot rom (the register address) and wait for word from boot rom (the register content)
|
173 |
|
|
brom_rd <= '0';
|
174 |
|
|
|
175 |
|
|
-- stop reading from boot rom if all ones is returned
|
176 |
|
|
if brom_rddata = X"FFFFFFFF" then
|
177 |
|
|
brom_error <= '0';
|
178 |
|
|
esoc_boot_complete <= '1';
|
179 |
|
|
ctrl_bus_state <= operational;
|
180 |
|
|
|
181 |
|
|
-- prepare write on internal bus by providing the address, init wait counter for dead lock detection
|
182 |
|
|
else
|
183 |
|
|
brom_wait_count <= brom_wait_count_init;
|
184 |
|
|
ctrl_address_i <= brom_rddata(ctrl_address_i'high downto 0);
|
185 |
|
|
ctrl_bus_state <= boot_rd_dat;
|
186 |
|
|
end if;
|
187 |
|
|
|
188 |
|
|
when boot_rd_dat => -- word from boot rom (the register content) available, start write cycle on internal bus and wait for ACK
|
189 |
|
|
ctrl_wr_i <= '1';
|
190 |
|
|
ctrl_rdwr_i <= '1';
|
191 |
|
|
ctrl_wrdata_i <= brom_rddata;
|
192 |
|
|
|
193 |
|
|
-- wait for acknowledge, start counter to avoid dead lock due to wrong ROM content
|
194 |
|
|
if ctrl_wait = '0' or ctrl_wait_i = '0' then
|
195 |
|
|
ctrl_wr_i <= '0';
|
196 |
|
|
ctrl_bus_state <= boot;
|
197 |
|
|
|
198 |
|
|
-- write cycle time out? Terminate boot initialisation!
|
199 |
|
|
elsif brom_wait_count = 0 then
|
200 |
|
|
brom_error <= '1';
|
201 |
|
|
esoc_boot_complete <= '1';
|
202 |
|
|
ctrl_wr_i <= '0';
|
203 |
|
|
ctrl_bus_state <= operational;
|
204 |
|
|
|
205 |
|
|
-- count down
|
206 |
|
|
else
|
207 |
|
|
brom_wait_count <= brom_wait_count - 1;
|
208 |
|
|
end if;
|
209 |
|
|
|
210 |
|
|
when operational => -- detect rising edge of synchronized read signal, check address and drive internal signals of control bus
|
211 |
|
|
if esoc_rd_sync(esoc_rd_sync'low+1 downto 0) = "10" and to_integer(unsigned(esoc_address)) >= esoc_base and to_integer(unsigned(esoc_address)) < esoc_base + esoc_size then
|
212 |
|
|
ctrl_rd_i <= '1';
|
213 |
|
|
ctrl_rdwr_i <= '0';
|
214 |
|
|
ctrl_address_i <= esoc_address;
|
215 |
|
|
|
216 |
|
|
-- detect rising edge of synchronized write signal, check address and drive internal signals of control bus
|
217 |
|
|
elsif esoc_wr_sync(esoc_wr_sync'low+1 downto 0) = "10" and to_integer(unsigned(esoc_address)) >= esoc_base and to_integer(unsigned(esoc_address)) < esoc_base + esoc_size then
|
218 |
|
|
ctrl_wr_i <= '1';
|
219 |
|
|
ctrl_rdwr_i <= '1';
|
220 |
|
|
ctrl_wrdata_i <= esoc_data;
|
221 |
|
|
ctrl_address_i <= esoc_address;
|
222 |
|
|
|
223 |
|
|
-- reset internal signals read/write after acknowledge from addresses unit (ack = inactive wait)
|
224 |
|
|
elsif ctrl_wait = '0' or ctrl_wait_i = '0' then
|
225 |
|
|
ctrl_rd_i <= '0';
|
226 |
|
|
ctrl_wr_i <= '0';
|
227 |
|
|
end if;
|
228 |
|
|
|
229 |
|
|
when others => ctrl_bus_state <= boot;
|
230 |
|
|
end case;
|
231 |
|
|
end if;
|
232 |
|
|
end process;
|
233 |
|
|
|
234 |
|
|
-- use eSOC control interface inputs to drive eSOC control bus signals after initialisation by boot rom
|
235 |
|
|
ctrl_rd <= ctrl_rd_i;
|
236 |
|
|
ctrl_wr <= ctrl_wr_i;
|
237 |
|
|
ctrl_address <= ctrl_address_i;
|
238 |
|
|
ctrl_wrdata <= ctrl_wrdata_i;
|
239 |
|
|
|
240 |
|
|
-- use eSOC control bus signals to drive eSOC control interface outputs
|
241 |
|
|
esoc_data <= ctrl_rddata when ctrl_wait = '0' and ctrl_rdwr_i = '0' else
|
242 |
|
|
ctrl_rddata_i when ctrl_wait_i = '0' and ctrl_rdwr_i = '0' else (others => 'Z');
|
243 |
|
|
|
244 |
|
|
esoc_wait <= '0' when ctrl_wait = '0' or ctrl_wait_i = '0' else 'Z';
|
245 |
|
|
|
246 |
|
|
|
247 |
|
|
--=============================================================================================================
|
248 |
|
|
-- Process : access registers of control unit itself
|
249 |
|
|
-- Description :
|
250 |
|
|
--=============================================================================================================
|
251 |
|
|
registers: process(clk_control, reset)
|
252 |
|
|
begin
|
253 |
|
|
if reset = '1' then
|
254 |
|
|
reg_ctrl_scratch_dat <= reg_ctrl_scratch_rst;
|
255 |
|
|
ctrl_wait_i <= '1';
|
256 |
|
|
ctrl_rddata_i <= (others => '0');
|
257 |
|
|
|
258 |
|
|
elsif clk_control'event and clk_control = '1' then
|
259 |
|
|
ctrl_wait_i <= '1';
|
260 |
|
|
|
261 |
|
|
-- continu if memory space of this entity is addressed
|
262 |
|
|
if to_integer(unsigned(ctrl_address_i)) >= esoc_control_base and to_integer(unsigned(ctrl_address_i)) < esoc_control_base + esoc_control_size then
|
263 |
|
|
--
|
264 |
|
|
-- READ CYCLE started, unit addressed?
|
265 |
|
|
--
|
266 |
|
|
if ctrl_rd_i = '1' then
|
267 |
|
|
-- Check register address and provide data when addressed
|
268 |
|
|
case to_integer(unsigned(ctrl_address_i))- esoc_control_base is
|
269 |
|
|
when reg_ctrl_id_add => ctrl_rddata_i <= esoc_id;
|
270 |
|
|
ctrl_wait_i <= '0';
|
271 |
|
|
|
272 |
|
|
when reg_ctrl_version_add => ctrl_rddata_i <= std_logic_vector(to_unsigned(esoc_version,16)) & std_logic_vector(to_unsigned(esoc_release,16));
|
273 |
|
|
ctrl_wait_i <= '0';
|
274 |
|
|
|
275 |
|
|
when reg_ctrl_stat_ctrl_add => if esoc_brom_mode = enabled then
|
276 |
|
|
ctrl_rddata_i <= pll2_locked_sync(0) & pll1_locked_sync(0) & brom_error & '1' & X"000000" & std_logic_vector(to_unsigned(esoc_port_count,4));
|
277 |
|
|
else
|
278 |
|
|
ctrl_rddata_i <= pll2_locked_sync(0) & pll1_locked_sync(0) & brom_error & '0' & X"000000" & std_logic_vector(to_unsigned(esoc_port_count,4));
|
279 |
|
|
end if;
|
280 |
|
|
|
281 |
|
|
ctrl_wait_i <= '0';
|
282 |
|
|
|
283 |
|
|
when reg_ctrl_scratch_add => ctrl_rddata_i <= reg_ctrl_scratch_dat;
|
284 |
|
|
ctrl_wait_i <= '0';
|
285 |
|
|
|
286 |
|
|
when others => NULL;
|
287 |
|
|
end case;
|
288 |
|
|
|
289 |
|
|
--
|
290 |
|
|
-- WRITE CYCLE started, unit addressed?
|
291 |
|
|
--
|
292 |
|
|
elsif ctrl_wr_i = '1' then
|
293 |
|
|
-- Check register address and accept data when addressed
|
294 |
|
|
case to_integer(unsigned(ctrl_address_i)) - esoc_control_base is
|
295 |
|
|
when reg_ctrl_scratch_add => reg_ctrl_scratch_dat <= ctrl_wrdata_i;
|
296 |
|
|
ctrl_wait_i <= '0';
|
297 |
|
|
when others => NULL;
|
298 |
|
|
end case;
|
299 |
|
|
end if;
|
300 |
|
|
end if;
|
301 |
|
|
end if;
|
302 |
|
|
end process;
|
303 |
|
|
end architecture esoc_control ; -- of esoc_control
|
304 |
|
|
|