1 |
9 |
nuubik |
------------------------------------------------------------------
|
2 |
|
|
-- Universal dongle board source code
|
3 |
|
|
--
|
4 |
|
|
-- Copyright (C) 2006 Artec Design <jyrit@artecdesign.ee>
|
5 |
|
|
--
|
6 |
|
|
-- This source code is free hardware; you can redistribute it and/or
|
7 |
|
|
-- modify it under the terms of the GNU Lesser General Public
|
8 |
|
|
-- License as published by the Free Software Foundation; either
|
9 |
|
|
-- version 2.1 of the License, or (at your option) any later version.
|
10 |
|
|
--
|
11 |
|
|
-- This source code is distributed in the hope that it will be useful,
|
12 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
|
|
-- Lesser General Public License for more details.
|
15 |
|
|
--
|
16 |
|
|
-- You should have received a copy of the GNU Lesser General Public
|
17 |
|
|
-- License along with this library; if not, write to the Free Software
|
18 |
|
|
-- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19 |
|
|
--
|
20 |
|
|
--
|
21 |
|
|
-- The complete text of the GNU Lesser General Public License can be found in
|
22 |
|
|
-- the file 'lesser.txt'.
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
-- Coding for seg_out(7:0) "01101101"
|
26 |
|
|
--
|
27 |
|
|
-- bit 0,A
|
28 |
|
|
-- ----------
|
29 |
|
|
-- | |
|
30 |
|
|
-- | |
|
31 |
|
|
-- 5,F| | 1,B
|
32 |
|
|
-- | 6,G |
|
33 |
|
|
-- ----------
|
34 |
|
|
-- | |
|
35 |
|
|
-- | |
|
36 |
|
|
-- 4,E| | 2,C
|
37 |
|
|
-- | 3,D |
|
38 |
|
|
-- ----------
|
39 |
|
|
-- # 7,H
|
40 |
|
|
|
41 |
|
|
-- Revision history
|
42 |
|
|
--
|
43 |
|
|
-- Version 1.01
|
44 |
|
|
-- 15 oct 2006 version code 86 01 jyrit
|
45 |
|
|
-- Added IO write to address 0x0088 with commands F1 and F4 to
|
46 |
|
|
-- enable switching dongle to 4Meg mode for external reads
|
47 |
|
|
-- Changed USB interface to address all 4 Meg on any mode jumper configuration
|
48 |
|
|
--
|
49 |
|
|
-- Version 1.02
|
50 |
|
|
-- 04 dec 2006 version code 86 02 jyrit
|
51 |
|
|
-- Added listen only mode for mode pin configuration "00" to enable post code
|
52 |
|
|
-- spy mode (does not respond to external reads).
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
library ieee;
|
56 |
|
|
use ieee.std_logic_1164.all;
|
57 |
|
|
use IEEE.std_logic_unsigned.all;
|
58 |
|
|
use IEEE.std_logic_arith.all;
|
59 |
|
|
use work.serial_usb_package.all;
|
60 |
|
|
use work.dongle_arch.all;
|
61 |
|
|
|
62 |
|
|
entity design_top is
|
63 |
|
|
port(
|
64 |
|
|
--system signals
|
65 |
|
|
sys_clk : in std_logic; --25 MHz clk
|
66 |
|
|
resetn : in std_logic;
|
67 |
|
|
hdr : inout std_logic_vector(15 downto 0);
|
68 |
|
|
hdr_b : inout std_logic_vector(15 downto 0);
|
69 |
|
|
--alt_clk : out std_logic;
|
70 |
|
|
|
71 |
|
|
mode : inout std_logic_vector(2 downto 0); --sel upper addr bits
|
72 |
|
|
--lpc slave interf
|
73 |
|
|
lad : inout std_logic_vector(3 downto 0);
|
74 |
|
|
lframe_n : in std_logic;
|
75 |
|
|
lreset_n : in std_logic;
|
76 |
|
|
lclk : in std_logic;
|
77 |
|
|
ldev_present : out std_logic;
|
78 |
|
|
lserirq : inout std_logic;
|
79 |
|
|
--led system
|
80 |
|
|
seg_out : out std_logic_vector(7 downto 0);
|
81 |
|
|
scn_seg : out std_logic_vector(3 downto 0);
|
82 |
|
|
scn_seg2 : out std_logic_vector(3 downto 0); --parallel line to get more current
|
83 |
|
|
|
84 |
|
|
led_green : out std_logic;
|
85 |
|
|
led_red : out std_logic;
|
86 |
|
|
--flash interface
|
87 |
|
|
fl_addr : out std_logic_vector(23 downto 0);
|
88 |
|
|
fl_ce_n : out std_logic; --chip select
|
89 |
|
|
fl_oe_n : out std_logic; --output enable for flash
|
90 |
|
|
fl_we_n : out std_logic; --write enable
|
91 |
|
|
fl_data : inout std_logic_vector(15 downto 0);
|
92 |
|
|
fl_rp_n : out std_logic; --reset signal
|
93 |
|
|
fl_sts : in std_logic; --status signal
|
94 |
|
|
fl_sts_en : out std_logic; --enable status signal wiht highZ out
|
95 |
|
|
-- PSRAM aditional signals to flash
|
96 |
|
|
ps_ram_en : out std_logic;
|
97 |
|
|
ps_clk : out std_logic; --PSRAM clock
|
98 |
|
|
ps_wait : in std_logic;
|
99 |
|
|
ps_addr_val : out std_logic; --active low
|
100 |
|
|
ps_confr_en : out std_logic;
|
101 |
|
|
ps_lsb_en : out std_logic;
|
102 |
|
|
ps_msb_en : out std_logic;
|
103 |
|
|
-- EEPROM signals
|
104 |
|
|
-- ee_di : out std_logic;
|
105 |
|
|
-- ee_do : in std_logic;
|
106 |
|
|
-- ee_hold_n : out std_logic;
|
107 |
|
|
-- ee_cs_n : out std_logic;
|
108 |
|
|
-- ee_clk : out std_logic;
|
109 |
|
|
-- ee_write : out std_logic;
|
110 |
|
|
-- PROG enable
|
111 |
|
|
buf_oe_n : out std_logic;
|
112 |
|
|
--USB parallel interface
|
113 |
|
|
usb_rd_n : out std_logic; -- enables out data if low (next byte detected by edge / in usb chip)
|
114 |
|
|
usb_wr : out std_logic; -- write performed on edge \ of signal
|
115 |
|
|
usb_txe_n : in std_logic; -- transmit enable (redy for new data if low)
|
116 |
|
|
usb_rxf_n : in std_logic; -- rx fifo has data if low
|
117 |
|
|
usb_bd : inout std_logic_vector(7 downto 0) --bus data
|
118 |
|
|
);
|
119 |
|
|
end design_top;
|
120 |
|
|
|
121 |
|
|
architecture rtl of design_top is
|
122 |
|
|
component led_sys --toplevel for led system
|
123 |
|
|
generic(
|
124 |
|
|
msn_hib : std_logic_vector(7 downto 0); --Most signif. of hi byte
|
125 |
|
|
lsn_hib : std_logic_vector(7 downto 0); --Least signif. of hi byte
|
126 |
|
|
msn_lob : std_logic_vector(7 downto 0); --Most signif. of hi byte
|
127 |
|
|
lsn_lob : std_logic_vector(7 downto 0) --Least signif. of hi byte
|
128 |
|
|
);
|
129 |
|
|
port(
|
130 |
|
|
clk : in std_logic;
|
131 |
|
|
reset_n : in std_logic;
|
132 |
|
|
led_data_i : in std_logic_vector(15 downto 0); --binary data in
|
133 |
|
|
seg_out : out std_logic_vector(7 downto 0); --one segment out
|
134 |
|
|
sel_out : out std_logic_vector(3 downto 0) --segment scanner with one bit low
|
135 |
|
|
);
|
136 |
|
|
end component;
|
137 |
|
|
|
138 |
|
|
component lpc_iow
|
139 |
|
|
port(
|
140 |
|
|
--system signals
|
141 |
|
|
lreset_n : in std_logic;
|
142 |
|
|
lclk : in std_logic;
|
143 |
|
|
lena_mem_r : in std_logic; --enable full adress range covering memory read block
|
144 |
|
|
lena_reads : in std_logic; --enable read capabilities
|
145 |
|
|
uart_addr : in std_logic_vector(15 downto 0); -- define UART address to listen to
|
146 |
|
|
--LPC bus from host
|
147 |
|
|
lad_i : in std_logic_vector(3 downto 0);
|
148 |
|
|
lad_o : out std_logic_vector(3 downto 0);
|
149 |
|
|
lad_oe : out std_logic;
|
150 |
|
|
lframe_n : in std_logic;
|
151 |
|
|
--memory interface
|
152 |
|
|
lpc_addr : out std_logic_vector(23 downto 0); --shared address
|
153 |
|
|
lpc_wr : out std_logic; --shared write not read
|
154 |
|
|
lpc_io : out std_logic; --io access not mem access select
|
155 |
|
|
lpc_uart : out std_logic; --uart mapped cycle coming
|
156 |
|
|
lpc_gpioled: out std_logic; --gpio led cycle coming
|
157 |
|
|
lpc_data_i : in std_logic_vector(7 downto 0);
|
158 |
|
|
lpc_data_o : out std_logic_vector(7 downto 0);
|
159 |
|
|
lpc_val : out std_logic;
|
160 |
|
|
lpc_ack : in std_logic
|
161 |
|
|
);
|
162 |
|
|
end component;
|
163 |
|
|
|
164 |
|
|
component flash_if
|
165 |
|
|
port(
|
166 |
|
|
clk : in std_logic;
|
167 |
|
|
reset_n : in std_logic;
|
168 |
|
|
mode : in std_logic_vector(2 downto 0); --sel upper addr bits
|
169 |
|
|
--flash Bus
|
170 |
|
|
fl_addr : out std_logic_vector(23 downto 0);
|
171 |
|
|
fl_ce_n : out std_logic; --chip select
|
172 |
|
|
fl_oe_n : out std_logic; --output enable for flash
|
173 |
|
|
fl_we_n : out std_logic; --write enable
|
174 |
|
|
fl_data : inout std_logic_vector(15 downto 0);
|
175 |
|
|
fl_rp_n : out std_logic; --reset signal
|
176 |
|
|
fl_byte_n : out std_logic; --hold in byte mode
|
177 |
|
|
fl_sts : in std_logic; --status signal
|
178 |
|
|
-- mem Bus
|
179 |
|
|
mem_addr : in std_logic_vector(23 downto 0);
|
180 |
|
|
mem_do : out std_logic_vector(15 downto 0);
|
181 |
|
|
mem_di : in std_logic_vector(15 downto 0);
|
182 |
|
|
mem_wr : in std_logic; --write not read signal
|
183 |
|
|
mem_val : in std_logic;
|
184 |
|
|
mem_ack : out std_logic
|
185 |
|
|
);
|
186 |
|
|
end component;
|
187 |
|
|
|
188 |
|
|
component usb2mem
|
189 |
|
|
port(
|
190 |
|
|
clk25 : in std_logic;
|
191 |
|
|
reset_n : in std_logic;
|
192 |
|
|
dongle_ver : in std_logic_vector(15 downto 0);
|
193 |
|
|
pcb_ver : in std_logic_vector(15 downto 0);
|
194 |
|
|
mode : in std_logic_vector(2 downto 0); --sel upper addr bits
|
195 |
|
|
usb_buf_en : out std_logic;
|
196 |
|
|
dev_present_n : out std_logic;
|
197 |
|
|
-- mem Bus
|
198 |
|
|
mem_busy_n : in std_logic;
|
199 |
|
|
mem_idle : out std_logic; -- '1' if controller is idle (flash is safe for LPC reads)
|
200 |
|
|
mem_addr : out std_logic_vector(23 downto 0);
|
201 |
|
|
mem_do : out std_logic_vector(15 downto 0);
|
202 |
|
|
mem_di : in std_logic_vector(15 downto 0);
|
203 |
|
|
mem_wr : out std_logic;
|
204 |
|
|
mem_val : out std_logic;
|
205 |
|
|
mem_ack : in std_logic;
|
206 |
|
|
mem_cmd : out std_logic;
|
207 |
|
|
-- USB port
|
208 |
|
|
usb_mode_en : in std_logic; -- enable this block
|
209 |
|
|
usb_rd_n : out std_logic; -- enables out data if low (next byte detected by edge / in usb chip)
|
210 |
|
|
usb_wr : out std_logic; -- write performed on edge \ of signal
|
211 |
|
|
usb_txe_n : in std_logic; -- tx fifo empty (redy for new data if low)
|
212 |
|
|
usb_rxf_n : in std_logic; -- rx fifo empty (data redy if low)
|
213 |
|
|
usb_bd_o : out std_logic_vector(7 downto 0); --bus data
|
214 |
|
|
usb_bd : in std_logic_vector(7 downto 0) --bus data
|
215 |
|
|
);
|
216 |
|
|
end component;
|
217 |
|
|
|
218 |
|
|
component pc_serializer
|
219 |
|
|
Port( --system signals
|
220 |
|
|
sys_clk : in STD_LOGIC;
|
221 |
|
|
resetn : in STD_LOGIC;
|
222 |
|
|
--postcode data port
|
223 |
|
|
dbg_data : in STD_LOGIC_VECTOR(7 downto 0);
|
224 |
|
|
dbg_wr : in STD_LOGIC; --write not read
|
225 |
|
|
dbg_full : out STD_LOGIC; --write not read
|
226 |
|
|
dbg_almost_full : out STD_LOGIC;
|
227 |
|
|
dbg_usedw : out STD_LOGIC_VECTOR(12 DOWNTO 0);
|
228 |
|
|
--debug USB port
|
229 |
|
|
dbg_usb_mode_en : in std_logic; -- enable this debug mode
|
230 |
|
|
dbg_usb_wr : out std_logic; -- write performed on edge \ of signal
|
231 |
|
|
dbg_usb_txe_n : in std_logic; -- tx fifo not full (redy for new data if low)
|
232 |
|
|
dbg_usb_bd : out std_logic_vector(7 downto 0) --bus data
|
233 |
|
|
);
|
234 |
|
|
end component;
|
235 |
|
|
|
236 |
|
|
component serial_usb
|
237 |
|
|
port(
|
238 |
|
|
clock : in std_logic;
|
239 |
|
|
reset_n : in std_logic;
|
240 |
|
|
--VCI Port
|
241 |
|
|
vci_in : in vci_slave_in;
|
242 |
|
|
vci_out : out vci_slave_out;
|
243 |
|
|
--FTDI fifo interface
|
244 |
|
|
uart_ena : in usbser_ctrl;
|
245 |
|
|
fifo_out : out usb_out;
|
246 |
|
|
fifo_in : in usb_in
|
247 |
|
|
);
|
248 |
|
|
end component;
|
249 |
|
|
|
250 |
|
|
component serirq
|
251 |
|
|
port (
|
252 |
|
|
clock : in std_logic;
|
253 |
|
|
reset_n : in std_logic;
|
254 |
|
|
slot_sel : in std_logic_vector(4 downto 0); --clk no of IRQ defined in Ser irq for PCI systems spec.
|
255 |
|
|
serirq : inout std_logic;
|
256 |
|
|
irq : in std_logic
|
257 |
|
|
);
|
258 |
|
|
end component;
|
259 |
|
|
|
260 |
|
|
|
261 |
|
|
--LED signals
|
262 |
|
|
signal data_to_disp : std_logic_vector(15 downto 0);
|
263 |
|
|
|
264 |
|
|
signal scn_seg_w : std_logic_vector(3 downto 0);
|
265 |
|
|
--END LED SIGNALS
|
266 |
|
|
|
267 |
|
|
--lpc signals
|
268 |
|
|
signal lad_i : std_logic_vector(3 downto 0);
|
269 |
|
|
signal lad_o : std_logic_vector(3 downto 0);
|
270 |
|
|
signal lad_oe : std_logic;
|
271 |
|
|
|
272 |
|
|
signal lpc_debug : std_logic_vector(31 downto 0);
|
273 |
|
|
signal lpc_debug_cnt : std_logic_vector(15 downto 0);
|
274 |
|
|
signal lpc_addr : std_logic_vector(23 downto 0); --shared address
|
275 |
|
|
signal lpc_data_o : std_logic_vector(7 downto 0);
|
276 |
|
|
signal lpc_data_i : std_logic_vector(7 downto 0);
|
277 |
|
|
signal lpc_wr : std_logic; --shared write not read
|
278 |
|
|
signal lpc_io : std_logic; --io cycle not mem cycle
|
279 |
|
|
signal lpc_uart : std_logic; --uart mapped cycle coming
|
280 |
|
|
signal lpc_gpioled : std_logic; --gpio led cycle coming
|
281 |
|
|
signal lpc_ack : std_logic;
|
282 |
|
|
signal lpc_val : std_logic;
|
283 |
|
|
signal lena_mem_r : std_logic; --enable full adress range covering memory read block
|
284 |
|
|
signal lena_reads : std_logic; --enable/disables all read capabilty to make the device post code capturer
|
285 |
|
|
|
286 |
|
|
signal c25_lpc_val : std_logic;
|
287 |
|
|
signal c25_lpc_io : std_logic;
|
288 |
|
|
signal c25_lpc_uart : std_logic;
|
289 |
|
|
signal c25_lpc_wr : std_logic; --shared write not read
|
290 |
|
|
signal c25_lpc_wr_long : std_logic; --for led debug data latching
|
291 |
|
|
|
292 |
|
|
signal c33_lpc_wr_long : std_logic; --for led debug data latching
|
293 |
|
|
signal c33_lpc_wr : std_logic; --for led debug data latching
|
294 |
|
|
signal c33_lpc_wr_wait : std_logic; --for led debug data latching
|
295 |
|
|
signal c33_lpc_wr_waitd : std_logic; --for led debug data latching
|
296 |
|
|
signal c33_wr_cnt : std_logic_vector(23 downto 0); --for led debug data latching
|
297 |
|
|
signal c33_led_ack : std_logic; --for led debug data latching
|
298 |
|
|
|
299 |
|
|
|
300 |
|
|
--End lpc signals
|
301 |
|
|
|
302 |
|
|
--Flash signals
|
303 |
|
|
signal mem_addr : std_logic_vector(23 downto 0);
|
304 |
|
|
signal mem_do : std_logic_vector(15 downto 0);
|
305 |
|
|
signal mem_di : std_logic_vector(15 downto 0);
|
306 |
|
|
signal mem_wr : std_logic; --write not read signal
|
307 |
|
|
signal mem_val : std_logic;
|
308 |
|
|
signal mem_ack : std_logic;
|
309 |
|
|
|
310 |
|
|
signal c33_mem_ack : std_logic; --sync signal
|
311 |
|
|
|
312 |
|
|
|
313 |
|
|
signal fl_ce_n_w : std_logic; --chip select
|
314 |
|
|
signal fl_oe_n_w : std_logic; --output enable for flash
|
315 |
|
|
signal fl_we_n_w : std_logic; --output enable for flash
|
316 |
|
|
|
317 |
|
|
|
318 |
|
|
--END flash signals
|
319 |
|
|
|
320 |
|
|
-- UART signals
|
321 |
|
|
signal uart_addr : std_logic_vector(15 downto 0); -- define UART address to listen to
|
322 |
|
|
signal uart_name : STD_LOGIC_VECTOR(7 downto 0);
|
323 |
|
|
signal clock : std_logic;
|
324 |
|
|
signal reset_n : std_logic;
|
325 |
|
|
|
326 |
|
|
signal pc_loop_en : std_logic;
|
327 |
|
|
--VCI Port
|
328 |
|
|
signal uart_vci_in : vci_slave_in;
|
329 |
|
|
signal uart_vci_out : vci_slave_out;
|
330 |
|
|
--FTDI fifo interface
|
331 |
|
|
signal uart_ena : usbser_ctrl;
|
332 |
|
|
signal uart_fifo_out : usb_out;
|
333 |
|
|
signal uart_fifo_in : usb_in;
|
334 |
|
|
signal c33_uart_ack : std_logic;
|
335 |
|
|
-- end UART
|
336 |
|
|
|
337 |
|
|
--USB signals
|
338 |
|
|
signal dbg_data : STD_LOGIC_VECTOR(7 downto 0);
|
339 |
|
|
signal c25_dbg_addr_d : STD_LOGIC_VECTOR(7 downto 0);
|
340 |
|
|
signal c33_dbg_addr_d : STD_LOGIC_VECTOR(7 downto 0);
|
341 |
|
|
|
342 |
|
|
signal dbg_wr : STD_LOGIC; --write not read
|
343 |
|
|
signal c25_dbg_wr : STD_LOGIC; --write not read
|
344 |
|
|
signal dbg_usb_wr : STD_LOGIC;
|
345 |
|
|
--signal dbg_full : STD_LOGIC; --write not read
|
346 |
|
|
signal dbg_almost_full : STD_LOGIC;
|
347 |
|
|
signal dbg_usedw : STD_LOGIC_VECTOR(12 DOWNTO 0);
|
348 |
|
|
signal dbg_usb_bd : STD_LOGIC_VECTOR(7 downto 0);
|
349 |
|
|
|
350 |
|
|
signal dbg_usb_mode_en : std_logic;
|
351 |
|
|
signal usb_mode_en : std_logic;
|
352 |
|
|
signal mem_usb_rd_n : std_logic;
|
353 |
|
|
signal mem_usb_wr : std_logic;
|
354 |
|
|
signal mem_usb_bd_o : STD_LOGIC_VECTOR(7 downto 0);
|
355 |
|
|
|
356 |
|
|
signal mem_idle : std_logic;
|
357 |
|
|
signal umem_addr : std_logic_vector(23 downto 0);
|
358 |
|
|
signal umem_do : std_logic_vector(15 downto 0);
|
359 |
|
|
signal umem_wr : std_logic;
|
360 |
|
|
signal umem_val : std_logic;
|
361 |
|
|
signal umem_ack : std_logic;
|
362 |
|
|
--signal umem_cmd : std_logic;
|
363 |
|
|
signal enable_4meg : std_logic;
|
364 |
|
|
signal enable_4meg_r : std_logic; --4 meg ena register
|
365 |
|
|
|
366 |
|
|
signal dongle_con_n : std_logic; -- set by device side/unset with IO write to enable/disalbe dongle memory
|
367 |
|
|
|
368 |
|
|
signal ldev_present_w : std_logic; --output from USB subsystem to show what command has been sent by PC
|
369 |
|
|
|
370 |
|
|
signal slot_sel : std_logic_vector(4 downto 0);
|
371 |
|
|
|
372 |
|
|
signal com_force : std_logic_vector(3 downto 0);
|
373 |
|
|
signal jmp_io_leds : std_logic_vector(7 downto 0);
|
374 |
|
|
|
375 |
|
|
signal c33_jmp_settings : std_logic_vector(7 downto 0);
|
376 |
|
|
signal jmp_settings : std_logic_vector(7 downto 0);
|
377 |
|
|
signal jmp_value : std_logic_vector(7 downto 0);
|
378 |
|
|
signal jmp_leds : std_logic_vector(7 downto 0);
|
379 |
|
|
signal jmp_cnt : std_logic_vector(7 downto 0);
|
380 |
|
|
|
381 |
|
|
constant dongle_ver : std_logic_vector(15 downto 0) := x"8623";
|
382 |
|
|
constant pcb_ver : std_logic_vector(15 downto 0) := x"0836"; -- proj. no and PCB ver in hexademical
|
383 |
|
|
--END USB signals
|
384 |
|
|
|
385 |
|
|
begin
|
386 |
|
|
|
387 |
|
|
--PSRAM static signals
|
388 |
|
|
ps_lsb_en <= '0';
|
389 |
|
|
ps_msb_en <= '0';
|
390 |
|
|
ps_addr_val <= '0'; --use async PSRAM access
|
391 |
|
|
ps_clk <= '0';
|
392 |
|
|
ps_confr_en <= '0';
|
393 |
|
|
|
394 |
|
|
ps_ram_en <= fl_ce_n_w when mode(2) = '1' else
|
395 |
|
|
'1';
|
396 |
|
|
|
397 |
|
|
--GPIO PINS START
|
398 |
|
|
fl_sts_en <= 'Z';
|
399 |
|
|
|
400 |
|
|
JMP_FETCH : process(sys_clk, resetn) --c33
|
401 |
|
|
begin
|
402 |
|
|
if resetn = '0' then
|
403 |
|
|
jmp_settings <= x"00";
|
404 |
|
|
jmp_cnt <= x"00";
|
405 |
|
|
jmp_leds <= x"FF";
|
406 |
|
|
elsif sys_clk'event and sys_clk = '1' then -- rising clock edge
|
407 |
|
|
jmp_cnt <= jmp_cnt + 1;
|
408 |
|
|
if jmp_cnt = x"FE" then
|
409 |
|
|
jmp_leds <= x"00"; --light leds
|
410 |
|
|
elsif jmp_cnt = x"00" then
|
411 |
|
|
jmp_settings <= jmp_value;
|
412 |
|
|
jmp_leds <= jmp_io_leds; --show last settings this is ok as leds are slow
|
413 |
|
|
end if;
|
414 |
|
|
|
415 |
|
|
end if;
|
416 |
|
|
end process JMP_FETCH;
|
417 |
|
|
|
418 |
|
|
hdr(14) <= jmp_leds(7);
|
419 |
|
|
hdr(12) <= jmp_leds(6);
|
420 |
|
|
hdr(10) <= jmp_leds(5);
|
421 |
|
|
hdr(8) <= jmp_leds(4);
|
422 |
|
|
hdr(6) <= jmp_leds(3);
|
423 |
|
|
hdr(4) <= jmp_leds(2);
|
424 |
|
|
hdr(2) <= jmp_leds(1);
|
425 |
|
|
hdr(0) <= jmp_leds(0);
|
426 |
|
|
|
427 |
|
|
jmp_value(0) <= hdr(1); --3,4
|
428 |
|
|
jmp_value(1) <= hdr(3); --5,6
|
429 |
|
|
jmp_value(2) <= hdr(5); --7,8
|
430 |
|
|
jmp_value(3) <= hdr(7); --9,10
|
431 |
|
|
jmp_value(4) <= hdr(9); --11,12
|
432 |
|
|
jmp_value(5) <= hdr(11);--13,14
|
433 |
|
|
jmp_value(6) <= hdr(13);
|
434 |
|
|
jmp_value(7) <= hdr(15);
|
435 |
|
|
|
436 |
|
|
--hdr(1) <= dongle_con_n; --commented out for firm rev 0x20
|
437 |
|
|
|
438 |
|
|
--hdr(1) <= fl_sts when resetn='1' else
|
439 |
|
|
-- '0';
|
440 |
|
|
|
441 |
|
|
--SETTING #0
|
442 |
|
|
--when jumper on then mem read and firmware read enabled else only firmware read
|
443 |
|
|
--hdr(0) <= '0'; --commented out for firm rev 0x20
|
444 |
|
|
lena_mem_r <= not jmp_settings(0); -- disabled if jumper is not on header pins 1-2
|
445 |
|
|
|
446 |
|
|
--SETTING #1
|
447 |
|
|
-- jumper on pins 5,6 then postcode only mode (no mem device)
|
448 |
|
|
--hdr(2) <= '0'; --create low pin for jumper pair 5-6 (this pin is 6 on J1 header) --commented out for firm rev 0x20
|
449 |
|
|
lena_reads <= jmp_settings(1) and mem_idle and(not dongle_con_n); -- disabled if jumper is on (jumper makes it a postcode only device) paired with hdr(2) pins 5,6 and when usb control is not accessing flash
|
450 |
|
|
|
451 |
|
|
--ldev_present_w is active low '1' menaing not present ;)
|
452 |
|
|
ldev_present <= '1' when lena_reads = '0' and ldev_present_w = '0' else --when jumper or IO disable and USB ena bit is default then look disconnected
|
453 |
|
|
'1' when ldev_present_w = '1' else --when dev present is removed from USB override jumper and LPC IO
|
454 |
|
|
'0';
|
455 |
|
|
|
456 |
|
|
--SETTING #2
|
457 |
|
|
-- when jumpers on pins 7,8| 9,10 | 11,12 > jmp_settings (2,3,4) (need inverting as on is '0')
|
458 |
|
|
-- off,off,off PC utility access enabled > 111
|
459 |
|
|
-- off,off,on UART on base address 0x3F8 > 110
|
460 |
|
|
-- off,on,off UART on base address 0x2F8 > 101
|
461 |
|
|
-- off,on,on UART on base address 0x3E8 > 100
|
462 |
|
|
-- on,on,on UART on base address 0x2E8 > 000
|
463 |
|
|
-- on,on,off pc side UART loop ena > 001
|
464 |
|
|
-- on,off,off post code capture mode enabled > 011
|
465 |
|
|
|
466 |
|
|
uart_addr <=x"03F8" when com_force(2 downto 0)="001" else
|
467 |
|
|
x"02F8" when com_force(2 downto 0)="010" else
|
468 |
|
|
x"03E8" when com_force(2 downto 0)="011" else
|
469 |
|
|
x"02E8" when com_force(2 downto 0)="100" else
|
470 |
|
|
x"03F8" when jmp_settings(4 downto 2)="011" else
|
471 |
|
|
x"02F8" when jmp_settings(4 downto 2)="101" else
|
472 |
|
|
x"03E8" when jmp_settings(4 downto 2)="001" else
|
473 |
|
|
x"02E8" when jmp_settings(4 downto 2)="000" else
|
474 |
|
|
x"0000"; --uart diabled as bit 3 is 0
|
475 |
|
|
|
476 |
|
|
slot_sel <= "01011" when com_force(2 downto 0)="010" or com_force(2 downto 0)="100" else
|
477 |
|
|
"01110" when com_force(2 downto 0)="001" or com_force(2 downto 0)="011" else
|
478 |
|
|
"01011" when jmp_settings(4 downto 2)="101" or jmp_settings(4 downto 2)="000" else
|
479 |
|
|
"01110" when jmp_settings(4 downto 2)="011" or jmp_settings(4 downto 2)="001" else
|
480 |
|
|
"00000";
|
481 |
|
|
|
482 |
|
|
uart_name<=x"C1" when com_force(2 downto 0)="001" else
|
483 |
|
|
x"C2" when com_force(2 downto 0)="010" else
|
484 |
|
|
x"C3" when com_force(2 downto 0)="011" else
|
485 |
|
|
x"C4" when com_force(2 downto 0)="100" else
|
486 |
|
|
x"C1" when jmp_settings(4 downto 2)="011" else
|
487 |
|
|
x"C2" when jmp_settings(4 downto 2)="101" else
|
488 |
|
|
x"C3" when jmp_settings(4 downto 2)="001" else
|
489 |
|
|
x"C4" when jmp_settings(4 downto 2)="000" else
|
490 |
|
|
x"00"; --uart diabled as bit 3 is 0
|
491 |
|
|
|
492 |
|
|
--SETTING #3
|
493 |
|
|
-- when jumper on pins 13, 14 mem window override to 4Meg mode (Used for intel atom boot) jmp_settings(5)
|
494 |
|
|
-- look at the LATCHled process enable_4meg signal
|
495 |
|
|
|
496 |
|
|
|
497 |
|
|
uart_ena.mode_en <= uart_addr(3); -- when bit3 is up in addr uart is enabled
|
498 |
|
|
|
499 |
|
|
dbg_usb_mode_en <= '1' when jmp_settings(4 downto 2)="110" else --post code logging
|
500 |
|
|
'0';
|
501 |
|
|
|
502 |
|
|
usb_mode_en <= '1' when jmp_settings(4 downto 2)="111" else --all off is pc mode
|
503 |
|
|
'0';
|
504 |
|
|
|
505 |
|
|
|
506 |
|
|
|
507 |
|
|
--GPIO PINS END
|
508 |
|
|
|
509 |
|
|
|
510 |
|
|
--LED SUBSYSTEM START
|
511 |
|
|
data_to_disp <= x"86" & lpc_debug(7 downto 0) when usb_mode_en = '1' and resetn = '1' else --x"C0DE"; -- ASSIGN data to be displayed (should be regitered)
|
512 |
|
|
uart_name&lpc_debug(7 downto 0) when uart_ena.mode_en='1' and resetn = '1' else
|
513 |
|
|
"000" & dbg_usedw when usb_mode_en = '0' and resetn = '1' else
|
514 |
|
|
dongle_ver; --show tx fifo state on leds when postcode capture mode
|
515 |
|
|
|
516 |
|
|
|
517 |
|
|
--########################################--
|
518 |
|
|
--VERSION CONSTATNS
|
519 |
|
|
--########################################--
|
520 |
|
|
led_red <= not enable_4meg;
|
521 |
|
|
led_green <= not mem_val;
|
522 |
|
|
|
523 |
|
|
LEDS : led_sys --toplevel for led system
|
524 |
|
|
generic map(
|
525 |
|
|
msn_hib => "10111111", -- not used "01111111",--8 --Most signif. of hi byte
|
526 |
|
|
lsn_hib => "10111111", -- not used "01111101",--6 --Least signif. of hi byte
|
527 |
|
|
msn_lob => "10111111", -- not used 0 --Most signif. of hi byte This is version code
|
528 |
|
|
--lsn_lob => "01001111"-- not used 3 --Least signif. of hi byte This is version code
|
529 |
|
|
--lsn_lob => "01100110"-- not used 4 --Least signif. of hi byte This is version code
|
530 |
|
|
--lsn_lob => "01101101"-- not used 5 --sync with dongle version const. Least signif. of hi byte This is version code
|
531 |
|
|
lsn_lob => "10111111" -- not used
|
532 |
|
|
)
|
533 |
|
|
port map(
|
534 |
|
|
clk => sys_clk, -- in std_logic;
|
535 |
|
|
reset_n => resetn, -- in std_logic;
|
536 |
|
|
led_data_i => data_to_disp, -- in std_logic_vector(15 downto 0); --binary data in
|
537 |
|
|
seg_out => seg_out, -- out std_logic_vector(7 downto 0); --one segment out
|
538 |
|
|
sel_out => scn_seg_w -- out std_logic_vector(3 downto 0) --segment scanner with one bit low
|
539 |
|
|
);
|
540 |
|
|
|
541 |
|
|
scn_seg <= scn_seg_w;
|
542 |
|
|
scn_seg2 <= scn_seg_w;
|
543 |
|
|
|
544 |
|
|
--LED SUBSYSTEM END
|
545 |
|
|
|
546 |
|
|
|
547 |
|
|
--MAIN DATAPATH CONNECTIONS
|
548 |
|
|
--LPC bus logic
|
549 |
|
|
lad_i <= lad;
|
550 |
|
|
lad <= lad_o when lad_oe = '1' else(others => 'Z');
|
551 |
|
|
|
552 |
|
|
--END LPC bus logic
|
553 |
|
|
|
554 |
|
|
LPCBUS : lpc_iow
|
555 |
|
|
port map(
|
556 |
|
|
--system signals
|
557 |
|
|
lreset_n => lreset_n, -- in std_logic;
|
558 |
|
|
lclk => lclk, -- in std_logic;
|
559 |
|
|
lena_mem_r => lena_mem_r, --: in std_logic; --enable full adress range covering memory read block
|
560 |
|
|
lena_reads => lena_reads, -- : in std_logic; --enable read capabilities, : in std_logic; --enable read capabilities
|
561 |
|
|
uart_addr => uart_addr,
|
562 |
|
|
--LPC bus from host
|
563 |
|
|
lad_i => lad_i, -- in std_logic_vector(3 downto 0);
|
564 |
|
|
lad_o => lad_o, -- out std_logic_vector(3 downto 0);
|
565 |
|
|
lad_oe => lad_oe, -- out std_logic;
|
566 |
|
|
lframe_n => lframe_n, -- in std_logic;
|
567 |
|
|
--memory interface
|
568 |
|
|
lpc_addr => lpc_addr, -- out std_logic_vector(23 downto 0); --shared address
|
569 |
|
|
lpc_wr => lpc_wr, -- out std_logic; --shared write not read
|
570 |
|
|
lpc_io => lpc_io, --: out std_logic; --io access not mem access select
|
571 |
|
|
lpc_uart => lpc_uart,
|
572 |
|
|
lpc_gpioled=> lpc_gpioled, --: out std_logic; --gpio led cycle coming
|
573 |
|
|
lpc_data_i => lpc_data_i, -- in std_logic_vector(7 downto 0);
|
574 |
|
|
lpc_data_o => lpc_data_o, -- out std_logic_vector(7 downto 0);
|
575 |
|
|
lpc_val => lpc_val, -- out std_logic;
|
576 |
|
|
lpc_ack => lpc_ack -- in std_logic
|
577 |
|
|
);
|
578 |
|
|
|
579 |
|
|
--memory data bus logic
|
580 |
|
|
mem_addr <= mode(1 downto 0) & "11" & lpc_addr(19 downto 0) when c25_lpc_val = '1' and enable_4meg = '0' else --use mode bist
|
581 |
|
|
mode(1 downto 0) & lpc_addr(21 downto 0) when c25_lpc_val = '1' and enable_4meg = '1' else --use mode bist
|
582 |
|
|
mode(1 downto 0) & umem_addr(21 downto 0) when umem_val = '1' else --use mode bist
|
583 |
|
|
(others => 'Z');
|
584 |
|
|
|
585 |
|
|
mem_di <=(others => 'Z') when c25_lpc_val = '1' else
|
586 |
|
|
umem_do when umem_val = '1' else(others => 'Z');
|
587 |
|
|
|
588 |
|
|
mem_wr <= c25_lpc_wr when c25_lpc_val = '1' and c25_lpc_wr = '0' else --pass read olny
|
589 |
|
|
umem_wr when umem_val = '1' else
|
590 |
|
|
'0';
|
591 |
|
|
|
592 |
|
|
mem_val <= (c25_lpc_val and not c25_lpc_io) or umem_val;
|
593 |
|
|
|
594 |
|
|
umem_ack <= mem_ack when umem_val = '1' else
|
595 |
|
|
'0';
|
596 |
|
|
|
597 |
|
|
uart_vci_in.lpc_val <= c25_lpc_val when c25_lpc_uart='1' else
|
598 |
|
|
'0';
|
599 |
|
|
uart_vci_in.lpc_wr <= c25_lpc_wr; --can be connected as val is needed to do the cycle
|
600 |
|
|
|
601 |
|
|
uart_vci_in.lpc_addr <= x"000"&'0'&lpc_addr(2 downto 0); --these are stable when val is up so sync needed
|
602 |
|
|
uart_vci_in.lpc_data_o <= lpc_data_o; --these are stable when val is up so sync needed
|
603 |
|
|
|
604 |
|
|
lpc_data_i <= mem_do(7 downto 0) when lpc_addr(0) = '0' and lpc_io='0' else
|
605 |
|
|
mem_do(15 downto 8) when lpc_io='0' else
|
606 |
|
|
c33_jmp_settings when lpc_gpioled='1' and lpc_io='1' else -- IO read to 0x84 (jumper status)
|
607 |
|
|
uart_vci_out.lpc_data_i when lpc_uart='1' and lpc_io='1' else --IO read data for UART
|
608 |
|
|
(others=>'0');
|
609 |
|
|
|
610 |
|
|
lpc_ack <= c33_mem_ack when lpc_val = '1' and lpc_wr = '0' and lpc_io='0' else --all mem cycles
|
611 |
|
|
c33_uart_ack when lpc_val = '1' and lpc_io='1' and lpc_uart='1' else --we have UART bound IO cycle
|
612 |
|
|
c33_led_ack when lpc_val = '1' and lpc_io='1' and lpc_gpioled='1' else --we have IO 0x84 acking bound IO cycle this needs no wait so the ack can be looped back
|
613 |
|
|
(not dbg_almost_full) when lpc_val = '1' and lpc_wr = '1' and lpc_io='1' else --debug write to 80 and 88 IO cycle
|
614 |
|
|
'0';
|
615 |
|
|
|
616 |
|
|
SYNC1 : process(lclk, lreset_n) --c33
|
617 |
|
|
begin
|
618 |
|
|
if lclk'event and lclk = '1' then -- rising clock edge
|
619 |
|
|
c33_mem_ack <= mem_ack;
|
620 |
|
|
c33_uart_ack <= uart_vci_out.lpc_ack;
|
621 |
|
|
c33_led_ack<= lpc_val; --loop val back to ack for leds
|
622 |
|
|
end if;
|
623 |
|
|
end process SYNC1;
|
624 |
|
|
|
625 |
|
|
dbg_data <= lpc_debug(7 downto 0);
|
626 |
|
|
SYNC2 : process(sys_clk) --c25
|
627 |
|
|
begin
|
628 |
|
|
if sys_clk'event and sys_clk = '1' then -- rising clock edge
|
629 |
|
|
c25_lpc_val <= lpc_val; --syncro two clock domains
|
630 |
|
|
c25_lpc_io <= lpc_io;
|
631 |
|
|
c25_lpc_uart <= lpc_uart;
|
632 |
|
|
c25_lpc_uart <= lpc_uart;
|
633 |
|
|
c25_lpc_wr <= lpc_wr; --syncro two clock domains
|
634 |
|
|
c25_dbg_wr <= c33_lpc_wr; --delayed write
|
635 |
|
|
c25_dbg_addr_d <= c33_dbg_addr_d; --syncro two clock domains
|
636 |
|
|
if uart_ena.mode_en='0' and usb_mode_en = '0' and c25_dbg_addr_d = x"80" and c25_lpc_io='1' then --don't fill fifo in regular mode
|
637 |
|
|
dbg_wr <= c25_lpc_wr; --c33_lpc_wr_wait;--c33_lpc_wr_wait;
|
638 |
|
|
else
|
639 |
|
|
dbg_wr <= '0'; --write never rises when usb_mode_en = 1
|
640 |
|
|
end if;
|
641 |
|
|
end if;
|
642 |
|
|
end process SYNC2;
|
643 |
|
|
|
644 |
|
|
LATCHled : process(lclk, lreset_n) --c33
|
645 |
|
|
begin
|
646 |
|
|
if lreset_n = '0' then
|
647 |
|
|
lpc_debug(7 downto 0) <=(others => '0');
|
648 |
|
|
c33_dbg_addr_d <=(others => '0');
|
649 |
|
|
jmp_io_leds<=(others => '1');
|
650 |
|
|
com_force<=(others =>'0');
|
651 |
|
|
enable_4meg <= '0';
|
652 |
|
|
enable_4meg_r <= '0';
|
653 |
|
|
c33_lpc_wr <= '0';
|
654 |
|
|
dongle_con_n <= '0'; -- pin 3 in GPIO make it toggleable
|
655 |
|
|
elsif lclk'event and lclk = '1' then -- rising clock edge
|
656 |
|
|
|
657 |
|
|
|
658 |
|
|
if lpc_val = '1' and lpc_io='1' and lpc_gpioled='1' then
|
659 |
|
|
jmp_io_leds<=not lpc_data_o;
|
660 |
|
|
end if;
|
661 |
|
|
c33_jmp_settings<=not jmp_settings; --invert for better understanding jumper on is
|
662 |
|
|
c33_lpc_wr <= lpc_wr;
|
663 |
|
|
if c33_lpc_wr = '0' and lpc_wr = '1' and lpc_io='1' then
|
664 |
|
|
c33_dbg_addr_d <= lpc_addr(7 downto 0);
|
665 |
|
|
if lpc_addr(7 downto 0) = x"80" then
|
666 |
|
|
lpc_debug(7 downto 0) <= lpc_data_o;
|
667 |
|
|
end if;
|
668 |
|
|
|
669 |
|
|
if lpc_addr(7 downto 0) = x"88" and lpc_data_o = x"F4" then --Flash 4 Mega enable (LSN is first MSN is second)
|
670 |
|
|
enable_4meg_r <= '1';
|
671 |
|
|
elsif lpc_addr(7 downto 0) = x"88" and lpc_data_o = x"F1" then --Flash 1 Mega enalbe
|
672 |
|
|
enable_4meg_r <= '0';
|
673 |
|
|
elsif lpc_addr(7 downto 0) = x"88" and lpc_data_o = x"D1" then --Set Dongle not attached signal
|
674 |
|
|
dongle_con_n <= '1'; -- pin 3 in GPIO make it 1
|
675 |
|
|
elsif lpc_addr(7 downto 0) = x"88" and lpc_data_o = x"D0" then --Set Dongle attached signal
|
676 |
|
|
dongle_con_n <= '0'; -- pin 3 in GPIO make it 1
|
677 |
|
|
elsif lpc_addr(7 downto 0) = x"88" and lpc_data_o = x"C1" then --Set Dongle attached signal
|
678 |
|
|
com_force<=x"1";
|
679 |
|
|
elsif lpc_addr(7 downto 0) = x"88" and lpc_data_o = x"C2" then --Set Dongle attached signal
|
680 |
|
|
com_force<=x"2";
|
681 |
|
|
elsif lpc_addr(7 downto 0) = x"88" and lpc_data_o = x"C3" then --Set Dongle attached signal
|
682 |
|
|
com_force<=x"3";
|
683 |
|
|
elsif lpc_addr(7 downto 0) = x"88" and lpc_data_o = x"C4" then --Set Dongle attached signal
|
684 |
|
|
com_force<=x"4";
|
685 |
|
|
end if;
|
686 |
|
|
end if;
|
687 |
|
|
if jmp_settings(5)='0' then --0 is jumper on, meaning force 4 M mode
|
688 |
|
|
enable_4meg<='1';
|
689 |
|
|
else
|
690 |
|
|
enable_4meg<=enable_4meg_r;
|
691 |
|
|
end if;
|
692 |
|
|
|
693 |
|
|
end if;
|
694 |
|
|
end process LATCHled;
|
695 |
|
|
|
696 |
|
|
--END memory data bus logic
|
697 |
|
|
fl_ce_n <= fl_ce_n_w when mode(2) = '0' else
|
698 |
|
|
'1';
|
699 |
|
|
fl_oe_n <= fl_oe_n_w;
|
700 |
|
|
fl_we_n <= fl_we_n_w;
|
701 |
|
|
|
702 |
|
|
FLASH : flash_if
|
703 |
|
|
port map(
|
704 |
|
|
clk => sys_clk, -- in std_logic;
|
705 |
|
|
reset_n => resetn, -- in std_logic;
|
706 |
|
|
mode => mode, -- : in std_logic_vector(2 downto 0); --sel upper addr bits
|
707 |
|
|
--flash Bus
|
708 |
|
|
fl_addr => fl_addr, -- out std_logic_vector(23 downto 0);
|
709 |
|
|
fl_ce_n => fl_ce_n_w, -- out std_logic; --chip select
|
710 |
|
|
fl_oe_n => fl_oe_n_w, -- buffer std_logic; --output enable for flash
|
711 |
|
|
fl_we_n => fl_we_n_w, -- out std_logic; --write enable
|
712 |
|
|
fl_data => fl_data, -- inout std_logic_vector(15 downto 0);
|
713 |
|
|
fl_rp_n => fl_rp_n, -- out std_logic; --reset signal
|
714 |
|
|
--fl_byte_n => fl_byte_n, -- out std_logic; --hold in byte mode
|
715 |
|
|
|
716 |
|
|
fl_sts => fl_sts, -- in std_logic; --status signal
|
717 |
|
|
-- mem Bus
|
718 |
|
|
mem_addr => mem_addr, -- in std_logic_vector(23 downto 0);
|
719 |
|
|
mem_do => mem_do, -- out std_logic_vector(15 downto 0);
|
720 |
|
|
mem_di => mem_di, -- in std_logic_vector(15 downto 0);
|
721 |
|
|
|
722 |
|
|
mem_wr => mem_wr, -- in std_logic; --write not read signal
|
723 |
|
|
mem_val => mem_val, -- in std_logic;
|
724 |
|
|
mem_ack => mem_ack -- out std_logic
|
725 |
|
|
);
|
726 |
|
|
|
727 |
|
|
USB : usb2mem
|
728 |
|
|
port map(
|
729 |
|
|
clk25 => sys_clk, -- in std_logic;
|
730 |
|
|
reset_n => resetn, -- in std_logic;
|
731 |
|
|
dongle_ver => dongle_ver,
|
732 |
|
|
pcb_ver => pcb_ver, --: in std_logic_vector(15 downto 0);
|
733 |
|
|
mode => mode, -- : in std_logic_vector(2 downto 0); --sel upper addr bits
|
734 |
|
|
usb_buf_en => buf_oe_n, --: out std_logic;
|
735 |
|
|
dev_present_n => ldev_present_w, --: out std_logic;
|
736 |
|
|
-- mem Bus
|
737 |
|
|
mem_busy_n => fl_sts, --check flash status before starting new command on flash
|
738 |
|
|
mem_idle => mem_idle,
|
739 |
|
|
mem_addr => umem_addr, -- out std_logic_vector(23 downto 0);
|
740 |
|
|
mem_do => umem_do, -- out std_logic_vector(15 downto 0);
|
741 |
|
|
mem_di => mem_do, -- in std_logic_vector(15 downto 0); --from flash
|
742 |
|
|
mem_wr => umem_wr, -- out std_logic;
|
743 |
|
|
mem_val => umem_val, -- out std_logic;
|
744 |
|
|
mem_ack => umem_ack, -- in std_logic; --from flash
|
745 |
|
|
mem_cmd => open, -- out std_logic;
|
746 |
|
|
-- USB port
|
747 |
|
|
usb_mode_en => usb_mode_en,
|
748 |
|
|
usb_rd_n => mem_usb_rd_n, -- out std_logic; -- enables out data if low (next byte detected by edge / in usb chip)
|
749 |
|
|
usb_wr => mem_usb_wr, -- out std_logic; -- write performed on edge \ of signal
|
750 |
|
|
usb_txe_n => usb_txe_n, -- in std_logic; -- tx fifo empty (redy for new data if low)
|
751 |
|
|
usb_rxf_n => usb_rxf_n, -- in std_logic; -- rx fifo empty (data redy if low)
|
752 |
|
|
usb_bd_o => mem_usb_bd_o,
|
753 |
|
|
usb_bd => usb_bd -- in std_logic_vector(7 downto 0) --bus data
|
754 |
|
|
);
|
755 |
|
|
|
756 |
|
|
DBG : pc_serializer
|
757 |
|
|
port map( --system signals
|
758 |
|
|
sys_clk => sys_clk, -- in STD_LOGIC;
|
759 |
|
|
resetn => resetn, -- in STD_LOGIC;
|
760 |
|
|
--postcode data port
|
761 |
|
|
dbg_data => dbg_data, -- in STD_LOGIC_VECTOR (7 downto 0);
|
762 |
|
|
dbg_wr => dbg_wr, -- in STD_LOGIC; --write not read
|
763 |
|
|
dbg_full => open, --: out STD_LOGIC; --write not read
|
764 |
|
|
dbg_almost_full => dbg_almost_full,
|
765 |
|
|
dbg_usedw => dbg_usedw,
|
766 |
|
|
|
767 |
|
|
--debug USB port
|
768 |
|
|
dbg_usb_mode_en => dbg_usb_mode_en, -- in std_logic; -- enable this debug mode
|
769 |
|
|
dbg_usb_wr => dbg_usb_wr, -- out std_logic; -- write performed on edge \ of signal
|
770 |
|
|
dbg_usb_txe_n => usb_txe_n, -- in std_logic; -- tx fifo not full (redy for new data if low)
|
771 |
|
|
dbg_usb_bd => dbg_usb_bd -- out std_logic_vector(7 downto 0) --bus data
|
772 |
|
|
);
|
773 |
|
|
|
774 |
|
|
UART : serial_usb
|
775 |
|
|
port map (
|
776 |
|
|
clock => sys_clk, -- in std_logic;
|
777 |
|
|
reset_n => resetn, -- in std_logic;
|
778 |
|
|
--VCI Port
|
779 |
|
|
vci_in => uart_vci_in, -- in vci_slave_in;
|
780 |
|
|
vci_out => uart_vci_out, -- out vci_slave_out;
|
781 |
|
|
--FTDI fifo interface
|
782 |
|
|
uart_ena => uart_ena, -- in usbser_ctrl;
|
783 |
|
|
fifo_out => uart_fifo_out, -- out usb_out;
|
784 |
|
|
fifo_in => uart_fifo_in -- in usb_in
|
785 |
|
|
);
|
786 |
|
|
|
787 |
|
|
usb_rd_n <= mem_usb_rd_n when usb_mode_en='1' else --usb to mem reads fom fifo
|
788 |
|
|
uart_fifo_out.rx_oe_n when uart_ena.mode_en='1' else --UART read
|
789 |
|
|
'1'; --keep high
|
790 |
|
|
|
791 |
|
|
usb_wr <= uart_fifo_out.tx_wr when uart_ena.mode_en='1' else
|
792 |
|
|
mem_usb_wr when usb_mode_en='1' else
|
793 |
|
|
dbg_usb_wr when dbg_usb_mode_en='1' else
|
794 |
|
|
'0';
|
795 |
|
|
|
796 |
|
|
usb_bd <= uart_fifo_out.txdata when uart_ena.mode_en='1' and uart_fifo_out.tx_wr='1' else
|
797 |
|
|
dbg_usb_bd when dbg_usb_mode_en='1' and dbg_usb_wr='1' else
|
798 |
|
|
mem_usb_bd_o when usb_mode_en='1' and mem_usb_wr='1' else
|
799 |
|
|
(others=>'Z');
|
800 |
|
|
|
801 |
|
|
|
802 |
|
|
uart_fifo_in.rxdata <= usb_bd; --this can be in most of the time
|
803 |
|
|
uart_fifo_in.rx_full_n <= usb_rxf_n; --if low there is data
|
804 |
|
|
uart_fifo_in.tx_empty_n <= usb_txe_n; --if low data can be transmitted
|
805 |
|
|
|
806 |
|
|
|
807 |
|
|
irqgen : serirq
|
808 |
|
|
port map (
|
809 |
|
|
clock => lclk, -- in std_logic;
|
810 |
|
|
reset_n => lreset_n, -- in std_logic;
|
811 |
|
|
slot_sel => slot_sel, -- in std_logic_vector(4 downto 0); --clk no of IRQ defined in Ser irq for PCI systems spec.
|
812 |
|
|
serirq => lserirq, -- inout std_logic;
|
813 |
|
|
irq => uart_vci_out.lpc_irq -- in std_logic;
|
814 |
|
|
);
|
815 |
|
|
|
816 |
|
|
--END MAIN DATAPATH CONNECTIONS
|
817 |
|
|
|
818 |
|
|
end rtl;
|
819 |
|
|
|
820 |
|
|
|
821 |
|
|
|