OpenCores
URL https://opencores.org/ocsvn/usb_dongle_fpga/usb_dongle_fpga/trunk

Subversion Repositories usb_dongle_fpga

[/] [usb_dongle_fpga/] [trunk/] [src/] [design_top/] [design_top_thincandbg.vhd] - Blame information for rev 17

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
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 17 nuubik
        hdr                : inout    std_logic_vector(10 downto 0);
67
        --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
    --USB parallel interface
88
    usb_rd_n   : inout  std_logic;  -- enables out data if low (next byte detected by edge / in usb chip)
89
    usb_wr     : inout  std_logic;  -- write performed on edge \ of signal
90
    usb_txe_n  : in   std_logic;  -- transmit enable (redy for new data if low)
91
    usb_rxf_n  : in   std_logic;  -- rx fifo has data if low
92
    usb_bd     : inout  std_logic_vector(7 downto 0) --bus data
93
    );
94
end design_top;
95
 
96
 
97
 
98
architecture rtl of design_top is
99
 
100
component led_sys   --toplevel for led system
101
  generic(
102
        msn_hib : std_logic_vector(7 downto 0);  --Most signif. of hi byte
103
        lsn_hib : std_logic_vector(7 downto 0);  --Least signif. of hi byte
104
        msn_lob : std_logic_vector(7 downto 0);  --Most signif. of hi byte
105
        lsn_lob : std_logic_vector(7 downto 0)  --Least signif. of hi byte       
106
  );
107
  port (
108
    clk                         : in std_logic;
109
    reset_n                     : in std_logic;
110
        led_data_i              : in  std_logic_vector(15 downto 0);   --binary data in
111
    seg_out                     : out std_logic_vector(7 downto 0); --one segment out
112
    sel_out                     : out std_logic_vector(3 downto 0)  --segment scanner with one bit low
113
    );
114
end component;
115
 
116
 
117
component lpc_iow
118
  port (
119
    --system signals
120
    lreset_n   : in  std_logic;
121
    lclk       : in  std_logic;
122 17 nuubik
        lena_mem_r : in  std_logic;  --enable full adress range covering memory read block
123
        lena_reads : in  std_logic;  --enable read capabilities
124 2 nuubik
        --LPC bus from host
125
    lad_i      : in  std_logic_vector(3 downto 0);
126
    lad_o      : out std_logic_vector(3 downto 0);
127
    lad_oe     : out std_logic;
128
    lframe_n   : in  std_logic;
129
        --memory interface
130
    lpc_addr   : out std_logic_vector(23 downto 0); --shared address
131
    lpc_wr     : out std_logic;         --shared write not read
132
    lpc_data_i : in  std_logic_vector(7 downto 0);
133
    lpc_data_o : out std_logic_vector(7 downto 0);
134
    lpc_val    : out std_logic;
135
    lpc_ack    : in  std_logic
136
    );
137
end component;
138
 
139
 
140
component flash_if
141
  port (
142
    clk       : in  std_logic;
143
    reset_n   : in  std_logic;
144
    --flash Bus
145
    fl_addr   : out std_logic_vector(23 downto 0);
146
    fl_ce_n      : out std_logic;       --chip select
147
    fl_oe_n      : out std_logic;    --output enable for flash
148
    fl_we_n      : out std_logic;       --write enable
149
    fl_data      : inout std_logic_vector(15 downto 0);
150
    fl_rp_n      : out std_logic;       --reset signal
151
    fl_byte_n    : out std_logic;     --hold in byte mode
152
    fl_sts       : in std_logic;        --status signal
153
    -- mem Bus
154
    mem_addr  : in std_logic_vector(23 downto 0);
155
    mem_do    : out std_logic_vector(15 downto 0);
156
    mem_di    : in  std_logic_vector(15 downto 0);
157
 
158
    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
    -- mem Bus
170
    mem_addr  : out std_logic_vector(23 downto 0);
171
    mem_do    : out std_logic_vector(15 downto 0);
172
    mem_di    : in std_logic_vector(15 downto 0);
173
    mem_wr    : out std_logic;
174
    mem_val   : out std_logic;
175
    mem_ack   : in  std_logic;
176
    mem_cmd   : out std_logic;
177
    -- USB port
178
    usb_rd_n   : out  std_logic;  -- enables out data if low (next byte detected by edge / in usb chip)
179
    usb_wr     : out  std_logic;  -- write performed on edge \ of signal
180
    usb_txe_n  : in   std_logic;  -- tx fifo empty (redy for new data if low)
181
    usb_rxf_n  : in   std_logic;  -- rx fifo empty (data redy if low)
182
    usb_bd     : inout  std_logic_vector(7 downto 0) --bus data
183
    );
184
end component;
185
 
186
 
187
 
188
--LED signals
189
signal data_to_disp : std_logic_vector(15 downto 0);
190
--END LED SIGNALS
191
 
192
--lpc signals
193
signal    lad_i      : std_logic_vector(3 downto 0);
194
signal    lad_o      : std_logic_vector(3 downto 0);
195
signal    lad_oe     : std_logic;
196
 
197
signal    lpc_debug  : std_logic_vector(31 downto 0);
198
signal    lpc_addr   : std_logic_vector(23 downto 0); --shared address
199
signal    lpc_data_o : std_logic_vector(7 downto 0);
200
signal    lpc_data_i : std_logic_vector(7 downto 0);
201
signal    lpc_wr     : std_logic;        --shared write not read
202
signal    lpc_ack    : std_logic;
203
signal    lpc_val    : std_logic;
204 17 nuubik
signal    lena_mem_r : std_logic;  --enable full adress range covering memory read block
205
signal    lena_reads : std_logic;  --enable/disables all read capabilty to make the device post code capturer
206 2 nuubik
 
207
signal    c25_lpc_val  : std_logic;
208
signal    c25_lpc_wr     : std_logic;        --shared write not read
209
signal    c33_lpc_wr     : std_logic;        --for led debug data latching
210
 
211
--End lpc signals
212
 
213
--Flash signals
214
signal    mem_addr  : std_logic_vector(23 downto 0);
215
signal    mem_do    : std_logic_vector(15 downto 0);
216
signal    mem_di    : std_logic_vector(15 downto 0);
217
signal    mem_wr    : std_logic;  --write not read signal
218
signal    mem_val   : std_logic;
219
signal    mem_ack   : std_logic;
220
 
221
signal    c33_mem_ack   : std_logic;  --sync signal
222
 
223
 
224
 
225
signal    fl_ce_n_w : std_logic;       --chip select
226
signal    fl_oe_n_w : std_logic;    --output enable for flash
227
 
228
--END flash signals
229
 
230
--USB signals
231
signal    umem_addr  : std_logic_vector(23 downto 0);
232
signal    umem_do    : std_logic_vector(15 downto 0);
233
signal    umem_wr    : std_logic;
234
signal    umem_val   : std_logic;
235
signal    umem_ack   : std_logic;
236
signal    umem_cmd   : std_logic;
237
signal    enable_4meg: std_logic;
238
--END USB signals
239
 
240
begin
241
 
242 17 nuubik
--GPIO PINS START
243 2 nuubik
 
244 17 nuubik
hdr(2) <= '0'; --create low pin for jumper pair 5-6 (this pin is 6 on J1 header)
245
hdr(0) <= 'Z';
246
lena_mem_r <= not hdr(0); -- disabled if jumper is not on header pins 1-2
247
lena_reads <= hdr(3); -- disabled if jumper is on (jumper makes it a postcode only device)
248 2 nuubik
 
249 17 nuubik
--GPIO PINS END
250
 
251 2 nuubik
--LED SUBSYSTEM START
252
 
253
data_to_disp <= x"86"&lpc_debug(7 downto 0);     --x"C0DE"; -- ASSIGN data to be displayed (should be regitered)
254
 
255
--########################################--
256
                        --VERSION CONSTATNS
257
--########################################--
258
led_red <= enable_4meg;
259
 
260
LEDS: led_sys   --toplevel for led system
261
  generic map(
262
        msn_hib => "01111111",--8  --Most signif. of hi byte  
263
        lsn_hib => "01111101",--6   --Least signif. of hi byte
264
        msn_lob => "10111111",--0  --Most signif. of hi byte   This is version code
265 17 nuubik
        --lsn_lob => "01001111" --3   --Least signif. of hi byte        This is version code
266
        lsn_lob => "01100110" --4   --Least signif. of hi byte  This is version code
267 2 nuubik
  )
268
  port map(
269
    clk                         => sys_clk , -- in std_logic;
270
    reset_n                     => resetn, -- in std_logic;
271
        led_data_i              => data_to_disp, -- in  std_logic_vector(15 downto 0);   --binary data in
272
    seg_out                     => seg_out, -- out std_logic_vector(7 downto 0); --one segment out
273
    sel_out                     => scn_seg -- out std_logic_vector(3 downto 0)  --segment scanner with one bit low
274
    );
275
 
276
--LED SUBSYSTEM END
277
 
278
 
279
--MAIN DATAPATH CONNECTIONS
280
--LPC bus logic
281
lad_i <= lad;
282 15 nuubik
lad <=  lad_o when lad_oe='1' else
283 2 nuubik
                (others=>'Z');
284
 
285
--END LPC bus logic
286
 
287
LPCBUS : lpc_iow
288
  port map(
289
    --system signals
290
    lreset_n   => lreset_n, -- in  std_logic;
291
    lclk       => lclk, -- in  std_logic;
292 17 nuubik
        lena_mem_r => lena_mem_r,--: in  std_logic;  --enable full adress range covering memory read block
293
        lena_reads => lena_reads, -- : in  std_logic;  --enable read capabilities, : in  std_logic;  --enable read capabilities
294 2 nuubik
        --LPC bus from host
295
    lad_i      => lad_i, -- in  std_logic_vector(3 downto 0);
296
    lad_o      => lad_o, -- out std_logic_vector(3 downto 0);
297
    lad_oe     => lad_oe, -- out std_logic;
298
    lframe_n   => lframe_n, -- in  std_logic;
299
        --memory interface
300
    lpc_addr   => lpc_addr, -- out std_logic_vector(23 downto 0); --shared address
301
    lpc_wr     => lpc_wr, -- out std_logic;         --shared write not read
302
    lpc_data_i => lpc_data_i, -- in  std_logic_vector(7 downto 0);
303
    lpc_data_o => lpc_data_o, -- out std_logic_vector(7 downto 0);  
304
    lpc_val    => lpc_val, -- out std_logic;
305
    lpc_ack    => lpc_ack -- in  std_logic
306
    );
307
 
308
 
309
--memory data bus logic
310
        mem_addr <= mode&"11"&lpc_addr(19 downto 0) when c25_lpc_val='1' and enable_4meg='0' else  --use mode bist
311
                                mode&lpc_addr(21 downto 0) when c25_lpc_val='1' and enable_4meg='1' else  --use mode bist
312
                                mode&umem_addr(21 downto 0) when umem_val='1' else  --use mode bist
313
                                (others=>'Z');
314
 
315
        mem_di <=       (others=>'Z') when c25_lpc_val='1' else
316
                                umem_do when umem_val='1' else
317
                                (others=>'Z');
318
 
319
 
320
        mem_wr <= c25_lpc_wr when c25_lpc_val='1' and c25_lpc_wr='0' else  --pass read olny
321
                          umem_wr when umem_val='1' else
322
                          '0';
323
 
324
        mem_val <= c25_lpc_val or umem_val;
325
 
326
 
327
 
328
        umem_ack <= mem_ack when umem_val='1' else
329
                                '0';
330
 
331
 
332
        lpc_data_i <= mem_do(7 downto 0) when lpc_addr(0)='0' else
333
                                  mem_do(15 downto 8);
334
 
335
        lpc_ack <= c33_mem_ack when lpc_val='1' and lpc_wr='0' else
336
                           '1' when lpc_val='1' and lpc_wr='1' else
337
                           '0';
338
 
339
 
340
 
341
        SYNC1: process (lclk, lreset_n)  --c33
342
        begin
343
                if lclk'event and lclk = '1' then    -- rising clock edge
344
                        c33_mem_ack <= mem_ack;
345
 
346
                end if;
347
        end process SYNC1;
348
 
349
 
350
        SYNC2: process (sys_clk, resetn) --c25
351
        begin
352
                if sys_clk'event and sys_clk = '1' then    -- rising clock edge
353
                        c25_lpc_val <= lpc_val;
354
                        c25_lpc_wr <= lpc_wr;
355
                end if;
356
        end process SYNC2;
357
 
358
 
359
 
360
        LATCHled: process (lclk,lreset_n)  --c33
361
        begin
362
                if lreset_n='0' then
363
                        lpc_debug(7 downto 0)<=(others=>'0');
364
                        enable_4meg <='0';
365
                        c33_lpc_wr <='0';
366
                elsif lclk'event and lclk = '1' then    -- rising clock edge
367
                        c33_lpc_wr <= lpc_wr;                   --just for debug delay
368
                        if c33_lpc_wr='0' and  lpc_wr='1' then
369
                                lpc_debug(7 downto 0)<= lpc_data_o;
370
                                if lpc_addr(7 downto 0)=x"88" and lpc_data_o=x"4F" then   --Flash 4 Mega enable (LSN is first MSN is second)
371
                                        enable_4meg <='1';
372
                                elsif lpc_addr(7 downto 0)=x"88" and lpc_data_o=x"1F" then --Flash 1 Mega enalbe
373
                                        enable_4meg <='0';
374
                                end if;
375
                        end if;
376
                end if;
377
        end process LATCHled;
378
 
379
 
380
 
381
 
382
 
383
 
384
--END memory data bus logic
385
fl_ce_n<= fl_ce_n_w;
386
fl_oe_n<= fl_oe_n_w;
387
 
388
FLASH : flash_if
389
  port map(
390
    clk       => sys_clk, -- in  std_logic;
391
    reset_n   => resetn, -- in  std_logic;
392
    --flash Bus
393
    fl_addr   => fl_addr, -- out std_logic_vector(23 downto 0);
394
    fl_ce_n      => fl_ce_n_w, -- out std_logic;       --chip select
395
    fl_oe_n      => fl_oe_n_w, -- buffer std_logic;    --output enable for flash
396
    fl_we_n      => fl_we_n, -- out std_logic;       --write enable
397
    fl_data      => fl_data, -- inout std_logic_vector(15 downto 0);
398
    fl_rp_n      => fl_rp_n, -- out std_logic;       --reset signal
399
    --fl_byte_n    => fl_byte_n, -- out std_logic;     --hold in byte mode
400
    fl_sts       => fl_sts, -- in std_logic;        --status signal
401
    -- mem Bus
402
    mem_addr  => mem_addr, -- in std_logic_vector(23 downto 0);
403
    mem_do    => mem_do, -- out std_logic_vector(15 downto 0);
404
    mem_di    => mem_di, -- in  std_logic_vector(15 downto 0);
405
 
406
    mem_wr    => mem_wr, -- in  std_logic;  --write not read signal
407
    mem_val   => mem_val, -- in  std_logic;
408
    mem_ack   => mem_ack  -- out std_logic
409
    );
410
 
411
 
412
 
413
USB: usb2mem
414
  port map(
415
    clk25     => sys_clk, -- in  std_logic;
416
    reset_n   => resetn, -- in  std_logic;
417
    -- mem Bus
418
    mem_addr  => umem_addr, -- out std_logic_vector(23 downto 0);
419
    mem_do    => umem_do, -- out std_logic_vector(15 downto 0);
420
    mem_di    => mem_do, -- in std_logic_vector(15 downto 0);   --from flash
421
    mem_wr    => umem_wr, -- out std_logic;
422
    mem_val   => umem_val, -- out std_logic;
423
    mem_ack   => umem_ack, -- in  std_logic;  --from flash
424
    mem_cmd   => umem_cmd, -- out std_logic;
425
    -- USB port
426
    usb_rd_n   => usb_rd_n, -- out  std_logic;  -- enables out data if low (next byte detected by edge / in usb chip)
427
    usb_wr     => usb_wr, -- out  std_logic;  -- write performed on edge \ of signal
428
    usb_txe_n  => usb_txe_n, -- in   std_logic;  -- tx fifo empty (redy for new data if low)
429
    usb_rxf_n  => usb_rxf_n, -- in   std_logic;  -- rx fifo empty (data redy if low)
430
    usb_bd     => usb_bd -- inout  std_logic_vector(7 downto 0) --bus data
431
    );
432
 
433
 
434
--END MAIN DATAPATH CONNECTIONS
435
 
436
end rtl;
437
 
438
 
439
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.