w11 - vhd  0.72
W11 CPU core and support modules
 All Classes Namespaces Files Functions Variables
sys_tst_fx2loop_n2.vhd
Go to the documentation of this file.
1 -- $Id: sys_tst_fx2loop_n2.vhd 649 2015-02-21 21:10:16Z mueller $
2 --
3 -- Copyright 2011-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4 --
5 -- This program is free software; you may redistribute and/or modify it under
6 -- the terms of the GNU General Public License as published by the Free
7 -- Software Foundation, either version 2, or at your option any later version.
8 --
9 -- This program is distributed in the hope that it will be useful, but
10 -- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 -- for complete details.
13 --
14 ------------------------------------------------------------------------------
15 -- Module Name: sys_tst_fx2loop_n2 - syn
16 -- Description: test of Cypress EZ-USB FX2 controller
17 --
18 -- Dependencies: vlib/xlib/dcm_sfs
19 -- vlib/genlib/clkdivce
20 -- bpgen/sn_humanio
21 -- tst_fx2loop_hiomap
22 -- tst_fx2loop
23 -- bplib/fx2lib/fx2_2fifoctl_ic [sys_conf_fx2_type="ic2"]
24 -- bplib/fx2lib/fx2_3fifoctl_ic [sys_conf_fx2_type="ic3"]
25 -- bplib/nxcramlib/nx_cram_dummy
26 --
27 -- Test bench: -
28 --
29 -- Target Devices: generic
30 -- Tool versions: xst 13.3-14.7; ghdl 0.29-0.31
31 --
32 -- Synthesized (xst):
33 -- Date Rev ise Target flop lutl lutm slic t peri ctl/MHz
34 -- 2012-04-09 461 13.3 O76d xc3s1200e-4 307 390 64 325 p 9.9 as2/100
35 -- 2012-04-09 461 13.3 O76d xc3s1200e-4 358 419 64 369 p 9.4 ic2/100
36 -- 2012-04-09 461 13.3 O76c xc3s1200e-4 436 537 96 476 p 8.9 ic3/100
37 --
38 -- Revision History:
39 -- Date Rev Version Comment
40 -- 2015-01-25 638 1.1.1 retire fx2_2fifoctl_as
41 -- 2012-01-15 453 1.1 now generic for as,ic,ic3 controllers
42 -- 2011-12-26 445 1.0 Initial version
43 ------------------------------------------------------------------------------
44 
45 library ieee;
46 use ieee.std_logic_1164.all;
47 use ieee.numeric_std.all;
48 
49 use work.slvtypes.all;
50 use work.xlib.all;
51 use work.genlib.all;
52 use work.bpgenlib.all;
53 use work.tst_fx2looplib.all;
54 use work.fx2lib.all;
55 use work.nxcramlib.all;
56 use work.sys_conf.all;
57 
58 -- ----------------------------------------------------------------------------
59 
60 entity sys_tst_fx2loop_n2 is -- top level
61  -- implements nexys2_aif + fx2 pins
62  port (
63  I_CLK50 : in slbit; -- 50 MHz board clock
64  I_RXD : in slbit; -- receive data (board view)
65  O_TXD : out slbit; -- transmit data (board view)
66  I_SWI : in slv8; -- n2 switches
67  I_BTN : in slv4; -- n2 buttons
68  O_LED : out slv8; -- n2 leds
69  O_ANO_N : out slv4; -- 7 segment disp: anodes (act.low)
70  O_SEG_N : out slv8; -- 7 segment disp: segments (act.low)
71  O_MEM_CE_N : out slbit; -- cram: chip enable (act.low)
72  O_MEM_BE_N : out slv2; -- cram: byte enables (act.low)
73  O_MEM_WE_N : out slbit; -- cram: write enable (act.low)
74  O_MEM_OE_N : out slbit; -- cram: output enable (act.low)
75  O_MEM_ADV_N : out slbit; -- cram: address valid (act.low)
76  O_MEM_CLK : out slbit; -- cram: clock
77  O_MEM_CRE : out slbit; -- cram: command register enable
78  I_MEM_WAIT : in slbit; -- cram: mem wait
79  O_MEM_ADDR : out slv23; -- cram: address lines
80  IO_MEM_DATA : inout slv16; -- cram: data lines
81  O_FLA_CE_N : out slbit; -- flash ce.. (act.low)
82  I_FX2_IFCLK : in slbit; -- fx2: interface clock
83  O_FX2_FIFO : out slv2; -- fx2: fifo address
84  I_FX2_FLAG : in slv4; -- fx2: fifo flags
85  O_FX2_SLRD_N : out slbit; -- fx2: read enable (act.low)
86  O_FX2_SLWR_N : out slbit; -- fx2: write enable (act.low)
87  O_FX2_SLOE_N : out slbit; -- fx2: output enable (act.low)
88  O_FX2_PKTEND_N : out slbit; -- fx2: packet end (act.low)
89  IO_FX2_DATA : inout slv8 -- fx2: data lines
90  );
91 end sys_tst_fx2loop_n2;
92 
93 architecture syn of sys_tst_fx2loop_n2 is
94 
95  signal CLK : slbit := '0';
96  signal RESET : slbit := '0';
97 
98  signal CE_USEC : slbit := '0';
99  signal CE_MSEC : slbit := '0';
100 
101  signal SWI : slv8 := (others=>'0');
102  signal BTN : slv4 := (others=>'0');
103  signal LED : slv8 := (others=>'0');
104  signal DSP_DAT : slv16 := (others=>'0');
105  signal DSP_DP : slv4 := (others=>'0');
106 
107  signal LED_MAP : slv8 := (others=>'0');
108 
109  signal HIO_CNTL : hio_cntl_type := hio_cntl_init;
110  signal HIO_STAT : hio_stat_type := hio_stat_init;
111 
112  signal FX2_RXDATA : slv8 := (others=>'0');
113  signal FX2_RXVAL : slbit := '0';
114  signal FX2_RXHOLD : slbit := '0';
115  signal FX2_RXAEMPTY : slbit := '0';
116  signal FX2_TXDATA : slv8 := (others=>'0');
117  signal FX2_TXENA : slbit := '0';
118  signal FX2_TXBUSY : slbit := '0';
119  signal FX2_TXAFULL : slbit := '0';
120  signal FX2_TX2DATA : slv8 := (others=>'0');
121  signal FX2_TX2ENA : slbit := '0';
122  signal FX2_TX2BUSY : slbit := '1';
123  signal FX2_TX2AFULL : slbit := '0';
124  signal FX2_MONI : fx2ctl_moni_type := fx2ctl_moni_init;
125 
126 begin
127 
128  assert (sys_conf_clksys mod 1000000) = 0
129  report "assert sys_conf_clksys on MHz grid"
130  severity failure;
131 
132  DCM : dcm_sfs
133  generic map (
134  CLKFX_DIVIDE => sys_conf_clkfx_divide ,
135  CLKFX_MULTIPLY => sys_conf_clkfx_multiply ,
136  CLKIN_PERIOD => 20.0)
137  port map (
138  CLKIN => I_CLK50,
139  CLKFX => CLK,
140  LOCKED => open
141  );
142 
143  CLKDIV : clkdivce
144  generic map (
145  CDUWIDTH => 7, -- good for up to 127 MHz !
146  USECDIV => sys_conf_clksys_mhz ,
147  MSECDIV => 1000)
148  port map (
149  CLK => CLK,
150  CE_USEC => CE_USEC,
151  CE_MSEC => CE_MSEC
152  );
153 
154  HIO : sn_humanio
155  generic map (
156  DEBOUNCE => sys_conf_hio_debounce )
157  port map (
158  CLK => CLK,
159  RESET => '0',
160  CE_MSEC => CE_MSEC,
161  SWI => SWI,
162  BTN => BTN,
163  LED => LED,
164  DSP_DAT => DSP_DAT,
165  DSP_DP => DSP_DP,
166  I_SWI => I_SWI,
167  I_BTN => I_BTN,
168  O_LED => O_LED,
169  O_ANO_N => O_ANO_N,
170  O_SEG_N => O_SEG_N
171  );
172 
173  RESET <= BTN(0); -- BTN(0) will reset tester !!
174 
176  port map (
177  CLK => CLK,
178  RESET => RESET,
179  HIO_CNTL => HIO_CNTL,
180  HIO_STAT => HIO_STAT,
181  FX2_MONI => FX2_MONI,
182  SWI => SWI,
183  BTN => BTN,
184  LED => LED_MAP ,
185  DSP_DAT => DSP_DAT,
186  DSP_DP => DSP_DP
187  );
188 
191  begin
192 
193  if SWI(4) = '1' then
194  LED(7) <= '0';
195  LED(6) <= '0';
196  LED(5) <= FX2_TX2BUSY;
197  LED(4) <= FX2_TX2ENA;
198  LED(3) <= FX2_TXBUSY;
199  LED(2) <= FX2_TXENA;
200  LED(1) <= FX2_RXHOLD;
201  LED(0) <= FX2_RXVAL;
202  else
203  LED <= LED_MAP;
204  end if;
205 
206  end process proc_led;
207 
208 
209  TST : tst_fx2loop
210  port map (
211  CLK => CLK,
212  RESET => RESET,
213  CE_MSEC => CE_MSEC,
214  HIO_CNTL => HIO_CNTL,
215  HIO_STAT => HIO_STAT,
216  FX2_MONI => FX2_MONI,
217  RXDATA => FX2_RXDATA ,
218  RXVAL => FX2_RXVAL ,
219  RXHOLD => FX2_RXHOLD ,
220  TXDATA => FX2_TXDATA ,
221  TXENA => FX2_TXENA ,
222  TXBUSY => FX2_TXBUSY ,
223  TX2DATA => FX2_TX2DATA ,
224  TX2ENA => FX2_TX2ENA ,
225  TX2BUSY => FX2_TX2BUSY
226  );
227 
228  FX2_CNTL_IC : if sys_conf_fx2_type = "ic2" generate
230  generic map (
231  RXFAWIDTH => 5,
232  TXFAWIDTH => 5,
233  PETOWIDTH => sys_conf_fx2_petowidth,
234  CCWIDTH => sys_conf_fx2_ccwidth ,
235  RXAEMPTY_THRES => 1,
236  TXAFULL_THRES => 1)
237  port map (
238  CLK => CLK,
239  RESET => RESET,
240  RXDATA => FX2_RXDATA,
241  RXVAL => FX2_RXVAL,
242  RXHOLD => FX2_RXHOLD,
244  TXDATA => FX2_TXDATA,
245  TXENA => FX2_TXENA,
246  TXBUSY => FX2_TXBUSY,
247  TXAFULL => FX2_TXAFULL,
248  MONI => FX2_MONI,
257  );
258  end generate FX2_CNTL_IC;
259 
260  FX2_CNTL_IC3 : if sys_conf_fx2_type = "ic3" generate
262  generic map (
263  RXFAWIDTH => 5,
264  TXFAWIDTH => 5,
265  PETOWIDTH => sys_conf_fx2_petowidth,
266  CCWIDTH => sys_conf_fx2_ccwidth ,
267  RXAEMPTY_THRES => 1,
268  TXAFULL_THRES => 1,
269  TX2AFULL_THRES => 1)
270  port map (
271  CLK => CLK,
272  RESET => RESET,
273  RXDATA => FX2_RXDATA,
274  RXVAL => FX2_RXVAL,
275  RXHOLD => FX2_RXHOLD,
277  TXDATA => FX2_TXDATA,
278  TXENA => FX2_TXENA,
279  TXBUSY => FX2_TXBUSY,
280  TXAFULL => FX2_TXAFULL,
281  TX2DATA => FX2_TX2DATA,
282  TX2ENA => FX2_TX2ENA,
283  TX2BUSY => FX2_TX2BUSY,
285  MONI => FX2_MONI,
294  );
295  end generate FX2_CNTL_IC3;
296 
297  SRAM_PROT : nx_cram_dummy -- connect CRAM to protection dummy
298  port map (
299  O_MEM_CE_N => O_MEM_CE_N,
300  O_MEM_BE_N => O_MEM_BE_N,
301  O_MEM_WE_N => O_MEM_WE_N,
302  O_MEM_OE_N => O_MEM_OE_N,
303  O_MEM_ADV_N => O_MEM_ADV_N,
304  O_MEM_CLK => O_MEM_CLK,
305  O_MEM_CRE => O_MEM_CRE,
306  I_MEM_WAIT => I_MEM_WAIT,
307  O_MEM_ADDR => O_MEM_ADDR,
308  IO_MEM_DATA => IO_MEM_DATA
309  );
310 
311  O_FLA_CE_N <= '1'; -- keep Flash memory disabled
312 
313  O_TXD <= I_RXD; -- loop-back in serial port...
314 
315 end syn;
316 
out TXENAslbit
Definition: tst_fx2loop.vhd:55
out CLKFXslbit
in FX2_MONIfx2ctl_moni_type
Definition: tst_fx2loop.vhd:50
CCWIDTHpositive :=5
out HIO_STAThio_stat_type
Definition: tst_fx2loop.vhd:49
tst_fx2loop tsttst
CCWIDTHpositive :=5
Definition: xlib.vhd:40
DEBOUNCEboolean :=true
Definition: sn_humanio.vhd:63
TXFAWIDTHpositive :=5
slv4 :=( others =>'0' ) DSP_DP
in CLKslbit
Definition: tst_fx2loop.vhd:45
out LOCKEDslbit
in HIO_STAThio_stat_type
slv8 :=( others =>'0' ) LED_MAP
dcm_sfs dcmdcm
out O_FX2_SLWR_Nslbit
out CE_MSECslbit
Definition: clkdivce.vhd:44
TXAFULL_THRESnatural :=1
_library_ ieeeieee
Definition: sys_conf.vhd:25
CDUWIDTHpositive :=6
Definition: clkdivce.vhd:38
out O_SEG_Nslv8
Definition: sn_humanio.vhd:77
TX2AFULL_THRESnatural :=1
nx_cram_dummy sram_protsram_prot
out O_FX2_SLWR_Nslbit
slv8 :=( others =>'0' ) SWI
in RXDATAslv8
Definition: tst_fx2loop.vhd:51
RXFAWIDTHpositive :=5
out O_LEDslv (LWIDTH - 1 downto 0)
Definition: sn_humanio.vhd:75
out HIO_CNTLhio_cntl_type
slv8 :=( others =>'0' ) FX2_TX2DATA
RXFAWIDTHpositive :=5
slv8 :=( others =>'0' ) LED
TXAFULL_THRESnatural :=1
out O_FX2_PKTEND_Nslbit
in DSP_DPslv ((2 ** DCWIDTH) - 1 downto 0)
Definition: sn_humanio.vhd:72
MSECDIVpositive :=1000
Definition: clkdivce.vhd:40
out SWIslv (SWIDTH - 1 downto 0)
Definition: sn_humanio.vhd:68
out O_FX2_PKTEND_Nslbit
out CE_USECslbit
Definition: clkdivce.vhd:43
out O_FX2_SLOE_Nslbit
hio_stat_type :=hio_stat_init HIO_STAT
in CE_MSECslbit
Definition: tst_fx2loop.vhd:47
in CLKslbit
Definition: sn_humanio.vhd:65
out O_FX2_SLRD_Nslbit
in RESETslbit
Definition: tst_fx2loop.vhd:46
in I_SWIslv (SWIDTH - 1 downto 0)
Definition: sn_humanio.vhd:73
out O_FX2_SLRD_Nslbit
PETOWIDTHpositive :=7
in TXBUSYslbit
Definition: tst_fx2loop.vhd:56
PETOWIDTHpositive :=7
fx2_2fifoctl_ic cntlcntl
in RXVALslbit
Definition: tst_fx2loop.vhd:52
CLKIN_PERIODreal :=20.0
in TX2BUSYslbit
Definition: tst_fx2loop.vhd:59
out O_FX2_SLOE_Nslbit
in I_BTNslv (BWIDTH - 1 downto 0)
Definition: sn_humanio.vhd:74
out MONIfx2ctl_moni_type
slv8 :=( others =>'0' ) FX2_TXDATA
out TX2ENAslbit
Definition: tst_fx2loop.vhd:58
clkdivce clkdivclkdiv
in CLKslbit
Definition: clkdivce.vhd:42
out RXHOLDslbit
Definition: tst_fx2loop.vhd:53
in FX2_MONIfx2ctl_moni_type
proc_ledSWI,LED_MAP,FX2_TX2BUSY,FX2_TX2ENA,FX2_TXBUSY,FX2_TXENA,FX2_RXHOLD,FX2_RXVAL
out MONIfx2ctl_moni_type
inout IO_FX2_DATAslv8
RXAEMPTY_THRESnatural :=1
inout IO_FX2_DATAslv8
in DSP_DATslv (4 * (2 ** DCWIDTH) - 1 downto 0)
Definition: sn_humanio.vhd:71
in CLKINslbit
in HIO_CNTLhio_cntl_type
Definition: tst_fx2loop.vhd:48
CLKFX_DIVIDEpositive :=1
in RESETslbit :='0'
in RESETslbit :='0'
in LEDslv (LWIDTH - 1 downto 0)
Definition: sn_humanio.vhd:70
out BTNslv (BWIDTH - 1 downto 0)
Definition: sn_humanio.vhd:69
out TXDATAslv8
Definition: tst_fx2loop.vhd:54
RXAEMPTY_THRESnatural :=1
slv16 :=( others =>'0' ) DSP_DAT
fx2ctl_moni_type :=fx2ctl_moni_init FX2_MONI
in RESETslbit :='0'
Definition: sn_humanio.vhd:66
tst_fx2loop_hiomap hiomaphiomap
sn_humanio hiohio
in CE_MSECslbit
Definition: sn_humanio.vhd:67
TXFAWIDTHpositive :=5
out O_ANO_Nslv ((2 ** DCWIDTH) - 1 downto 0)
Definition: sn_humanio.vhd:76
slv8 :=( others =>'0' ) FX2_RXDATA
USECDIVpositive :=50
Definition: clkdivce.vhd:39
CLKFX_MULTIPLYpositive :=1
slv4 :=( others =>'0' ) BTN
hio_cntl_type :=hio_cntl_init HIO_CNTL
out TX2DATAslv8
Definition: tst_fx2loop.vhd:57