w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
tb_nexys2_fusp.vhd
Go to the documentation of this file.
1-- $Id: tb_nexys2_fusp.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2010-2016 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: tb_nexys2_fusp - sim
7-- Description: Test bench for nexys2 (base+fusp)
8--
9-- Dependencies: simlib/simclk
10-- simlib/simclkcnt
11-- xlib/dcm_sfs
12-- rlink/tbcore/tbcore_rlink
13-- tb_nexys2_core
14-- serport/tb/serport_master_tb
15-- nexys2_fusp_aif [UUT]
16--
17-- To test: generic, any nexys2_fusp_aif target
18--
19-- Target Devices: generic
20-- Tool versions: xst 11.4-14.7; ghdl 0.26-0.31
21--
22-- Revision History:
23-- Date Rev Version Comment
24-- 2016-09-02 805 3.3.3 tbcore_rlink without CLK_STOP now
25-- 2016-02-13 730 3.3.2 direct instantiation of tbcore_rlink
26-- 2016-01-03 724 3.3.1 use serport/tb/serport_master_tb
27-- 2015-04-12 666 3.3 use serport_master instead of serport_uart_rxtx
28-- 2011-12-23 444 3.2 new system clock scheme, new tbcore_rlink iface
29-- 2011-11-26 433 3.1.1 remove O_FLA_CE_N from tb_nexys2_core
30-- 2011-11-21 432 3.1 update O_FLA_CE_N usage
31-- 2011-11-19 427 3.0.1 now numeric_std clean
32-- 2010-12-29 351 3.0 use rlink/tb now
33-- 2010-11-13 338 1.0.2 now dcm aware: add O_CLKSYS, use rritb_core_dcm
34-- 2010-11-06 336 1.0.1 rename input pin CLK -> I_CLK50
35-- 2010-05-28 295 1.0 Initial version (derived from tb_s3board_fusp)
36------------------------------------------------------------------------------
37
38library ieee;
39use ieee.std_logic_1164.all;
40use ieee.numeric_std.all;
41use ieee.std_logic_textio.all;
42use std.textio.all;
43
44use work.slvtypes.all;
45use work.rlinklib.all;
46use work.xlib.all;
47use work.nexys2lib.all;
48use work.simlib.all;
49use work.simbus.all;
50use work.sys_conf.all;
51
54
55architecture sim of tb_nexys2_fusp is
56
57 signal CLKOSC : slbit := '0';
58 signal CLKCOM : slbit := '0';
59
60 signal CLKCOM_CYCLE : integer := 0;
61
62 signal RESET : slbit := '0';
63 signal CLKDIV : slv2 := "00"; -- run with 1 clocks / bit !!
64 signal RXDATA : slv8 := (others=>'0');
65 signal RXVAL : slbit := '0';
66 signal RXERR : slbit := '0';
67 signal RXACT : slbit := '0';
68 signal TXDATA : slv8 := (others=>'0');
69 signal TXENA : slbit := '0';
70 signal TXBUSY : slbit := '0';
71
72 signal RX_HOLD : slbit := '0';
73
74 signal I_RXD : slbit := '1';
75 signal O_TXD : slbit := '1';
76 signal I_SWI : slv8 := (others=>'0');
77 signal I_BTN : slv4 := (others=>'0');
78 signal O_LED : slv8 := (others=>'0');
79 signal O_ANO_N : slv4 := (others=>'0');
80 signal O_SEG_N : slv8 := (others=>'0');
81
82 signal O_MEM_CE_N : slbit := '1';
83 signal O_MEM_BE_N : slv2 := (others=>'1');
84 signal O_MEM_WE_N : slbit := '1';
85 signal O_MEM_OE_N : slbit := '1';
86 signal O_MEM_ADV_N : slbit := '1';
87 signal O_MEM_CLK : slbit := '0';
88 signal O_MEM_CRE : slbit := '0';
89 signal I_MEM_WAIT : slbit := '0';
90 signal O_MEM_ADDR : slv23 := (others=>'Z');
91 signal IO_MEM_DATA : slv16 := (others=>'0');
92 signal O_FLA_CE_N : slbit := '0';
93
94 signal O_FUSP_RTS_N : slbit := '0';
95 signal I_FUSP_CTS_N : slbit := '0';
96 signal I_FUSP_RXD : slbit := '1';
97 signal O_FUSP_TXD : slbit := '1';
98
99 signal UART_RESET : slbit := '0';
100 signal UART_RXD : slbit := '1';
101 signal UART_TXD : slbit := '1';
102 signal CTS_N : slbit := '0';
103 signal RTS_N : slbit := '0';
104
105 signal R_PORTSEL_SER : slbit := '0'; -- if 1 use alternate serport
106 signal R_PORTSEL_XON : slbit := '0'; -- if 1 use xon/xoff
107
108 constant sbaddr_portsel: slv8 := slv(to_unsigned( 8,8));
109
110 constant clock_period : Delay_length := 20 ns;
111 constant clock_offset : Delay_length := 200 ns;
112
113begin
114
115 CLKGEN : simclk
116 generic map (
119 port map (
120 CLK => CLKOSC
121 );
122
123 DCM_COM : dcm_sfs
124 generic map (
125 CLKFX_DIVIDE => sys_conf_clkfx_divide,
126 CLKFX_MULTIPLY => sys_conf_clkfx_multiply,
127 CLKIN_PERIOD => 20.0)
128 port map (
129 CLKIN => CLKOSC,
130 CLKFX => CLKCOM,
131 LOCKED => open
132 );
133
134 CLKCNT : simclkcnt port map (CLK => CLKCOM, CLK_CYCLE => CLKCOM_CYCLE);
135
136 TBCORE : entity work.tbcore_rlink
137 port map (
138 CLK => CLKCOM,
139 RX_DATA => TXDATA,
140 RX_VAL => TXENA,
141 RX_HOLD => RX_HOLD,
142 TX_DATA => RXDATA,
143 TX_ENA => RXVAL
144 );
145
146 RX_HOLD <= TXBUSY or RTS_N; -- back pressure for data flow to tb
147
148 N2CORE : entity work.tb_nexys2_core
149 port map (
150 I_SWI => I_SWI,
151 I_BTN => I_BTN,
162 );
163
164 UUT : nexys2_fusp_aif
165 port map (
166 I_CLK50 => CLKOSC,
167 I_RXD => I_RXD,
168 O_TXD => O_TXD,
169 I_SWI => I_SWI,
170 I_BTN => I_BTN,
171 O_LED => O_LED,
172 O_ANO_N => O_ANO_N,
173 O_SEG_N => O_SEG_N,
174 O_MEM_CE_N => O_MEM_CE_N,
175 O_MEM_BE_N => O_MEM_BE_N,
176 O_MEM_WE_N => O_MEM_WE_N,
177 O_MEM_OE_N => O_MEM_OE_N,
178 O_MEM_ADV_N => O_MEM_ADV_N,
179 O_MEM_CLK => O_MEM_CLK,
180 O_MEM_CRE => O_MEM_CRE,
181 I_MEM_WAIT => I_MEM_WAIT,
182 O_MEM_ADDR => O_MEM_ADDR,
183 IO_MEM_DATA => IO_MEM_DATA,
184 O_FLA_CE_N => O_FLA_CE_N,
185 O_FUSP_RTS_N => O_FUSP_RTS_N,
186 I_FUSP_CTS_N => I_FUSP_CTS_N,
187 I_FUSP_RXD => I_FUSP_RXD,
188 O_FUSP_TXD => O_FUSP_TXD
189 );
190
191 SERMSTR : entity work.serport_master_tb
192 generic map (
193 CDWIDTH => CLKDIV'length)
194 port map (
195 CLK => CLKCOM,
196 RESET => UART_RESET,
197 CLKDIV => CLKDIV,
199 ENAESC => '0',
200 RXDATA => RXDATA,
201 RXVAL => RXVAL,
202 RXERR => RXERR,
203 RXOK => '1',
204 TXDATA => TXDATA,
205 TXENA => TXENA,
206 TXBUSY => TXBUSY,
207 RXSD => UART_RXD,
208 TXSD => UART_TXD,
209 RXRTS_N => RTS_N,
210 TXCTS_N => CTS_N
211 );
212
213 proc_port_mux: process (R_PORTSEL_SER, UART_TXD, CTS_N,
215 begin
216
217 if R_PORTSEL_SER = '0' then -- use main board rs232, no flow cntl
218 I_RXD <= UART_TXD; -- write port 0 inputs
219 UART_RXD <= O_TXD; -- get port 0 outputs
220 RTS_N <= '0';
221 I_FUSP_RXD <= '1'; -- port 1 inputs to idle state
222 I_FUSP_CTS_N <= '0';
223 else -- otherwise use pmod1 rs232
224 I_FUSP_RXD <= UART_TXD; -- write port 1 inputs
226 UART_RXD <= O_FUSP_TXD; -- get port 1 outputs
228 I_RXD <= '1'; -- port 0 inputs to idle state
229 end if;
230
231 end process proc_port_mux;
232
233 proc_moni: process
234 variable oline : line;
235 begin
236
237 loop
238 wait until rising_edge(CLKCOM);
239
240 if RXERR = '1' then
241 writetimestamp(oline, CLKCOM_CYCLE, " : seen RXERR=1");
242 writeline(output, oline);
243 end if;
244
245 end loop;
246
247 end process proc_moni;
248
249 proc_simbus: process (SB_VAL)
250 begin
251 if SB_VAL'event and to_x01(SB_VAL)='1' then
252 if SB_ADDR = sbaddr_portsel then
253 R_PORTSEL_SER <= to_x01(SB_DATA(0));
254 R_PORTSEL_XON <= to_x01(SB_DATA(1));
255 end if;
256 end if;
257 end process proc_simbus;
258
259end sim;
CLKFX_DIVIDE positive := 1
in CLKIN slbit
CLKFX_MULTIPLY positive := 1
out LOCKED slbit
CLKIN_PERIOD real := 20.0
out CLKFX slbit
CDWIDTH positive := 13
in ENAESC slbit := '0'
in ENAXON slbit := '0'
in CLKDIV slv( CDWIDTH- 1 downto 0)
in RXOK slbit := '1'
in TXCTS_N slbit := '0'
out CLK slbit
Definition: simclk.vhd:33
OFFSET Delay_length := 200 ns
Definition: simclk.vhd:31
PERIOD Delay_length := 20 ns
Definition: simclk.vhd:30
out CLK_CYCLE integer
Definition: simclkcnt.vhd:29
in CLK slbit
Definition: simclkcnt.vhd:27
std_logic_vector( 22 downto 0) slv23
Definition: slvtypes.vhd:56
std_logic_vector( 3 downto 0) slv4
Definition: slvtypes.vhd:36
std_logic_vector( 15 downto 0) slv16
Definition: slvtypes.vhd:48
std_logic slbit
Definition: slvtypes.vhd:30
std_logic_vector( 7 downto 0) slv8
Definition: slvtypes.vhd:40
std_logic_vector( 1 downto 0) slv2
Definition: slvtypes.vhd:34
std_logic_vector slv
Definition: slvtypes.vhd:31
in O_MEM_WE_N slbit
in O_MEM_ADV_N slbit
out I_MEM_WAIT slbit
in O_MEM_CLK slbit
in O_MEM_OE_N slbit
in O_MEM_ADDR slv23
in O_MEM_CRE slbit
in O_MEM_CE_N slbit
inout IO_MEM_DATA slv16
in O_MEM_BE_N slv2
slbit := '0' RX_HOLD
slbit := '0' RXERR
slbit := '0' RESET
slv8 :=( others => '0') O_SEG_N
integer := 0 CLKCOM_CYCLE
slbit := '1' O_MEM_CE_N
slbit := '1' I_FUSP_RXD
slv2 := "00" CLKDIV
slbit := '1' UART_RXD
slv4 :=( others => '0') I_BTN
slbit := '0' TXENA
slv8 :=( others => '0') RXDATA
slv2 :=( others => '1') O_MEM_BE_N
Delay_length := 200 ns clock_offset
slv16 :=( others => '0') IO_MEM_DATA
slbit := '1' UART_TXD
slbit := '1' O_FUSP_TXD
slv8 :=( others => '0') O_LED
slbit := '0' R_PORTSEL_SER
slbit := '0' O_FLA_CE_N
slbit := '0' UART_RESET
slbit := '0' RXACT
slv23 :=( others => 'Z') O_MEM_ADDR
slbit := '0' O_MEM_CRE
slbit := '0' RXVAL
slbit := '1' O_MEM_ADV_N
slbit := '1' O_TXD
slv8 := slv( to_unsigned( 8, 8) ) sbaddr_portsel
slbit := '0' CLKOSC
slbit := '0' O_MEM_CLK
slbit := '1' O_MEM_OE_N
slv8 :=( others => '0') I_SWI
slbit := '0' CLKCOM
slbit := '0' I_MEM_WAIT
slbit := '0' TXBUSY
slv4 :=( others => '0') O_ANO_N
slbit := '0' R_PORTSEL_XON
slbit := '1' O_MEM_WE_N
slbit := '0' O_FUSP_RTS_N
slv8 :=( others => '0') TXDATA
Delay_length := 20 ns clock_period
slbit := '1' I_RXD
slbit := '0' I_FUSP_CTS_N
Definition: xlib.vhd:35