w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
tb_nexys3_fusp.vhd
Go to the documentation of this file.
1-- $Id: tb_nexys3_fusp.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2011-2016 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: tb_nexys3_fusp - sim
7-- Description: Test bench for nexys3 (base+fusp)
8--
9-- Dependencies: simlib/simclk
10-- simlib/simclkcnt
11-- xlib/s6_cmt_sfs
12-- rlink/tbcore/tbcore_rlink
13-- tb_nexys3_core
14-- serport/tb/serport_master_tb
15-- nexys3_fusp_aif [UUT]
16--
17-- To test: generic, any nexys3_fusp_aif target
18--
19-- Target Devices: generic
20-- Tool versions: xst 13.1-14.7; ghdl 0.29-0.33
21--
22-- Revision History:
23-- Date Rev Version Comment
24-- 2016-09-02 805 1.3.3 tbcore_rlink without CLK_STOP now
25-- 2016-02-13 730 1.3.2 direct instantiation of tbcore_rlink
26-- 2016-01-03 724 1.3.1 use serport/tb/serport_master_tb
27-- 2015-04-12 666 1.3 use serport_master instead of serport_uart_rxtx
28-- 2013-10-06 538 1.2 pll support, use clksys_vcodivide ect
29-- 2011-12-23 444 1.1 new system clock scheme, new tbcore_rlink iface
30-- 2011-11-25 432 1.0 Initial version (derived from tb_nexys2_fusp)
31------------------------------------------------------------------------------
32
33library ieee;
34use ieee.std_logic_1164.all;
35use ieee.numeric_std.all;
36use ieee.std_logic_textio.all;
37use std.textio.all;
38
39use work.slvtypes.all;
40use work.rlinklib.all;
41use work.xlib.all;
42use work.nexys3lib.all;
43use work.simlib.all;
44use work.simbus.all;
45use work.sys_conf.all;
46
49
50architecture sim of tb_nexys3_fusp is
51
52 signal CLKOSC : slbit := '0'; -- board clock (100 Mhz)
53 signal CLKCOM : slbit := '0'; -- communication clock
54
55 signal CLKCOM_CYCLE : integer := 0;
56
57 signal RESET : slbit := '0';
58 signal CLKDIV : slv2 := "00"; -- run with 1 clocks / bit !!
59 signal RXDATA : slv8 := (others=>'0');
60 signal RXVAL : slbit := '0';
61 signal RXERR : slbit := '0';
62 signal RXACT : slbit := '0';
63 signal TXDATA : slv8 := (others=>'0');
64 signal TXENA : slbit := '0';
65 signal TXBUSY : slbit := '0';
66
67 signal RX_HOLD : slbit := '0';
68
69 signal I_RXD : slbit := '1';
70 signal O_TXD : slbit := '1';
71 signal I_SWI : slv8 := (others=>'0');
72 signal I_BTN : slv5 := (others=>'0');
73 signal O_LED : slv8 := (others=>'0');
74 signal O_ANO_N : slv4 := (others=>'0');
75 signal O_SEG_N : slv8 := (others=>'0');
76
77 signal O_MEM_CE_N : slbit := '1';
78 signal O_MEM_BE_N : slv2 := (others=>'1');
79 signal O_MEM_WE_N : slbit := '1';
80 signal O_MEM_OE_N : slbit := '1';
81 signal O_MEM_ADV_N : slbit := '1';
82 signal O_MEM_CLK : slbit := '0';
83 signal O_MEM_CRE : slbit := '0';
84 signal I_MEM_WAIT : slbit := '0';
85 signal O_MEM_ADDR : slv23 := (others=>'Z');
86 signal IO_MEM_DATA : slv16 := (others=>'0');
87 signal O_PPCM_CE_N : slbit := '0';
88 signal O_PPCM_RST_N : slbit := '0';
89
90 signal O_FUSP_RTS_N : slbit := '0';
91 signal I_FUSP_CTS_N : slbit := '0';
92 signal I_FUSP_RXD : slbit := '1';
93 signal O_FUSP_TXD : slbit := '1';
94
95 signal UART_RESET : slbit := '0';
96 signal UART_RXD : slbit := '1';
97 signal UART_TXD : slbit := '1';
98 signal CTS_N : slbit := '0';
99 signal RTS_N : slbit := '0';
100
101 signal R_PORTSEL_SER : slbit := '0'; -- if 1 use alternate serport
102 signal R_PORTSEL_XON : slbit := '0'; -- if 1 use xon/xoff
103
104 constant sbaddr_portsel: slv8 := slv(to_unsigned( 8,8));
105
106 constant clock_period : Delay_length := 10 ns;
107 constant clock_offset : Delay_length := 200 ns;
108
109begin
110
111 CLKGEN : simclk
112 generic map (
115 port map (
116 CLK => CLKOSC
117 );
118
119 CLKGEN_COM : s6_cmt_sfs
120 generic map (
121 VCO_DIVIDE => sys_conf_clksys_vcodivide,
122 VCO_MULTIPLY => sys_conf_clksys_vcomultiply,
123 OUT_DIVIDE => sys_conf_clksys_outdivide,
124 CLKIN_PERIOD => 10.0,
125 CLKIN_JITTER => 0.01,
126 STARTUP_WAIT => false,
127 GEN_TYPE => sys_conf_clksys_gentype)
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 N3CORE : entity work.tb_nexys3_core
149 port map (
150 I_SWI => I_SWI,
151 I_BTN => I_BTN,
162 );
163
164 UUT : nexys3_fusp_aif
165 port map (
166 I_CLK100 => 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_PPCM_CE_N => O_PPCM_CE_N,
185 O_PPCM_RST_N => O_PPCM_RST_N,
186 O_FUSP_RTS_N => O_FUSP_RTS_N,
187 I_FUSP_CTS_N => I_FUSP_CTS_N,
188 I_FUSP_RXD => I_FUSP_RXD,
189 O_FUSP_TXD => O_FUSP_TXD
190 );
191
192 SERMSTR : entity work.serport_master_tb
193 generic map (
194 CDWIDTH => CLKDIV'length)
195 port map (
196 CLK => CLKCOM,
197 RESET => UART_RESET,
198 CLKDIV => CLKDIV,
200 ENAESC => '0',
201 RXDATA => RXDATA,
202 RXVAL => RXVAL,
203 RXERR => RXERR,
204 RXOK => '1',
205 TXDATA => TXDATA,
206 TXENA => TXENA,
207 TXBUSY => TXBUSY,
208 RXSD => UART_RXD,
209 TXSD => UART_TXD,
210 RXRTS_N => RTS_N,
211 TXCTS_N => CTS_N
212 );
213
214 proc_port_mux: process (R_PORTSEL_SER, UART_TXD, CTS_N,
216 begin
217
218 if R_PORTSEL_SER = '0' then -- use main board rs232, no flow cntl
219 I_RXD <= UART_TXD; -- write port 0 inputs
220 UART_RXD <= O_TXD; -- get port 0 outputs
221 RTS_N <= '0';
222 I_FUSP_RXD <= '1'; -- port 1 inputs to idle state
223 I_FUSP_CTS_N <= '0';
224 else -- otherwise use pmod1 rs232
225 I_FUSP_RXD <= UART_TXD; -- write port 1 inputs
227 UART_RXD <= O_FUSP_TXD; -- get port 1 outputs
229 I_RXD <= '1'; -- port 0 inputs to idle state
230 end if;
231
232 end process proc_port_mux;
233
234 proc_moni: process
235 variable oline : line;
236 begin
237
238 loop
239 wait until rising_edge(CLKCOM);
240
241 if RXERR = '1' then
242 writetimestamp(oline, CLKCOM_CYCLE, " : seen RXERR=1");
243 writeline(output, oline);
244 end if;
245
246 end loop;
247
248 end process proc_moni;
249
250 proc_simbus: process (SB_VAL)
251 begin
252 if SB_VAL'event and to_x01(SB_VAL)='1' then
253 if SB_ADDR = sbaddr_portsel then
254 R_PORTSEL_SER <= to_x01(SB_DATA(0));
255 R_PORTSEL_XON <= to_x01(SB_DATA(1));
256 end if;
257 end if;
258 end process proc_simbus;
259
260end sim;
VCO_DIVIDE positive := 1
GEN_TYPE string := "PLL"
CLKIN_PERIOD real := 10.0
OUT_DIVIDE positive := 1
in CLKIN slbit
CLKIN_JITTER real := 0.01
STARTUP_WAIT boolean := false
VCO_MULTIPLY positive := 1
out LOCKED slbit
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( 4 downto 0) slv5
Definition: slvtypes.vhd:37
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
Delay_length := 10 ns clock_period
slv2 := "00" CLKDIV
slbit := '1' UART_RXD
slbit := '0' TXENA
slv8 :=( others => '0') RXDATA
slv2 :=( others => '1') O_MEM_BE_N
slbit := '0' O_PPCM_CE_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' UART_RESET
slbit := '0' RXACT
slv23 :=( others => 'Z') O_MEM_ADDR
slbit := '0' O_MEM_CRE
slv5 :=( others => '0') I_BTN
slbit := '0' RXVAL
slbit := '1' O_MEM_ADV_N
slbit := '0' CTS_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' RTS_N
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_PPCM_RST_N
slbit := '0' O_FUSP_RTS_N
slv8 :=( others => '0') TXDATA
slbit := '1' I_RXD
slbit := '0' I_FUSP_CTS_N
Definition: xlib.vhd:35