w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
tb_cmoda7.vhd
Go to the documentation of this file.
1-- $Id: tb_cmoda7.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2017-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: tb_cmoda7 - sim
7-- Description: Test bench for cmoda7 (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-- cmoda7_aif [UUT]
16--
17-- To test: generic, any cmoda7_aif target
18--
19-- Target Devices: generic
20-- Tool versions: viv 2016.4-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-- 2017-06-04 906 1.0 Initial version (derived from tb_arty)
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.cmoda7lib.all;
38use work.simlib.all;
39use work.simbus.all;
40use work.sys_conf.all;
41
42entity tb_cmoda7 is
43end tb_cmoda7;
44
45architecture sim of tb_cmoda7 is
46
47 signal CLKOSC : slbit := '0'; -- board clock (12 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_BTN : slv2 := (others=>'0');
65 signal O_LED : slv2 := (others=>'0');
66 signal O_RGBLED0_N : slv3 := (others=>'0');
67
68 signal R_PORTSEL_XON : slbit := '0'; -- if 1 use xon/xoff
69
70 constant sbaddr_portsel: slv8 := slv(to_unsigned( 8,8));
71
72 constant clock_period : Delay_length := 83.333 ns;
73 constant clock_offset : Delay_length := 2000 ns;
74
75begin
76
77 GINIT : entity work.gsr_pulse;
78
79 CLKGEN : simclk
80 generic map (
83 port map (
84 CLK => CLKOSC
85 );
86
87 CLKGEN_COM : sfs_gsim_core
88 generic map (
89 VCO_DIVIDE => sys_conf_clkser_vcodivide,
90 VCO_MULTIPLY => sys_conf_clkser_vcomultiply,
91 OUT_DIVIDE => sys_conf_clkser_outdivide)
92 port map (
93 CLKIN => CLKOSC,
94 CLKFX => CLKCOM,
95 LOCKED => open
96 );
97
98 CLKCNT : simclkcnt port map (CLK => CLKCOM, CLK_CYCLE => CLKCOM_CYCLE);
99
100 TBCORE : entity work.tbcore_rlink
101 port map (
102 CLK => CLKCOM,
103 RX_DATA => TXDATA,
104 RX_VAL => TXENA,
105 RX_HOLD => TXBUSY,
106 TX_DATA => RXDATA,
107 TX_ENA => RXVAL
108 );
109
110 C7CORE : entity work.tb_cmoda7_core
111 port map (
112 I_BTN => I_BTN
113 );
114
115 UUT : cmoda7_aif
116 port map (
117 I_CLK12 => CLKOSC,
118 I_RXD => I_RXD,
119 O_TXD => O_TXD,
120 I_BTN => I_BTN,
121 O_LED => O_LED,
122 O_RGBLED0_N => O_RGBLED0_N
123 );
124
125 SERMSTR : entity work.serport_master_tb
126 generic map (
127 CDWIDTH => CLKDIV'length)
128 port map (
129 CLK => CLKCOM,
130 RESET => RESET,
131 CLKDIV => CLKDIV,
133 ENAESC => '0',
134 RXDATA => RXDATA,
135 RXVAL => RXVAL,
136 RXERR => RXERR,
137 RXOK => '1',
138 TXDATA => TXDATA,
139 TXENA => TXENA,
140 TXBUSY => TXBUSY,
141 RXSD => O_TXD,
142 TXSD => I_RXD,
143 RXRTS_N => open,
144 TXCTS_N => '0'
145 );
146
147 proc_moni: process
148 variable oline : line;
149 begin
150
151 loop
152 wait until rising_edge(CLKCOM);
153
154 if RXERR = '1' then
155 writetimestamp(oline, CLKCOM_CYCLE, " : seen RXERR=1");
156 writeline(output, oline);
157 end if;
158
159 end loop;
160
161 end process proc_moni;
162
163 --
164 -- Notes on portsel and XON control:
165 -- - most cmoda7 designs will use hardwired XON=1
166 -- - but some (especially basis tests) might not use flow control
167 -- - that's why XON flow control must be optional and configurable !
168 --
169 proc_simbus: process (SB_VAL)
170 begin
171 if SB_VAL'event and to_x01(SB_VAL)='1' then
172 if SB_ADDR = sbaddr_portsel then
173 R_PORTSEL_XON <= to_x01(SB_DATA(1));
174 end if;
175 end if;
176 end process proc_simbus;
177
178end 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( 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_cmoda7.vhd:56
slbit := '0' RESET
Definition: tb_cmoda7.vhd:52
integer := 0 CLKCOM_CYCLE
Definition: tb_cmoda7.vhd:50
slv2 := "00" CLKDIV
Definition: tb_cmoda7.vhd:53
Delay_length := 83.333 ns clock_period
Definition: tb_cmoda7.vhd:72
slbit := '0' TXENA
Definition: tb_cmoda7.vhd:59
slv8 :=( others => '0') RXDATA
Definition: tb_cmoda7.vhd:54
Delay_length := 2000 ns clock_offset
Definition: tb_cmoda7.vhd:73
slbit := '0' RXACT
Definition: tb_cmoda7.vhd:57
slv2 :=( others => '0') I_BTN
Definition: tb_cmoda7.vhd:64
slbit := '0' RXVAL
Definition: tb_cmoda7.vhd:55
slbit := '1' O_TXD
Definition: tb_cmoda7.vhd:63
slv8 := slv( to_unsigned( 8, 8) ) sbaddr_portsel
Definition: tb_cmoda7.vhd:70
slbit := '0' CLKOSC
Definition: tb_cmoda7.vhd:47
slv3 :=( others => '0') O_RGBLED0_N
Definition: tb_cmoda7.vhd:66
slbit := '0' CLKCOM
Definition: tb_cmoda7.vhd:48
slbit := '0' TXBUSY
Definition: tb_cmoda7.vhd:60
slbit := '0' R_PORTSEL_XON
Definition: tb_cmoda7.vhd:68
slv2 :=( others => '0') O_LED
Definition: tb_cmoda7.vhd:65
slv8 :=( others => '0') TXDATA
Definition: tb_cmoda7.vhd:58
slbit := '1' I_RXD
Definition: tb_cmoda7.vhd:62
Definition: xlib.vhd:35