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