1 |
2 |
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 |
|
|
|
26 |
|
|
-- Coding for seg_out(7:0)
|
27 |
|
|
--
|
28 |
|
|
-- bit 0,A
|
29 |
|
|
-- ----------
|
30 |
|
|
-- | |
|
31 |
|
|
-- | |
|
32 |
|
|
-- 5,F| | 1,B
|
33 |
|
|
-- | 6,G |
|
34 |
|
|
-- ----------
|
35 |
|
|
-- | |
|
36 |
|
|
-- | |
|
37 |
|
|
-- 4,E| | 2,C
|
38 |
|
|
-- | 3,D |
|
39 |
|
|
-- ----------
|
40 |
|
|
-- # 7,H
|
41 |
|
|
|
42 |
|
|
-- Revision history
|
43 |
|
|
--
|
44 |
|
|
-- Version 1.01
|
45 |
|
|
-- 15 oct 2006 version code 86 01 jyrit
|
46 |
|
|
-- Added IO write to address 0x0088 with commands F1 and F4 to
|
47 |
|
|
-- enable switching dongle to 4Meg mode for external reads
|
48 |
|
|
-- Changed USB interface to address all 4 Meg on any mode jumper configuration
|
49 |
|
|
--
|
50 |
|
|
-- Version 1.02
|
51 |
|
|
-- 04 dec 2006 version code 86 02 jyrit
|
52 |
|
|
-- Added listen only mode for mode pin configuration "00" to enable post code
|
53 |
|
|
-- spy mode (does not respond to external reads).
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
library ieee;
|
57 |
|
|
use ieee.std_logic_1164.all;
|
58 |
|
|
use IEEE.std_logic_unsigned.all;
|
59 |
|
|
use IEEE.std_logic_arith.all;
|
60 |
|
|
|
61 |
|
|
entity design_top is
|
62 |
|
|
port (
|
63 |
|
|
--system signals
|
64 |
|
|
sys_clk : in std_logic; --25 MHz clk
|
65 |
|
|
resetn : in std_logic;
|
66 |
26 |
nuubik |
hdr : inout std_logic_vector(9 downto 0);
|
67 |
17 |
nuubik |
--alt_clk : out std_logic;
|
68 |
2 |
nuubik |
mode : in std_logic_vector(1 downto 0); --sel upper addr bits
|
69 |
|
|
--lpc slave interf
|
70 |
|
|
lad : inout std_logic_vector(3 downto 0);
|
71 |
|
|
lframe_n : in std_logic;
|
72 |
|
|
lreset_n : in std_logic;
|
73 |
|
|
lclk : in std_logic;
|
74 |
|
|
--led system
|
75 |
|
|
seg_out : out std_logic_vector(7 downto 0);
|
76 |
|
|
scn_seg : out std_logic_vector(3 downto 0);
|
77 |
|
|
led_green : out std_logic;
|
78 |
|
|
led_red : out std_logic;
|
79 |
|
|
--flash interface
|
80 |
|
|
fl_addr : out std_logic_vector(23 downto 0);
|
81 |
|
|
fl_ce_n : out std_logic; --chip select
|
82 |
|
|
fl_oe_n : out std_logic; --output enable for flash
|
83 |
|
|
fl_we_n : out std_logic; --write enable
|
84 |
|
|
fl_data : inout std_logic_vector(15 downto 0);
|
85 |
|
|
fl_rp_n : out std_logic; --reset signal
|
86 |
|
|
fl_sts : in std_logic; --status signal
|
87 |
35 |
nuubik |
fl_sts_en : out std_logic; --enable status signal wiht highZ out
|
88 |
2 |
nuubik |
--USB parallel interface
|
89 |
|
|
usb_rd_n : inout std_logic; -- enables out data if low (next byte detected by edge / in usb chip)
|
90 |
|
|
usb_wr : inout std_logic; -- write performed on edge \ of signal
|
91 |
|
|
usb_txe_n : in std_logic; -- transmit enable (redy for new data if low)
|
92 |
|
|
usb_rxf_n : in std_logic; -- rx fifo has data if low
|
93 |
|
|
usb_bd : inout std_logic_vector(7 downto 0) --bus data
|
94 |
|
|
);
|
95 |
|
|
end design_top;
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
architecture rtl of design_top is
|
100 |
|
|
|
101 |
|
|
component led_sys --toplevel for led system
|
102 |
|
|
generic(
|
103 |
|
|
msn_hib : std_logic_vector(7 downto 0); --Most signif. of hi byte
|
104 |
|
|
lsn_hib : std_logic_vector(7 downto 0); --Least signif. of hi byte
|
105 |
|
|
msn_lob : std_logic_vector(7 downto 0); --Most signif. of hi byte
|
106 |
|
|
lsn_lob : std_logic_vector(7 downto 0) --Least signif. of hi byte
|
107 |
|
|
);
|
108 |
|
|
port (
|
109 |
|
|
clk : in std_logic;
|
110 |
|
|
reset_n : in std_logic;
|
111 |
|
|
led_data_i : in std_logic_vector(15 downto 0); --binary data in
|
112 |
|
|
seg_out : out std_logic_vector(7 downto 0); --one segment out
|
113 |
|
|
sel_out : out std_logic_vector(3 downto 0) --segment scanner with one bit low
|
114 |
|
|
);
|
115 |
|
|
end component;
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
component lpc_iow
|
119 |
|
|
port (
|
120 |
|
|
--system signals
|
121 |
|
|
lreset_n : in std_logic;
|
122 |
|
|
lclk : in std_logic;
|
123 |
17 |
nuubik |
lena_mem_r : in std_logic; --enable full adress range covering memory read block
|
124 |
|
|
lena_reads : in std_logic; --enable read capabilities
|
125 |
2 |
nuubik |
--LPC bus from host
|
126 |
|
|
lad_i : in std_logic_vector(3 downto 0);
|
127 |
|
|
lad_o : out std_logic_vector(3 downto 0);
|
128 |
|
|
lad_oe : out std_logic;
|
129 |
|
|
lframe_n : in std_logic;
|
130 |
|
|
--memory interface
|
131 |
|
|
lpc_addr : out std_logic_vector(23 downto 0); --shared address
|
132 |
|
|
lpc_wr : out std_logic; --shared write not read
|
133 |
|
|
lpc_data_i : in std_logic_vector(7 downto 0);
|
134 |
|
|
lpc_data_o : out std_logic_vector(7 downto 0);
|
135 |
|
|
lpc_val : out std_logic;
|
136 |
|
|
lpc_ack : in std_logic
|
137 |
|
|
);
|
138 |
|
|
end component;
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
component flash_if
|
142 |
|
|
port (
|
143 |
|
|
clk : in std_logic;
|
144 |
|
|
reset_n : in std_logic;
|
145 |
|
|
--flash Bus
|
146 |
|
|
fl_addr : out std_logic_vector(23 downto 0);
|
147 |
|
|
fl_ce_n : out std_logic; --chip select
|
148 |
|
|
fl_oe_n : out std_logic; --output enable for flash
|
149 |
|
|
fl_we_n : out std_logic; --write enable
|
150 |
|
|
fl_data : inout std_logic_vector(15 downto 0);
|
151 |
|
|
fl_rp_n : out std_logic; --reset signal
|
152 |
|
|
fl_byte_n : out std_logic; --hold in byte mode
|
153 |
|
|
fl_sts : in std_logic; --status signal
|
154 |
|
|
-- mem Bus
|
155 |
|
|
mem_addr : in std_logic_vector(23 downto 0);
|
156 |
|
|
mem_do : out std_logic_vector(15 downto 0);
|
157 |
26 |
nuubik |
mem_di : in std_logic_vector(15 downto 0);
|
158 |
2 |
nuubik |
mem_wr : in std_logic; --write not read signal
|
159 |
|
|
mem_val : in std_logic;
|
160 |
|
|
mem_ack : out std_logic
|
161 |
|
|
);
|
162 |
|
|
end component;
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
component usb2mem
|
166 |
|
|
port (
|
167 |
|
|
clk25 : in std_logic;
|
168 |
|
|
reset_n : in std_logic;
|
169 |
26 |
nuubik |
dongle_ver: in std_logic_vector(15 downto 0);
|
170 |
2 |
nuubik |
-- mem Bus
|
171 |
26 |
nuubik |
mem_busy_n: in std_logic;
|
172 |
|
|
mem_idle : out std_logic; -- '1' if controller is idle (flash is safe for LPC reads)
|
173 |
2 |
nuubik |
mem_addr : out std_logic_vector(23 downto 0);
|
174 |
|
|
mem_do : out std_logic_vector(15 downto 0);
|
175 |
|
|
mem_di : in std_logic_vector(15 downto 0);
|
176 |
|
|
mem_wr : out std_logic;
|
177 |
|
|
mem_val : out std_logic;
|
178 |
|
|
mem_ack : in std_logic;
|
179 |
|
|
mem_cmd : out std_logic;
|
180 |
|
|
-- USB port
|
181 |
26 |
nuubik |
usb_mode_en: in std_logic; -- enable this block
|
182 |
2 |
nuubik |
usb_rd_n : out std_logic; -- enables out data if low (next byte detected by edge / in usb chip)
|
183 |
|
|
usb_wr : out std_logic; -- write performed on edge \ of signal
|
184 |
|
|
usb_txe_n : in std_logic; -- tx fifo empty (redy for new data if low)
|
185 |
|
|
usb_rxf_n : in std_logic; -- rx fifo empty (data redy if low)
|
186 |
|
|
usb_bd : inout std_logic_vector(7 downto 0) --bus data
|
187 |
|
|
);
|
188 |
|
|
end component;
|
189 |
|
|
|
190 |
26 |
nuubik |
component pc_serializer
|
191 |
|
|
Port ( --system signals
|
192 |
|
|
sys_clk : in STD_LOGIC;
|
193 |
|
|
resetn : in STD_LOGIC;
|
194 |
|
|
--postcode data port
|
195 |
|
|
dbg_data : in STD_LOGIC_VECTOR (7 downto 0);
|
196 |
|
|
dbg_wr : in STD_LOGIC; --write not read
|
197 |
|
|
dbg_full : out STD_LOGIC; --write not read
|
198 |
|
|
dbg_almost_full : out STD_LOGIC;
|
199 |
|
|
dbg_usedw : out STD_LOGIC_VECTOR (12 DOWNTO 0);
|
200 |
|
|
--debug USB port
|
201 |
|
|
dbg_usb_mode_en: in std_logic; -- enable this debug mode
|
202 |
|
|
dbg_usb_wr : out std_logic; -- write performed on edge \ of signal
|
203 |
|
|
dbg_usb_txe_n : in std_logic; -- tx fifo not full (redy for new data if low)
|
204 |
|
|
dbg_usb_bd : inout std_logic_vector(7 downto 0) --bus data
|
205 |
|
|
);
|
206 |
|
|
end component;
|
207 |
2 |
nuubik |
|
208 |
|
|
|
209 |
|
|
--LED signals
|
210 |
|
|
signal data_to_disp : std_logic_vector(15 downto 0);
|
211 |
|
|
--END LED SIGNALS
|
212 |
|
|
|
213 |
|
|
--lpc signals
|
214 |
|
|
signal lad_i : std_logic_vector(3 downto 0);
|
215 |
|
|
signal lad_o : std_logic_vector(3 downto 0);
|
216 |
|
|
signal lad_oe : std_logic;
|
217 |
|
|
|
218 |
|
|
signal lpc_debug : std_logic_vector(31 downto 0);
|
219 |
26 |
nuubik |
signal lpc_debug_cnt : std_logic_vector(15 downto 0);
|
220 |
2 |
nuubik |
signal lpc_addr : std_logic_vector(23 downto 0); --shared address
|
221 |
|
|
signal lpc_data_o : std_logic_vector(7 downto 0);
|
222 |
|
|
signal lpc_data_i : std_logic_vector(7 downto 0);
|
223 |
|
|
signal lpc_wr : std_logic; --shared write not read
|
224 |
|
|
signal lpc_ack : std_logic;
|
225 |
|
|
signal lpc_val : std_logic;
|
226 |
17 |
nuubik |
signal lena_mem_r : std_logic; --enable full adress range covering memory read block
|
227 |
|
|
signal lena_reads : std_logic; --enable/disables all read capabilty to make the device post code capturer
|
228 |
2 |
nuubik |
|
229 |
|
|
signal c25_lpc_val : std_logic;
|
230 |
|
|
signal c25_lpc_wr : std_logic; --shared write not read
|
231 |
26 |
nuubik |
signal c25_lpc_wr_long : std_logic; --for led debug data latching
|
232 |
|
|
|
233 |
|
|
signal c33_lpc_wr_long : std_logic; --for led debug data latching
|
234 |
2 |
nuubik |
signal c33_lpc_wr : std_logic; --for led debug data latching
|
235 |
26 |
nuubik |
signal c33_lpc_wr_wait: std_logic; --for led debug data latching
|
236 |
|
|
signal c33_lpc_wr_waitd: std_logic; --for led debug data latching
|
237 |
|
|
signal c33_wr_cnt : std_logic_vector(23 downto 0); --for led debug data latching
|
238 |
2 |
nuubik |
|
239 |
26 |
nuubik |
|
240 |
2 |
nuubik |
--End lpc signals
|
241 |
|
|
|
242 |
|
|
--Flash signals
|
243 |
|
|
signal mem_addr : std_logic_vector(23 downto 0);
|
244 |
|
|
signal mem_do : std_logic_vector(15 downto 0);
|
245 |
|
|
signal mem_di : std_logic_vector(15 downto 0);
|
246 |
|
|
signal mem_wr : std_logic; --write not read signal
|
247 |
|
|
signal mem_val : std_logic;
|
248 |
|
|
signal mem_ack : std_logic;
|
249 |
|
|
|
250 |
|
|
signal c33_mem_ack : std_logic; --sync signal
|
251 |
|
|
|
252 |
|
|
|
253 |
|
|
|
254 |
|
|
signal fl_ce_n_w : std_logic; --chip select
|
255 |
|
|
signal fl_oe_n_w : std_logic; --output enable for flash
|
256 |
|
|
|
257 |
|
|
--END flash signals
|
258 |
|
|
|
259 |
|
|
--USB signals
|
260 |
26 |
nuubik |
signal dbg_data : STD_LOGIC_VECTOR (7 downto 0);
|
261 |
|
|
signal c25_dbg_addr_d : STD_LOGIC_VECTOR (7 downto 0);
|
262 |
|
|
signal c33_dbg_addr_d : STD_LOGIC_VECTOR (7 downto 0);
|
263 |
|
|
|
264 |
|
|
signal dbg_wr : STD_LOGIC; --write not read
|
265 |
|
|
signal dbg_full : STD_LOGIC; --write not read
|
266 |
|
|
signal dbg_almost_full : STD_LOGIC;
|
267 |
|
|
signal dbg_usedw : STD_LOGIC_VECTOR (12 DOWNTO 0);
|
268 |
|
|
|
269 |
|
|
signal dbg_usb_mode_en : std_logic;
|
270 |
|
|
signal usb_mode_en : std_logic;
|
271 |
|
|
signal mem_idle : std_logic;
|
272 |
2 |
nuubik |
signal umem_addr : std_logic_vector(23 downto 0);
|
273 |
|
|
signal umem_do : std_logic_vector(15 downto 0);
|
274 |
|
|
signal umem_wr : std_logic;
|
275 |
|
|
signal umem_val : std_logic;
|
276 |
|
|
signal umem_ack : std_logic;
|
277 |
|
|
signal umem_cmd : std_logic;
|
278 |
|
|
signal enable_4meg: std_logic;
|
279 |
35 |
nuubik |
signal dongle_con_n : std_logic;
|
280 |
26 |
nuubik |
|
281 |
|
|
constant dongle_ver : std_logic_vector(15 downto 0):=x"8605";
|
282 |
2 |
nuubik |
--END USB signals
|
283 |
|
|
|
284 |
|
|
begin
|
285 |
|
|
|
286 |
17 |
nuubik |
--GPIO PINS START
|
287 |
26 |
nuubik |
fl_sts_en <='Z';
|
288 |
2 |
nuubik |
|
289 |
35 |
nuubik |
hdr(1) <= dongle_con_n;
|
290 |
|
|
--hdr(1) <= fl_sts when resetn='1' else
|
291 |
|
|
-- '0';
|
292 |
|
|
|
293 |
26 |
nuubik |
--when jumper on then mem read and firmware read enabled else only firmware read
|
294 |
17 |
nuubik |
hdr(0) <= 'Z';
|
295 |
|
|
lena_mem_r <= not hdr(0); -- disabled if jumper is not on header pins 1-2
|
296 |
2 |
nuubik |
|
297 |
26 |
nuubik |
-- jumper on pins 5,6 then postcode only mode (no mem device)
|
298 |
|
|
hdr(2) <= '0'; --create low pin for jumper pair 5-6 (this pin is 6 on J1 header)
|
299 |
35 |
nuubik |
lena_reads <= hdr(3) 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
|
300 |
26 |
nuubik |
|
301 |
|
|
|
302 |
|
|
-- when jumper on pins 7,8 then post code capture mode enabled
|
303 |
|
|
hdr(4)<= '0';
|
304 |
|
|
dbg_usb_mode_en <= not hdr(5); --weak pullup on hdr(5) paired with hdr(4)
|
305 |
|
|
usb_mode_en <= not dbg_usb_mode_en;
|
306 |
|
|
|
307 |
17 |
nuubik |
--GPIO PINS END
|
308 |
|
|
|
309 |
2 |
nuubik |
--LED SUBSYSTEM START
|
310 |
26 |
nuubik |
data_to_disp <= x"86"&lpc_debug(7 downto 0) when usb_mode_en='1' else --x"C0DE"; -- ASSIGN data to be displayed (should be regitered)
|
311 |
|
|
"000"&dbg_usedw; --show tx fifo state on leds when postcode capture mode
|
312 |
2 |
nuubik |
--########################################--
|
313 |
|
|
--VERSION CONSTATNS
|
314 |
|
|
--########################################--
|
315 |
|
|
led_red <= enable_4meg;
|
316 |
|
|
|
317 |
|
|
LEDS: led_sys --toplevel for led system
|
318 |
|
|
generic map(
|
319 |
|
|
msn_hib => "01111111",--8 --Most signif. of hi byte
|
320 |
|
|
lsn_hib => "01111101",--6 --Least signif. of hi byte
|
321 |
|
|
msn_lob => "10111111",--0 --Most signif. of hi byte This is version code
|
322 |
17 |
nuubik |
--lsn_lob => "01001111" --3 --Least signif. of hi byte This is version code
|
323 |
26 |
nuubik |
--lsn_lob => "01100110" --4 --Least signif. of hi byte This is version code
|
324 |
|
|
lsn_lob => "01101101" --5 --sync with dongle version const. Least signif. of hi byte This is version code
|
325 |
|
|
|
326 |
2 |
nuubik |
)
|
327 |
|
|
port map(
|
328 |
|
|
clk => sys_clk , -- in std_logic;
|
329 |
|
|
reset_n => resetn, -- in std_logic;
|
330 |
|
|
led_data_i => data_to_disp, -- in std_logic_vector(15 downto 0); --binary data in
|
331 |
|
|
seg_out => seg_out, -- out std_logic_vector(7 downto 0); --one segment out
|
332 |
|
|
sel_out => scn_seg -- out std_logic_vector(3 downto 0) --segment scanner with one bit low
|
333 |
|
|
);
|
334 |
|
|
|
335 |
|
|
--LED SUBSYSTEM END
|
336 |
|
|
|
337 |
|
|
|
338 |
|
|
--MAIN DATAPATH CONNECTIONS
|
339 |
|
|
--LPC bus logic
|
340 |
|
|
lad_i <= lad;
|
341 |
15 |
nuubik |
lad <= lad_o when lad_oe='1' else
|
342 |
2 |
nuubik |
(others=>'Z');
|
343 |
|
|
|
344 |
|
|
--END LPC bus logic
|
345 |
|
|
|
346 |
|
|
LPCBUS : lpc_iow
|
347 |
|
|
port map(
|
348 |
|
|
--system signals
|
349 |
|
|
lreset_n => lreset_n, -- in std_logic;
|
350 |
|
|
lclk => lclk, -- in std_logic;
|
351 |
35 |
nuubik |
lena_mem_r => lena_mem_r, --: in std_logic; --enable full adress range covering memory read block
|
352 |
17 |
nuubik |
lena_reads => lena_reads, -- : in std_logic; --enable read capabilities, : in std_logic; --enable read capabilities
|
353 |
2 |
nuubik |
--LPC bus from host
|
354 |
|
|
lad_i => lad_i, -- in std_logic_vector(3 downto 0);
|
355 |
|
|
lad_o => lad_o, -- out std_logic_vector(3 downto 0);
|
356 |
|
|
lad_oe => lad_oe, -- out std_logic;
|
357 |
|
|
lframe_n => lframe_n, -- in std_logic;
|
358 |
|
|
--memory interface
|
359 |
|
|
lpc_addr => lpc_addr, -- out std_logic_vector(23 downto 0); --shared address
|
360 |
|
|
lpc_wr => lpc_wr, -- out std_logic; --shared write not read
|
361 |
|
|
lpc_data_i => lpc_data_i, -- in std_logic_vector(7 downto 0);
|
362 |
|
|
lpc_data_o => lpc_data_o, -- out std_logic_vector(7 downto 0);
|
363 |
|
|
lpc_val => lpc_val, -- out std_logic;
|
364 |
|
|
lpc_ack => lpc_ack -- in std_logic
|
365 |
|
|
);
|
366 |
|
|
|
367 |
|
|
|
368 |
|
|
--memory data bus logic
|
369 |
|
|
mem_addr <= mode&"11"&lpc_addr(19 downto 0) when c25_lpc_val='1' and enable_4meg='0' else --use mode bist
|
370 |
|
|
mode&lpc_addr(21 downto 0) when c25_lpc_val='1' and enable_4meg='1' else --use mode bist
|
371 |
|
|
mode&umem_addr(21 downto 0) when umem_val='1' else --use mode bist
|
372 |
|
|
(others=>'Z');
|
373 |
|
|
|
374 |
|
|
mem_di <= (others=>'Z') when c25_lpc_val='1' else
|
375 |
|
|
umem_do when umem_val='1' else
|
376 |
|
|
(others=>'Z');
|
377 |
|
|
|
378 |
|
|
|
379 |
|
|
mem_wr <= c25_lpc_wr when c25_lpc_val='1' and c25_lpc_wr='0' else --pass read olny
|
380 |
|
|
umem_wr when umem_val='1' else
|
381 |
|
|
'0';
|
382 |
|
|
|
383 |
|
|
mem_val <= c25_lpc_val or umem_val;
|
384 |
|
|
|
385 |
|
|
|
386 |
|
|
|
387 |
|
|
umem_ack <= mem_ack when umem_val='1' else
|
388 |
|
|
'0';
|
389 |
|
|
|
390 |
|
|
|
391 |
|
|
lpc_data_i <= mem_do(7 downto 0) when lpc_addr(0)='0' else
|
392 |
|
|
mem_do(15 downto 8);
|
393 |
|
|
|
394 |
|
|
lpc_ack <= c33_mem_ack when lpc_val='1' and lpc_wr='0' else
|
395 |
26 |
nuubik |
(not dbg_almost_full) when lpc_val='1' and lpc_wr='1' else
|
396 |
2 |
nuubik |
'0';
|
397 |
|
|
|
398 |
|
|
|
399 |
|
|
|
400 |
|
|
SYNC1: process (lclk, lreset_n) --c33
|
401 |
|
|
begin
|
402 |
|
|
if lclk'event and lclk = '1' then -- rising clock edge
|
403 |
|
|
c33_mem_ack <= mem_ack;
|
404 |
|
|
|
405 |
|
|
end if;
|
406 |
|
|
end process SYNC1;
|
407 |
|
|
|
408 |
|
|
|
409 |
26 |
nuubik |
dbg_data <= lpc_debug(7 downto 0);
|
410 |
|
|
SYNC2: process (sys_clk) --c25
|
411 |
2 |
nuubik |
begin
|
412 |
|
|
if sys_clk'event and sys_clk = '1' then -- rising clock edge
|
413 |
26 |
nuubik |
c25_lpc_val <= lpc_val; --syncro two clock domains
|
414 |
|
|
c25_lpc_wr <= c33_lpc_wr; --syncro two clock domains
|
415 |
|
|
c25_dbg_addr_d <= c33_dbg_addr_d; --syncro two clock domains
|
416 |
|
|
if usb_mode_en ='0' and c25_dbg_addr_d=x"80" then --don't fill fifo in regular mode
|
417 |
|
|
dbg_wr<= c25_lpc_wr; --c33_lpc_wr_wait;--c33_lpc_wr_wait;
|
418 |
|
|
else
|
419 |
|
|
dbg_wr<='0'; --write never rises when usb_mode_en = 1
|
420 |
|
|
end if;
|
421 |
|
|
end if;
|
422 |
2 |
nuubik |
end process SYNC2;
|
423 |
|
|
|
424 |
|
|
|
425 |
|
|
|
426 |
|
|
LATCHled: process (lclk,lreset_n) --c33
|
427 |
|
|
begin
|
428 |
|
|
if lreset_n='0' then
|
429 |
|
|
lpc_debug(7 downto 0)<=(others=>'0');
|
430 |
26 |
nuubik |
c33_dbg_addr_d <=(others=>'0');
|
431 |
2 |
nuubik |
enable_4meg <='0';
|
432 |
|
|
c33_lpc_wr <='0';
|
433 |
35 |
nuubik |
dongle_con_n <='0'; -- pin 3 in GPIO make it toggleable
|
434 |
2 |
nuubik |
elsif lclk'event and lclk = '1' then -- rising clock edge
|
435 |
26 |
nuubik |
c33_lpc_wr <= lpc_wr;
|
436 |
2 |
nuubik |
if c33_lpc_wr='0' and lpc_wr='1' then
|
437 |
26 |
nuubik |
c33_dbg_addr_d <= lpc_addr(7 downto 0);
|
438 |
2 |
nuubik |
lpc_debug(7 downto 0)<= lpc_data_o;
|
439 |
35 |
nuubik |
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)
|
440 |
2 |
nuubik |
enable_4meg <='1';
|
441 |
35 |
nuubik |
elsif lpc_addr(7 downto 0)=x"88" and lpc_data_o=x"F1" then --Flash 1 Mega enalbe
|
442 |
2 |
nuubik |
enable_4meg <='0';
|
443 |
35 |
nuubik |
elsif lpc_addr(7 downto 0)=x"88" and lpc_data_o=x"D1" then --Set Dongle not attached signal
|
444 |
|
|
dongle_con_n <='1'; -- pin 3 in GPIO make it 1
|
445 |
|
|
elsif lpc_addr(7 downto 0)=x"88" and lpc_data_o=x"D0" then --Set Dongle attached signal
|
446 |
|
|
dongle_con_n <='0'; -- pin 3 in GPIO make it 1
|
447 |
2 |
nuubik |
end if;
|
448 |
|
|
end if;
|
449 |
|
|
end if;
|
450 |
|
|
end process LATCHled;
|
451 |
|
|
|
452 |
|
|
|
453 |
|
|
|
454 |
|
|
|
455 |
|
|
|
456 |
|
|
|
457 |
|
|
--END memory data bus logic
|
458 |
|
|
fl_ce_n<= fl_ce_n_w;
|
459 |
|
|
fl_oe_n<= fl_oe_n_w;
|
460 |
|
|
|
461 |
|
|
FLASH : flash_if
|
462 |
|
|
port map(
|
463 |
|
|
clk => sys_clk, -- in std_logic;
|
464 |
|
|
reset_n => resetn, -- in std_logic;
|
465 |
|
|
--flash Bus
|
466 |
|
|
fl_addr => fl_addr, -- out std_logic_vector(23 downto 0);
|
467 |
|
|
fl_ce_n => fl_ce_n_w, -- out std_logic; --chip select
|
468 |
|
|
fl_oe_n => fl_oe_n_w, -- buffer std_logic; --output enable for flash
|
469 |
|
|
fl_we_n => fl_we_n, -- out std_logic; --write enable
|
470 |
|
|
fl_data => fl_data, -- inout std_logic_vector(15 downto 0);
|
471 |
|
|
fl_rp_n => fl_rp_n, -- out std_logic; --reset signal
|
472 |
|
|
--fl_byte_n => fl_byte_n, -- out std_logic; --hold in byte mode
|
473 |
|
|
fl_sts => fl_sts, -- in std_logic; --status signal
|
474 |
|
|
-- mem Bus
|
475 |
|
|
mem_addr => mem_addr, -- in std_logic_vector(23 downto 0);
|
476 |
|
|
mem_do => mem_do, -- out std_logic_vector(15 downto 0);
|
477 |
|
|
mem_di => mem_di, -- in std_logic_vector(15 downto 0);
|
478 |
|
|
|
479 |
|
|
mem_wr => mem_wr, -- in std_logic; --write not read signal
|
480 |
|
|
mem_val => mem_val, -- in std_logic;
|
481 |
|
|
mem_ack => mem_ack -- out std_logic
|
482 |
|
|
);
|
483 |
|
|
|
484 |
|
|
|
485 |
|
|
|
486 |
|
|
USB: usb2mem
|
487 |
|
|
port map(
|
488 |
|
|
clk25 => sys_clk, -- in std_logic;
|
489 |
|
|
reset_n => resetn, -- in std_logic;
|
490 |
26 |
nuubik |
dongle_ver => dongle_ver,
|
491 |
2 |
nuubik |
-- mem Bus
|
492 |
26 |
nuubik |
mem_busy_n=> fl_sts, --check flash status before starting new command on flash
|
493 |
|
|
mem_idle => mem_idle,
|
494 |
2 |
nuubik |
mem_addr => umem_addr, -- out std_logic_vector(23 downto 0);
|
495 |
|
|
mem_do => umem_do, -- out std_logic_vector(15 downto 0);
|
496 |
|
|
mem_di => mem_do, -- in std_logic_vector(15 downto 0); --from flash
|
497 |
|
|
mem_wr => umem_wr, -- out std_logic;
|
498 |
|
|
mem_val => umem_val, -- out std_logic;
|
499 |
|
|
mem_ack => umem_ack, -- in std_logic; --from flash
|
500 |
|
|
mem_cmd => umem_cmd, -- out std_logic;
|
501 |
|
|
-- USB port
|
502 |
26 |
nuubik |
usb_mode_en => usb_mode_en,
|
503 |
2 |
nuubik |
usb_rd_n => usb_rd_n, -- out std_logic; -- enables out data if low (next byte detected by edge / in usb chip)
|
504 |
|
|
usb_wr => usb_wr, -- out std_logic; -- write performed on edge \ of signal
|
505 |
|
|
usb_txe_n => usb_txe_n, -- in std_logic; -- tx fifo empty (redy for new data if low)
|
506 |
|
|
usb_rxf_n => usb_rxf_n, -- in std_logic; -- rx fifo empty (data redy if low)
|
507 |
|
|
usb_bd => usb_bd -- inout std_logic_vector(7 downto 0) --bus data
|
508 |
|
|
);
|
509 |
|
|
|
510 |
|
|
|
511 |
26 |
nuubik |
DBG : pc_serializer
|
512 |
|
|
port map ( --system signals
|
513 |
|
|
sys_clk => sys_clk, -- in STD_LOGIC;
|
514 |
|
|
resetn => resetn, -- in STD_LOGIC;
|
515 |
|
|
--postcode data port
|
516 |
|
|
dbg_data => dbg_data, -- in STD_LOGIC_VECTOR (7 downto 0);
|
517 |
|
|
dbg_wr => dbg_wr, -- in STD_LOGIC; --write not read
|
518 |
|
|
dbg_full => dbg_full,--: out STD_LOGIC; --write not read
|
519 |
|
|
dbg_almost_full => dbg_almost_full,
|
520 |
|
|
dbg_usedw => dbg_usedw,
|
521 |
|
|
|
522 |
|
|
--debug USB port
|
523 |
|
|
dbg_usb_mode_en=> dbg_usb_mode_en, -- in std_logic; -- enable this debug mode
|
524 |
|
|
dbg_usb_wr => usb_wr, -- out std_logic; -- write performed on edge \ of signal
|
525 |
|
|
dbg_usb_txe_n => usb_txe_n, -- in std_logic; -- tx fifo not full (redy for new data if low)
|
526 |
|
|
dbg_usb_bd => usb_bd -- inout std_logic_vector(7 downto 0) --bus data
|
527 |
|
|
);
|
528 |
|
|
|
529 |
|
|
|
530 |
2 |
nuubik |
--END MAIN DATAPATH CONNECTIONS
|
531 |
|
|
|
532 |
|
|
end rtl;
|
533 |
|
|
|
534 |
|
|
|
535 |
|
|
|