w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
tb_arty.vhd
Go to the documentation of this file.
1-- $Id: tb_arty.vhd 1211 2021-08-28 11:20:34Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2016-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: tb_arty - sim
7-- Description: Test bench for arty (base)
8--
9-- Dependencies: simlib/simclk
10-- simlib/simclkcnt
11-- rlink/tbcore/tbcore_rlink
12-- xlib/sfs_gsim_core
13-- tb_arty_core
14-- serport/tb/serport_master_tb
15-- arty_aif [UUT]
16--
17-- To test: generic, any arty_aif target
18--
19-- Target Devices: generic
20-- Tool versions: viv 2015.4-2018.2; ghdl 0.33-0.34
21--
22-- Revision History:
23-- Date Rev Version Comment
24-- 2018-11-03 1064 1.3.1 use sfs_gsim_core
25-- 2016-09-18 809 1.3 add gsr_pulse (provisional....)
26-- 2016-09-02 805 1.2.1 tbcore_rlink without CLK_STOP now
27-- 2016-03-20 748 1.2 BUGFIX: add PORTSEL_XON logic
28-- 2016-03-06 740 1.1 add A_VPWRN/P to baseline config
29-- 2016-02-20 734 1.0.2 use s7_cmt_sfs_tb to avoid xsim conflict
30-- 2016-02-13 730 1.0.1 direct instantiation of tbcore_rlink
31-- 2016-01-31 726 1.0 Initial version (derived from tb_basys3)
32------------------------------------------------------------------------------
33
34library ieee;
35use ieee.std_logic_1164.all;
36use ieee.numeric_std.all;
37use ieee.std_logic_textio.all;
38use std.textio.all;
39
40use work.slvtypes.all;
41use work.rlinklib.all;
42use work.xlib.all;
43use work.artylib.all;
44use work.simlib.all;
45use work.simbus.all;
46use work.sys_conf.all;
47
48entity tb_arty is
49end tb_arty;
50
51architecture sim of tb_arty is
52
53 signal CLKOSC : slbit := '0'; -- board clock (100 Mhz)
54 signal CLKCOM : slbit := '0'; -- communication clock
55
56 signal CLKCOM_CYCLE : integer := 0;
57
58 signal RESET : slbit := '0';
59 signal CLKDIV : slv2 := "00"; -- run with 1 clocks / bit !!
60 signal RXDATA : slv8 := (others=>'0');
61 signal RXVAL : slbit := '0';
62 signal RXERR : slbit := '0';
63 signal RXACT : slbit := '0';
64 signal TXDATA : slv8 := (others=>'0');
65 signal TXENA : slbit := '0';
66 signal TXBUSY : slbit := '0';
67
68 signal I_RXD : slbit := '1';
69 signal O_TXD : slbit := '1';
70 signal I_SWI : slv4 := (others=>'0');
71 signal I_BTN : slv4 := (others=>'0');
72 signal O_LED : slv4 := (others=>'0');
73 signal O_RGBLED0 : slv3 := (others=>'0');
74 signal O_RGBLED1 : slv3 := (others=>'0');
75 signal O_RGBLED2 : slv3 := (others=>'0');
76 signal O_RGBLED3 : slv3 := (others=>'0');
77
78 signal R_PORTSEL_XON : slbit := '0'; -- if 1 use xon/xoff
79
80 constant sbaddr_portsel: slv8 := slv(to_unsigned( 8,8));
81
82 constant clock_period : Delay_length := 10 ns;
83 constant clock_offset : Delay_length := 200 ns;
84
85begin
86
87 GINIT : entity work.gsr_pulse;
88
89 CLKGEN : simclk
90 generic map (
93 port map (
94 CLK => CLKOSC
95 );
96
97 CLKGEN_COM : sfs_gsim_core
98 generic map (
99 VCO_DIVIDE => sys_conf_clkser_vcodivide,
100 VCO_MULTIPLY => sys_conf_clkser_vcomultiply,
101 OUT_DIVIDE => sys_conf_clkser_outdivide)
102 port map (
103 CLKIN => CLKOSC,
104 CLKFX => CLKCOM,
105 LOCKED => open
106 );
107
108 CLKCNT : simclkcnt port map (CLK => CLKCOM, CLK_CYCLE => CLKCOM_CYCLE);
109
110 TBCORE : entity work.tbcore_rlink
111 port map (
112 CLK => CLKCOM,
113 RX_DATA => TXDATA,
114 RX_VAL => TXENA,
115 RX_HOLD => TXBUSY,
116 TX_DATA => RXDATA,
117 TX_ENA => RXVAL
118 );
119
120 ARTYCORE : entity work.tb_arty_core
121 port map (
122 I_SWI => I_SWI,
123 I_BTN => I_BTN
124 );
125
126 UUT : arty_aif
127 port map (
128 I_CLK100 => CLKOSC,
129 I_RXD => I_RXD,
130 O_TXD => O_TXD,
131 I_SWI => I_SWI,
132 I_BTN => I_BTN,
133 O_LED => O_LED,
134 O_RGBLED0 => O_RGBLED0,
135 O_RGBLED1 => O_RGBLED1,
136 O_RGBLED2 => O_RGBLED2,
137 O_RGBLED3 => O_RGBLED3,
138 A_VPWRN => (others=>'0'),
139 A_VPWRP => (others=>'0')
140 );
141
142 SERMSTR : entity work.serport_master_tb
143 generic map (
144 CDWIDTH => CLKDIV'length)
145 port map (
146 CLK => CLKCOM,
147 RESET => RESET,
148 CLKDIV => CLKDIV,
150 ENAESC => '0',
151 RXDATA => RXDATA,
152 RXVAL => RXVAL,
153 RXERR => RXERR,
154 RXOK => '1',
155 TXDATA => TXDATA,
156 TXENA => TXENA,
157 TXBUSY => TXBUSY,
158 RXSD => O_TXD,
159 TXSD => I_RXD,
160 RXRTS_N => open,
161 TXCTS_N => '0'
162 );
163
164 proc_moni: process
165 variable oline : line;
166 begin
167
168 loop
169 wait until rising_edge(CLKCOM);
170
171 if RXERR = '1' then
172 writetimestamp(oline, CLKCOM_CYCLE, " : seen RXERR=1");
173 writeline(output, oline);
174 end if;
175
176 end loop;
177
178 end process proc_moni;
179
180 --
181 -- Notes on portsel and XON control:
182 -- - most arty designs will use hardwired XON=1
183 -- - but some (especially basis tests) might not use flow control
184 -- - that's why XON flow control must be optional and configurable !
185 --
186 proc_simbus: process (SB_VAL)
187 begin
188 if SB_VAL'event and to_x01(SB_VAL)='1' then
189 if SB_ADDR = sbaddr_portsel then
190 R_PORTSEL_XON <= to_x01(SB_DATA(1));
191 end if;
192 end if;
193 end process proc_simbus;
194
195end sim;
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'
VCO_DIVIDE positive := 1
OUT_DIVIDE positive := 1
in CLKIN slbit
VCO_MULTIPLY positive := 1
out LOCKED slbit
out CLKFX slbit
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( 3 downto 0) slv4
Definition: slvtypes.vhd:36
std_logic_vector( 2 downto 0) slv3
Definition: slvtypes.vhd:35
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
slbit := '0' RXERR
Definition: tb_arty.vhd:62
slbit := '0' RESET
Definition: tb_arty.vhd:58
slv4 :=( others => '0') I_SWI
Definition: tb_arty.vhd:70
integer := 0 CLKCOM_CYCLE
Definition: tb_arty.vhd:56
Delay_length := 10 ns clock_period
Definition: tb_arty.vhd:82
slv2 := "00" CLKDIV
Definition: tb_arty.vhd:59
slv4 :=( others => '0') I_BTN
Definition: tb_arty.vhd:71
slbit := '0' TXENA
Definition: tb_arty.vhd:65
slv8 :=( others => '0') RXDATA
Definition: tb_arty.vhd:60
Delay_length := 200 ns clock_offset
Definition: tb_arty.vhd:83
slv3 :=( others => '0') O_RGBLED2
Definition: tb_arty.vhd:75
slbit := '0' RXACT
Definition: tb_arty.vhd:63
slbit := '0' RXVAL
Definition: tb_arty.vhd:61
slbit := '1' O_TXD
Definition: tb_arty.vhd:69
slv8 := slv( to_unsigned( 8, 8) ) sbaddr_portsel
Definition: tb_arty.vhd:80
slv3 :=( others => '0') O_RGBLED1
Definition: tb_arty.vhd:74
slbit := '0' CLKOSC
Definition: tb_arty.vhd:53
slv3 :=( others => '0') O_RGBLED3
Definition: tb_arty.vhd:76
slbit := '0' CLKCOM
Definition: tb_arty.vhd:54
slbit := '0' TXBUSY
Definition: tb_arty.vhd:66
slv3 :=( others => '0') O_RGBLED0
Definition: tb_arty.vhd:73
slbit := '0' R_PORTSEL_XON
Definition: tb_arty.vhd:78
slv8 :=( others => '0') TXDATA
Definition: tb_arty.vhd:64
slv4 :=( others => '0') O_LED
Definition: tb_arty.vhd:72
slbit := '1' I_RXD
Definition: tb_arty.vhd:68
out I_SWI slv4
out I_BTN slv4
Definition: xlib.vhd:35