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