w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
sys_tst_rlink_n4d.vhd
Go to the documentation of this file.
1-- $Id: sys_tst_rlink_n4d.vhd 1247 2022-07-06 07:04:33Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2017-2022 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: sys_tst_rlink_n4d - syn
7-- Description: rlink tester design for nexys4d
8--
9-- Dependencies: vlib/xlib/s7_cmt_sfs
10-- vlib/genlib/clkdivce
11-- bplib/bpgen/bp_rs232_4line_iob
12-- bplib/bpgen/sn_humanio_rbus
13-- vlib/rlink/rlink_sp1c
14-- rbd_tst_rlink
15-- bplib/bpgen/rgbdrv_master
16-- bplib/bpgen/rgbdrv_analog_rbus
17-- bplib/sysmon/sysmonx_rbus_base
18-- vlib/rbus/rbd_usracc
19-- vlib/rbus/rb_sres_or_2
20-- vlib/rbus/rb_sres_or_6
21--
22-- Test bench: tb/tb_tst_rlink_n4d
23--
24-- Target Devices: generic
25-- Tool versions: viv 2014.4-2022.1; ghdl 0.29-2.0.0
26--
27-- Synthesized:
28-- Date Rev viv Target flop lutl lutm bram slic
29-- 2022-07-05 1247 2022.1 xc7a100t-1 1181 1611 34 3.0 581
30-- 2019-02-02 1108 2018.3 xc7a100t-1 1179 1721 36 3.0 597
31-- 2019-02-02 1108 2017.2 xc7a100t-1 1179 1802 36 3.0 619
32-- 2016-04-02 758 2015.4 xc7a100t-1 1113 1461 36 3.0 528 usracc
33-- 2016-03-27 753 2015.4 xc7a100t-1 1124 1461 36 3.0 522 meminf
34-- 2016-03-13 743 2015.4 xc7a100t-1 1124 1463 64 4.5 567 +XADC
35-- 2016-02-20 734 2015.4 xc7a100t-1 1080 1424 64 4.5 502 +RGB
36-- 2015-01-31 640 2014.4 xc7a100t-1 990 1360 64 4.5 495
37--
38-- Revision History:
39-- Date Rev Version Comment
40-- 2016-06-05 772 1.5.3 use CDUWIDTH=7, 120 MHz clock is natural choice
41-- 2016-04-02 758 1.5.2 add rbd_usracc_e2 (bitfile+jtag timestamp access)
42-- 2016-03-19 748 1.5.1 define rlink SYSID
43-- 2016-03-12 741 1.5 add sysmon_rbus
44-- 2016-02-20 734 1.4.2 add rgbdrv_analog_rbus for two rgb leds
45-- 2015-04-11 666 1.4.1 rearrange XON handling
46-- 2015-02-06 643 1.4 factor out memory
47-- 2015-02-01 641 1.3.1 separate I_BTNRST_N; autobaud on msb of display
48-- 2015-01-31 640 1.3 drop fusp iface; use new sn_hio
49-- 2014-11-09 603 1.2 use new rlink v4 iface and 4 bit STAT
50-- 2014-08-15 583 1.1 rb_mreq addr now 16 bit
51-- 2013-09-28 535 1.0 Initial version (derived from sys_tst_rlink_n3)
52------------------------------------------------------------------------------
53-- Usage of Nexys 4DDR Switches, Buttons, LEDs:
54--
55-- SWI(7:2): no function (only connected to sn_humanio_rbus)
56-- SWI(1): 1 enable XON
57-- SWI(0): -unused-
58--
59-- LED(7): SER_MONI.abact
60-- LED(6:2): no function (only connected to sn_humanio_rbus)
61-- LED(1): timer 1 busy
62-- LED(0): timer 0 busy
63--
64-- DSP: SER_MONI.clkdiv (from auto bauder)
65-- DP(3): not SER_MONI.txok (shows tx back pressure)
66-- DP(2): SER_MONI.txact (shows tx activity)
67-- DP(1): not SER_MONI.rxok (shows rx back pressure)
68-- DP(0): SER_MONI.rxact (shows rx activity)
69--
70
71library ieee;
72use ieee.std_logic_1164.all;
73
74use work.slvtypes.all;
75use work.xlib.all;
76use work.genlib.all;
77use work.serportlib.all;
78use work.rblib.all;
79use work.rbdlib.all;
80use work.rlinklib.all;
81use work.bpgenlib.all;
82use work.bpgenrbuslib.all;
83use work.sysmonrbuslib.all;
84use work.sys_conf.all;
85
86-- ----------------------------------------------------------------------------
87
88entity sys_tst_rlink_n4d is -- top level
89 -- implements nexys4d_aif
90 port (
91 I_CLK100 : in slbit; -- 100 MHz clock
92 I_RXD : in slbit; -- receive data (board view)
93 O_TXD : out slbit; -- transmit data (board view)
94 O_RTS_N : out slbit; -- rx rts (board view; act.low)
95 I_CTS_N : in slbit; -- tx cts (board view; act.low)
96 I_SWI : in slv16; -- n4d switches
97 I_BTN : in slv5; -- n4d buttons
98 I_BTNRST_N : in slbit; -- n4d reset button
99 O_LED : out slv16; -- n4d leds
100 O_RGBLED0 : out slv3; -- n4d rgb-led 0
101 O_RGBLED1 : out slv3; -- n4d rgb-led 1
102 O_ANO_N : out slv8; -- 7 segment disp: anodes (act.low)
103 O_SEG_N : out slv8 -- 7 segment disp: segments (act.low)
104 );
106
107architecture syn of sys_tst_rlink_n4d is
108
109 signal CLK : slbit := '0';
110
111 signal RXD : slbit := '1';
112 signal TXD : slbit := '0';
113 signal RTS_N : slbit := '0';
114 signal CTS_N : slbit := '0';
115
116 signal SWI : slv16 := (others=>'0');
117 signal BTN : slv5 := (others=>'0');
118 signal LED : slv16 := (others=>'0');
119 signal DSP_DAT : slv32 := (others=>'0');
120 signal DSP_DP : slv8 := (others=>'0');
121
122 signal RESET : slbit := '0';
123 signal CE_USEC : slbit := '0';
124 signal CE_MSEC : slbit := '0';
125
126 signal RB_MREQ : rb_mreq_type := rb_mreq_init;
127 signal RB_SRES : rb_sres_type := rb_sres_init;
128 signal RB_SRES_HIO : rb_sres_type := rb_sres_init;
129 signal RB_SRES_TST : rb_sres_type := rb_sres_init;
130 signal RB_SRES_RGB0 : rb_sres_type := rb_sres_init;
131 signal RB_SRES_RGB1 : rb_sres_type := rb_sres_init;
132 signal RB_SRES_RGB : rb_sres_type := rb_sres_init;
133 signal RB_SRES_SYSMON : rb_sres_type := rb_sres_init;
134 signal RB_SRES_USRACC : rb_sres_type := rb_sres_init;
135
136 signal RB_LAM : slv16 := (others=>'0');
137 signal RB_STAT : slv4 := (others=>'0');
138
139 signal SER_MONI : serport_moni_type := serport_moni_init;
140 signal STAT : slv8 := (others=>'0');
141
142 signal RGBCNTL : slv3 := (others=>'0');
143 signal DIMCNTL : slv12 := (others=>'0');
144
145 constant rbaddr_hio : slv16 := x"fef0"; -- fef0/0008: 1111 1110 1111 0xxx
146 constant rbaddr_rgb0 : slv16 := x"fc00"; -- fe00/0004: 1111 1100 0000 00xx
147 constant rbaddr_rgb1 : slv16 := x"fc04"; -- fe04/0004: 1111 1100 0000 01xx
148 constant rbaddr_sysmon: slv16 := x"fb00"; -- fb00/0080: 1111 1011 0xxx xxxx
149
150 constant sysid_proj : slv16 := x"0101"; -- tst_rlink
151 constant sysid_board : slv8 := x"08"; -- nexys4d
152 constant sysid_vers : slv8 := x"00";
153
154begin
155
156 assert (sys_conf_clksys mod 1000000) = 0
157 report "assert sys_conf_clksys on MHz grid"
158 severity failure;
159
160 RESET <= '0'; -- so far not used
161
162 GEN_CLKSYS : s7_cmt_sfs
163 generic map (
164 VCO_DIVIDE => sys_conf_clksys_vcodivide,
165 VCO_MULTIPLY => sys_conf_clksys_vcomultiply,
166 OUT_DIVIDE => sys_conf_clksys_outdivide,
167 CLKIN_PERIOD => 10.0,
168 CLKIN_JITTER => 0.01,
169 STARTUP_WAIT => false,
170 GEN_TYPE => sys_conf_clksys_gentype)
171 port map (
172 CLKIN => I_CLK100,
173 CLKFX => CLK,
174 LOCKED => open
175 );
176
177 CLKDIV : clkdivce
178 generic map (
179 CDUWIDTH => 7, -- good up to 127 MHz
180 USECDIV => sys_conf_clksys_mhz,
181 MSECDIV => 1000)
182 port map (
183 CLK => CLK,
184 CE_USEC => CE_USEC,
186 );
187
188 IOB_RS232 : bp_rs232_4line_iob
189 port map (
190 CLK => CLK,
191 RXD => RXD,
192 TXD => TXD,
193 CTS_N => CTS_N,
194 RTS_N => RTS_N,
195 I_RXD => I_RXD,
196 O_TXD => O_TXD,
197 I_CTS_N => I_CTS_N,
199 );
200
201 HIO : sn_humanio_rbus
202 generic map (
203 SWIDTH => 16,
204 BWIDTH => 5,
205 LWIDTH => 16,
206 DCWIDTH => 3,
207 DEBOUNCE => sys_conf_hio_debounce,
209 port map (
210 CLK => CLK,
211 RESET => RESET,
212 CE_MSEC => CE_MSEC,
213 RB_MREQ => RB_MREQ,
215 SWI => SWI,
216 BTN => BTN,
217 LED => LED,
218 DSP_DAT => DSP_DAT,
219 DSP_DP => DSP_DP,
220 I_SWI => I_SWI,
221 I_BTN => I_BTN,
222 O_LED => O_LED,
223 O_ANO_N => O_ANO_N,
225 );
226
227 RLINK : rlink_sp1c
228 generic map (
229 BTOWIDTH => 6,
230 RTAWIDTH => 12,
231 SYSID => sysid_proj & sysid_board & sysid_vers ,
232 IFAWIDTH => 5,
233 OFAWIDTH => 5,
234 ENAPIN_RLMON => sbcntl_sbf_rlmon,
235 ENAPIN_RBMON => sbcntl_sbf_rbmon,
236 CDWIDTH => 12,
237 CDINIT => sys_conf_ser2rri_cdinit,
238 RBMON_AWIDTH => 0, -- must be 0, rbmon in rbd_tst_rlink
239 RBMON_RBADDR => (others=>'0'))
240 port map (
241 CLK => CLK,
242 CE_USEC => CE_USEC,
243 CE_MSEC => CE_MSEC,
244 CE_INT => CE_MSEC,
245 RESET => RESET,
246 ENAXON => SWI(1),
247 ESCFILL => '0',
248 RXSD => RXD,
249 TXSD => TXD,
250 CTS_N => CTS_N,
251 RTS_N => RTS_N,
252 RB_MREQ => RB_MREQ,
253 RB_SRES => RB_SRES,
254 RB_LAM => RB_LAM,
255 RB_STAT => RB_STAT,
256 RL_MONI => open,
258 );
259
260 RBDTST : entity work.rbd_tst_rlink
261 port map (
262 CLK => CLK,
263 RESET => RESET,
264 CE_USEC => CE_USEC,
265 RB_MREQ => RB_MREQ,
267 RB_LAM => RB_LAM,
268 RB_STAT => RB_STAT,
270 RXSD => RXD,
271 RXACT => SER_MONI.rxact,
272 STAT => STAT
273 );
274
275 RGBMSTR : rgbdrv_master
276 generic map (
277 DWIDTH => DIMCNTL'length)
278 port map (
279 CLK => CLK,
280 RESET => RESET,
281 CE_USEC => CE_USEC,
282 RGBCNTL => RGBCNTL,
284 );
285
286 RGB0 : rgbdrv_analog_rbus
287 generic map (
288 DWIDTH => DIMCNTL'length,
290 port map (
291 CLK => CLK,
292 RESET => RESET,
293 RB_MREQ => RB_MREQ,
295 RGBCNTL => RGBCNTL,
296 DIMCNTL => DIMCNTL,
298 );
299
300 RGB1 : rgbdrv_analog_rbus
301 generic map (
302 DWIDTH => DIMCNTL'length,
304 port map (
305 CLK => CLK,
306 RESET => RESET,
307 RB_MREQ => RB_MREQ,
309 RGBCNTL => RGBCNTL,
310 DIMCNTL => DIMCNTL,
312 );
313
314
315 SMRB : if sys_conf_rbd_sysmon generate
317 generic map ( -- use default INIT_ (Vccint=1.00)
318 CLK_MHZ => sys_conf_clksys_mhz,
320 port map (
321 CLK => CLK,
322 RESET => RESET,
323 RB_MREQ => RB_MREQ,
325 ALM => open,
326 OT => open,
327 TEMP => open
328 );
329 end generate SMRB;
330
331 UARB : rbd_usracc
332 port map (
333 CLK => CLK,
334 RB_MREQ => RB_MREQ,
336 );
337
338 RB_SRES_ORRGB : rb_sres_or_2
339 port map (
343 );
344
345 RB_SRES_OR1 : rb_sres_or_6
346 port map (
353 );
354
355 DSP_DAT(31 downto 20) <= SER_MONI.abclkdiv(11 downto 0);
356 DSP_DAT(19) <= '0';
357 DSP_DAT(18 downto 16) <= SER_MONI.abclkdiv_f;
358 DSP_DP(7 downto 4) <= "0010";
359
360 DSP_DAT(15 downto 0) <= (others=>'0');
361
362 DSP_DP(3) <= not SER_MONI.txok;
363 DSP_DP(2) <= SER_MONI.txact;
364 DSP_DP(1) <= not SER_MONI.rxok;
365 DSP_DP(0) <= SER_MONI.rxact;
366
367 LED(15 downto 8) <= SWI(15 downto 8);
368 LED(7) <= SER_MONI.abact;
369 LED(6 downto 2) <= (others=>'0');
370 LED(1) <= STAT(1);
371 LED(0) <= STAT(0);
372
373end syn;
out CE_MSEC slbit
Definition: clkdivce.vhd:39
USECDIV positive := 50
Definition: clkdivce.vhd:33
CDUWIDTH positive := 6
Definition: clkdivce.vhd:32
out CE_USEC slbit
Definition: clkdivce.vhd:37
MSECDIV positive := 1000
Definition: clkdivce.vhd:34
in CLK slbit
Definition: clkdivce.vhd:36
in RB_SRES_2 rb_sres_type := rb_sres_init
out RB_SRES_OR rb_sres_type
in RB_SRES_1 rb_sres_type
in RB_SRES_2 rb_sres_type := rb_sres_init
in RB_SRES_3 rb_sres_type := rb_sres_init
out RB_SRES_OR rb_sres_type
in RB_SRES_1 rb_sres_type
in RB_SRES_4 rb_sres_type := rb_sres_init
in RB_SRES_5 rb_sres_type := rb_sres_init
in CLK slbit
Definition: rbd_usracc.vhd:40
in RB_MREQ rb_mreq_type
Definition: rbd_usracc.vhd:41
out RB_SRES rb_sres_type
Definition: rbd_usracc.vhd:43
Definition: rblib.vhd:32
RB_ADDR slv16 := x"0000"
in DIMCNTL slv( DWIDTH- 1 downto 0)
in RB_MREQ rb_mreq_type
out RB_SRES rb_sres_type
in RESET slbit := '0'
DWIDTH positive := 8
in CE_USEC slbit
in CLK slbit
in RESET slbit := '0'
out RGBCNTL slv3
out DIMCNTL slv( DWIDTH- 1 downto 0)
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
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( 11 downto 0) slv12
Definition: slvtypes.vhd:44
std_logic_vector( 2 downto 0) slv3
Definition: slvtypes.vhd:35
std_logic_vector( 31 downto 0) slv32
Definition: slvtypes.vhd:59
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
in DSP_DP slv(( 2** DCWIDTH)- 1 downto 0)
DEBOUNCE boolean := true
out O_LED slv( LWIDTH- 1 downto 0)
RB_ADDR slv16 := x"fef0"
in DSP_DAT slv( 4*( 2** DCWIDTH)- 1 downto 0)
DCWIDTH positive := 2
out SWI slv( SWIDTH- 1 downto 0)
in I_BTN slv( BWIDTH- 1 downto 0)
LWIDTH positive := 8
in I_SWI slv( SWIDTH- 1 downto 0)
SWIDTH positive := 8
out BTN slv( BWIDTH- 1 downto 0)
in RB_MREQ rb_mreq_type
BWIDTH positive := 4
out O_ANO_N slv(( 2** DCWIDTH)- 1 downto 0)
out RB_SRES rb_sres_type
in LED slv( LWIDTH- 1 downto 0)
in RESET slbit := '0'
CLK_MHZ integer := 250
RB_ADDR slv16 := x"fb00"
in RB_MREQ rb_mreq_type
out RB_SRES rb_sres_type
in RESET slbit := '0'
Definition: xlib.vhd:35