w11 - vhd  0.72
W11 CPU core and support modules
 All Classes Namespaces Files Functions Variables
tst_fx2loop.vhd
Go to the documentation of this file.
1 -- $Id: tst_fx2loop.vhd 649 2015-02-21 21:10:16Z mueller $
2 --
3 -- Copyright 2011-2013 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: tst_fx2loop - syn
16 -- Description: simple stand-alone tester for fx2lib components
17 --
18 -- Dependencies: comlib/byte2word
19 -- comlib/word2byte
20 -- Test bench: -
21 --
22 -- Target Devices: generic
23 -- Tool versions: xst 13.3-14.7; ghdl 0.29-0.31
24 --
25 -- Revision History:
26 -- Date Rev Version Comment
27 -- 2013-04-24 510 1.0.1 fix sensitivity list of proc_next
28 -- 2012-01-15 453 1.0 Initial version
29 -- 2011-12-26 445 0.5 First draft
30 ------------------------------------------------------------------------------
31 
32 library ieee;
33 use ieee.std_logic_1164.all;
34 use ieee.numeric_std.all;
35 
36 use work.slvtypes.all;
37 use work.comlib.all;
38 use work.fx2lib.all;
39 use work.tst_fx2looplib.all;
40 
41 -- ----------------------------------------------------------------------------
42 
43 entity tst_fx2loop is -- tester for fx2lib components
44  port (
45  CLK : in slbit; -- clock
46  RESET : in slbit; -- reset
47  CE_MSEC : in slbit; -- msec pulse
48  HIO_CNTL : in hio_cntl_type; -- humanio controls
49  HIO_STAT : out hio_stat_type; -- humanio status
50  FX2_MONI : in fx2ctl_moni_type; -- fx2ctl monitor
51  RXDATA : in slv8; -- receiver data out
52  RXVAL : in slbit; -- receiver data valid
53  RXHOLD : out slbit; -- receiver data hold
54  TXDATA : out slv8; -- transmit data in
55  TXENA : out slbit; -- transmit data enable
56  TXBUSY : in slbit; -- transmit busy
57  TX2DATA : out slv8; -- transmit 2 data in
58  TX2ENA : out slbit; -- transmit 2 data enable
59  TX2BUSY : in slbit -- transmit 2 busy
60  );
61 end tst_fx2loop;
62 
63 architecture syn of tst_fx2loop is
64 
65  type regs_type is record
66  rxdata : slv16; -- next rx word
67  txdata : slv16; -- next tx word
68  tx2data : slv16; -- next tx2 word
69  rxsecnt : slv16; -- rx sequence error counter
70  rxcnt : slv32; -- rx word counter
71  txcnt : slv32; -- tx word counter
72  tx2cnt : slv32; -- tx2 word counter
73  rxthrottle : slbit; -- rx throttle flag
74  end record regs_type;
75 
76  constant regs_init : regs_type := (
77  (others=>'0'), -- rxdata
78  (others=>'0'), -- txdata
79  (others=>'0'), -- tx2data
80  (others=>'0'), -- rxsecnt
81  (others=>'0'), -- rxcnt
82  (others=>'0'), -- txcnt
83  (others=>'0'), -- tx2cnt
84  '0' -- rxthrottle
85  );
86 
87  signal R_REGS : regs_type := regs_init; -- state registers
88  signal N_REGS : regs_type := regs_init; -- next value state regs
89 
90  signal RXWDATA : slv16 := (others=>'0');
91  signal RXWVAL : slbit := '0';
92  signal RXWHOLD : slbit := '0';
93  signal RXODD : slbit := '0';
94 
95  signal TXWDATA : slv16 := (others=>'0');
96  signal TXWENA : slbit := '0';
97  signal TXWBUSY : slbit := '0';
98  signal TXODD : slbit := '0';
99  signal TX2WDATA : slv16 := (others=>'0');
100  signal TX2WENA : slbit := '0';
101  signal TX2WBUSY : slbit := '0';
102  signal TX2ODD : slbit := '0';
103 
104  signal RXHOLD_L : slbit := '0'; -- local copy of out port signal
105  signal TXENA_L : slbit := '0'; -- local copy of out port signal
106  signal TX2ENA_L : slbit := '0'; -- local copy of out port signal
107  signal CNTL_RESET_L : slbit := '0'; -- local copy of out port signal
108 
109 begin
110 
111  CNTL_RESET_L <= '0'; -- so far unused
112 
113  RXB2W : byte2word
114  port map (
115  CLK => CLK,
116  RESET => CNTL_RESET_L,
117  DI => RXDATA,
118  ENA => RXVAL,
119  BUSY => RXHOLD_L,
120  DO => RXWDATA,
121  VAL => RXWVAL,
122  HOLD => RXWHOLD,
123  ODD => RXODD
124  );
125 
126  TX1W2B : word2byte
127  port map (
128  CLK => CLK,
129  RESET => CNTL_RESET_L,
130  DI => TXWDATA,
131  ENA => TXWENA,
132  BUSY => TXWBUSY,
133  DO => TXDATA,
134  VAL => TXENA_L,
135  HOLD => TXBUSY,
136  ODD => TXODD
137  );
138 
139  TX2W2B : word2byte
140  port map (
141  CLK => CLK,
142  RESET => CNTL_RESET_L,
143  DI => TX2WDATA,
144  ENA => TX2WENA,
145  BUSY => TX2WBUSY,
146  DO => TX2DATA,
147  VAL => TX2ENA_L,
148  HOLD => TX2BUSY,
149  ODD => TX2ODD
150  );
151 
152  proc_regs: process (CLK)
153  begin
154 
155  if rising_edge(CLK) then
156  if RESET = '1' then
157  R_REGS <= regs_init;
158  else
159  R_REGS <= N_REGS;
160  end if;
161  end if;
162 
163  end process proc_regs;
164 
168 
169  variable r : regs_type := regs_init;
170  variable n : regs_type := regs_init;
171 
172  variable irxwhold : slbit := '1';
173  variable itxwena : slbit := '0';
174  variable itxwdata : slv16 := (others=>'0');
175  variable itx2wena : slbit := '0';
176 
177  begin
178  r := R_REGS;
179  n := R_REGS;
180 
181  irxwhold := '1';
182  itxwena := '0';
183  itxwdata := RXWDATA;
184  itx2wena := '0';
185 
186  if HIO_CNTL.throttle = '1' then
187  if CE_MSEC = '1' then
188  n.rxthrottle := not r.rxthrottle;
189  end if;
190  else
191  n.rxthrottle := '0';
192  end if;
193 
194 
195  case HIO_CNTL.mode is
196  when c_mode_idle =>
197  null;
198 
199  when c_mode_rxblast =>
200  if RXWVAL='1' and r.rxthrottle='0' then
201  irxwhold := '0';
202  if RXWDATA /= r.rxdata then
203  n.rxsecnt := slv(unsigned(r.rxsecnt) + 1);
204  end if;
205  n.rxdata := slv(unsigned(RXWDATA) + 1);
206  end if;
207 
208  when c_mode_txblast =>
209  itxwdata := r.txdata;
210  if TXWBUSY = '0' then
211  itxwena := '1';
212  n.txdata := slv(unsigned(r.txdata) + 1);
213  end if;
214  irxwhold := '0';
215 
216  when c_mode_loop =>
217  itxwdata := RXWDATA;
218  if RXWVAL='1' and r.rxthrottle='0' and TXWBUSY = '0' then
219  irxwhold := '0';
220  itxwena := '1';
221  end if;
222 
223  when others => null;
224  end case;
225 
226  if HIO_CNTL.tx2blast = '1' then
227  if TX2WBUSY = '0' then
228  itx2wena := '1';
229  n.tx2data := slv(unsigned(r.tx2data) + 1);
230  end if;
231  end if;
232 
233  if RXWVAL='1' and irxwhold='0' then
234  n.rxcnt := slv(unsigned(r.rxcnt) + 1);
235  end if;
236 
237  if itxwena = '1' then
238  n.txcnt := slv(unsigned(r.txcnt) + 1);
239  end if;
240 
241  if itx2wena = '1' then
242  n.tx2cnt := slv(unsigned(r.tx2cnt) + 1);
243  end if;
244 
245  N_REGS <= n;
246 
247  RXWHOLD <= irxwhold;
248  TXWENA <= itxwena;
249  TXWDATA <= itxwdata;
250  TX2WENA <= itx2wena;
251  TX2WDATA <= r.tx2data;
252 
256  HIO_STAT.rxsecnt <= r.rxsecnt;
257  HIO_STAT.rxcnt <= r.rxcnt;
258  HIO_STAT.txcnt <= r.txcnt;
259  HIO_STAT.tx2cnt <= r.tx2cnt;
260 
261  end process proc_next;
262 
263  RXHOLD <= RXHOLD_L;
264  TXENA <= TXENA_L;
265  TX2ENA <= TX2ENA_L;
266 
267 end syn;
in DIslv8
Definition: byte2word.vhd:39
out TXENAslbit
Definition: tst_fx2loop.vhd:55
in FX2_MONIfx2ctl_moni_type
Definition: tst_fx2loop.vhd:50
regs_type :=regs_init R_REGS
Definition: tst_fx2loop.vhd:87
out HIO_STAThio_stat_type
Definition: tst_fx2loop.vhd:49
in RESETslbit
Definition: word2byte.vhd:38
slv16 :=( others =>'0' ) RXWDATA
Definition: tst_fx2loop.vhd:90
in CLKslbit
Definition: tst_fx2loop.vhd:45
slbit :='0' RXHOLD_L
slbit :='0' TXENA_L
out ODDslbit
Definition: word2byte.vhd:45
slbit :='0' RXWVAL
Definition: tst_fx2loop.vhd:91
out ODDslbit
Definition: byte2word.vhd:45
in DIslv16
Definition: word2byte.vhd:39
in CLKslbit
Definition: byte2word.vhd:37
slv16 :=( others =>'0' ) TX2WDATA
Definition: tst_fx2loop.vhd:99
slbit :='0' RXWHOLD
Definition: tst_fx2loop.vhd:92
slbit :='0' TX2ODD
slbit :='0' TX2ENA_L
in RXDATAslv8
Definition: tst_fx2loop.vhd:51
proc_nextR_REGS,CE_MSEC,HIO_CNTL,FX2_MONI,RXWDATA,RXWVAL,TXWBUSY,TX2WBUSY,RXHOLD_L,TXBUSY,TX2BUSY
in RESETslbit
Definition: byte2word.vhd:38
byte2word rxb2wrxb2w
out VALslbit
Definition: word2byte.vhd:43
in ENAslbit
Definition: byte2word.vhd:40
out BUSYslbit
Definition: word2byte.vhd:41
slbit :='0' TX2WBUSY
in HOLDslbit
Definition: word2byte.vhd:44
in CE_MSECslbit
Definition: tst_fx2loop.vhd:47
in RESETslbit
Definition: tst_fx2loop.vhd:46
slbit :='0' TXWBUSY
Definition: tst_fx2loop.vhd:97
in TXBUSYslbit
Definition: tst_fx2loop.vhd:56
slbit :='0' TXODD
Definition: tst_fx2loop.vhd:98
slv16 :=( others =>'0' ) TXWDATA
Definition: tst_fx2loop.vhd:95
in RXVALslbit
Definition: tst_fx2loop.vhd:52
slbit :='0' TXWENA
Definition: tst_fx2loop.vhd:96
in TX2BUSYslbit
Definition: tst_fx2loop.vhd:59
out TX2ENAslbit
Definition: tst_fx2loop.vhd:58
out RXHOLDslbit
Definition: tst_fx2loop.vhd:53
word2byte tx1w2btx1w2b
in CLKslbit
Definition: word2byte.vhd:37
in ENAslbit
Definition: word2byte.vhd:40
slbit :='0' RXODD
Definition: tst_fx2loop.vhd:93
in HOLDslbit
Definition: byte2word.vhd:44
in HIO_CNTLhio_cntl_type
Definition: tst_fx2loop.vhd:48
regs_type := ( ( others =>'0' ) ,( others =>'0' ) ,( others =>'0' ) ,( others =>'0' ) ,( others =>'0' ) ,( others =>'0' ) ,( others =>'0' ) ,'0' ) regs_init
Definition: tst_fx2loop.vhd:76
slbit :='0' TX2WENA
out TXDATAslv8
Definition: tst_fx2loop.vhd:54
out DOslv16
Definition: byte2word.vhd:42
out DOslv8
Definition: word2byte.vhd:42
rxdata:slv16 # txdata:slv16 # tx2data:slv16 # rxsecnt:slv16 # rxcnt:slv32 # txcnt:slv32 # tx2cnt:slv32 # rxthrottle:slbit # regs_typerecordrxdata:slv16%#%%txdata:slv16%#%tx2data:slv16%#%rxsecnt:slv16%#%rxcnt:slv32%#%txcnt:slv32%#%tx2cnt:slv32%#%rxthrottle:slbit%#
Definition: tst_fx2loop.vhd:65
word2byte tx2w2btx2w2b
slbit :='0' CNTL_RESET_L
out VALslbit
Definition: byte2word.vhd:43
out BUSYslbit
Definition: byte2word.vhd:41
regs_type :=regs_init N_REGS
Definition: tst_fx2loop.vhd:88
out TX2DATAslv8
Definition: tst_fx2loop.vhd:57