w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
tbd_rlink_sp1c.vhd
Go to the documentation of this file.
1-- $Id: tbd_rlink_sp1c.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2007-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: tbd_rlink_sp1c - syn
7-- Description: Wrapper for rlink_core plus rlink_serport with an interface
8-- compatible to the rlink_core only module.
9-- NOTE: this implementation is a hack, should be redone
10-- using configurations.
11--
12-- Dependencies: tbu_rlink_sp1c [UUT]
13-- serport_uart_tx
14-- serport_uart_rx
15-- byte2cdata
16-- cdata2byte
17-- simlib/simclkcnt
18--
19-- To test: rlink_sp1c
20--
21-- Target Devices: generic
22-- Tool versions: xst 8.2-14.7; ghdl 0.18-0.31
23--
24-- Revision History:
25-- Date Rev Version Comment
26-- 2014-08-28 588 4.0 use new rlink v4 iface and 4 bit STAT
27-- 2011-12-23 444 3.2 use simclkcnt instead of simbus global
28-- 2011-12-22 442 3.1 renamed and retargeted to tbu_rlink_sp1c
29-- 2011-11-19 427 3.0.5 now numeric_std clean
30-- 2010-12-28 350 3.0.4 use CLKDIV/CDINIT=0;
31-- 2010-12-26 348 3.0.3 add RTS/CTS ports for tbu_;
32-- 2010-12-24 347 3.0.2 rename: CP_*->RL->*
33-- 2010-12-22 346 3.0.1 removed proc_moni, use .rlmon cmd in test bench
34-- 2010-12-05 343 3.0 rri->rlink renames; port to rbus V3 protocol;
35-- 2010-06-06 301 2.3 use NCOMM=4 (new eop,nak commas)
36-- 2010-05-02 287 2.2.2 ren CE_XSEC->CE_INT,RP_STAT->RB_STAT,AP_LAM->RB_LAM
37-- drop RP_IINT signal from interfaces
38-- 2010-04-24 281 2.2.1 use serport_uart_[tr]x directly again
39-- 2010-04-03 274 2.2 add CE_USEC
40-- 2009-03-14 197 2.1 remove records in interface to allow _ssim usage
41-- 2008-08-24 162 2.0 with new rb_mreq/rb_sres interface
42-- 2007-11-25 98 1.1 added RP_IINT support; use entity rather arch
43-- name to switch core/serport;
44-- use serport_uart_[tr]x_tb to allow that UUT is a
45-- [sft]sim model compiled with keep hierarchy
46-- 2007-07-02 63 1.0 Initial version
47------------------------------------------------------------------------------
48
49library ieee;
50use ieee.std_logic_1164.all;
51use ieee.numeric_std.all;
52use ieee.std_logic_textio.all;
53use std.textio.all;
54
55use work.slvtypes.all;
56use work.rlinklib.all;
57use work.comlib.all;
58use work.serportlib.all;
59use work.simlib.all;
60use work.simbus.all;
61
62entity tbd_rlink_sp1c is -- rlink_sp1c tb design
63 -- implements tbd_rlink_gen
64 port (
65 CLK : in slbit; -- clock
66 CE_INT : in slbit; -- rlink ito time unit clock enable
67 CE_USEC : in slbit; -- 1 usec clock enable
68 RESET : in slbit; -- reset
69 RL_DI : in slv9; -- rlink: data in
70 RL_ENA : in slbit; -- rlink: data enable
71 RL_BUSY : out slbit; -- rlink: data busy
72 RL_DO : out slv9; -- rlink: data out
73 RL_VAL : out slbit; -- rlink: data valid
74 RL_HOLD : in slbit; -- rlink: data hold
75 RB_MREQ_aval : out slbit; -- rbus: request - aval
76 RB_MREQ_re : out slbit; -- rbus: request - re
77 RB_MREQ_we : out slbit; -- rbus: request - we
78 RB_MREQ_initt : out slbit; -- rbus: request - init; avoid name coll
79 RB_MREQ_addr : out slv16; -- rbus: request - addr
80 RB_MREQ_din : out slv16; -- rbus: request - din
81 RB_SRES_ack : in slbit; -- rbus: response - ack
82 RB_SRES_busy : in slbit; -- rbus: response - busy
83 RB_SRES_err : in slbit; -- rbus: response - err
84 RB_SRES_dout : in slv16; -- rbus: response - dout
85 RB_LAM : in slv16; -- rbus: look at me
86 RB_STAT : in slv4; -- rbus: status flags
87 TXRXACT : out slbit -- txrx active flag
88 );
89end entity tbd_rlink_sp1c;
90
91
92architecture syn of tbd_rlink_sp1c is
93
94 constant CDWIDTH : positive := 13;
95 constant c_cdinit : natural := 0; -- NOTE: change in tbu_rlink_sp1c !!
96
97 signal RRI_RXSD : slbit := '0';
98 signal RRI_TXSD : slbit := '0';
99 signal RTS_N : slbit := '0';
100 signal RXDATA : slv8 := (others=>'0');
101 signal RXVAL : slbit := '0';
102 signal RXACT : slbit := '0';
103 signal TXDATA : slv8 := (others=>'0');
104 signal TXENA : slbit := '0';
105 signal TXBUSY : slbit := '0';
106 signal CLKDIV : slv13 := slv(to_unsigned(c_cdinit,CDWIDTH));
107 signal CLK_CYCLE : integer := 0;
108
109component tbu_rlink_sp1c is -- rlink core+serport combo
110 port (
111 CLK : in slbit; -- clock
112 CE_INT : in slbit; -- rlink ito time unit clock enable
113 CE_USEC : in slbit; -- 1 usec clock enable
114 CE_MSEC : in slbit; -- 1 msec clock enable
115 RESET : in slbit; -- reset
116 RXSD : in slbit; -- receive serial data (board view)
117 TXSD : out slbit; -- transmit serial data (board view)
118 CTS_N : in slbit; -- clear to send (act.low, board view)
119 RTS_N : out slbit; -- request to send (act.low, board view)
120 RB_MREQ_aval : out slbit; -- rbus: request - aval
121 RB_MREQ_re : out slbit; -- rbus: request - re
122 RB_MREQ_we : out slbit; -- rbus: request - we
123 RB_MREQ_initt : out slbit; -- rbus: request - init; avoid name coll
124 RB_MREQ_addr : out slv16; -- rbus: request - addr
125 RB_MREQ_din : out slv16; -- rbus: request - din
126 RB_SRES_ack : in slbit; -- rbus: response - ack
127 RB_SRES_busy : in slbit; -- rbus: response - busy
128 RB_SRES_err : in slbit; -- rbus: response - err
129 RB_SRES_dout : in slv16; -- rbus: response - dout
130 RB_LAM : in slv16; -- rbus: look at me
131 RB_STAT : in slv4 -- rbus: status flags
132 );
133end component;
134
135begin
136
137 TBU : tbu_rlink_sp1c
138 port map (
139 CLK => CLK,
140 CE_INT => CE_INT,
141 CE_USEC => CE_USEC,
142 CE_MSEC => '1',
143 RESET => RESET,
144 RXSD => RRI_RXSD,
145 TXSD => RRI_TXSD,
146 CTS_N => '0',
147 RTS_N => RTS_N,
158 RB_LAM => RB_LAM,
160 );
161
162 UARTRX : serport_uart_rx
163 generic map (
164 CDWIDTH => CDWIDTH)
165 port map (
166 CLK => CLK,
167 RESET => RESET,
168 CLKDIV => CLKDIV,
169 RXSD => RRI_TXSD,
170 RXDATA => RXDATA,
171 RXVAL => RXVAL,
172 RXERR => open,
173 RXACT => RXACT
174 );
175
176 UARTTX : serport_uart_tx
177 generic map (
178 CDWIDTH => CDWIDTH)
179 port map (
180 CLK => CLK,
181 RESET => RESET,
182 CLKDIV => CLKDIV,
183 TXSD => RRI_RXSD,
184 TXDATA => TXDATA,
185 TXENA => TXENA,
186 TXBUSY => TXBUSY
187 );
188
189 TXRXACT <= RXACT or TXBUSY;
190
191 B2CD : byte2cdata -- byte stream -> 9bit comma,data
192 port map (
193 CLK => CLK,
194 RESET => RESET,
195 DI => RXDATA,
196 ENA => RXVAL,
197 ERR => '0',
198 BUSY => open,
199 DO => RL_DO,
200 VAL => RL_VAL,
201 HOLD => RL_HOLD
202 );
203
204 CD2B : cdata2byte -- 9bit comma,data -> byte stream
205 port map (
206 CLK => CLK,
207 RESET => RESET,
208 ESCXON => '0',
209 ESCFILL => '0',
210 DI => RL_DI,
211 ENA => RL_ENA,
212 BUSY => RL_BUSY,
213 DO => TXDATA,
214 VAL => TXENA,
215 HOLD => TXBUSY
216 );
217
218 CLKCNT : simclkcnt port map (CLK => CLK, CLK_CYCLE => CLK_CYCLE);
219
220 proc_moni: process
221 variable oline : line;
222 variable rts_last : slbit := '0';
223 variable ncycle : integer := 0;
224 begin
225 loop
226 wait until rising_edge(CLK); -- check at end of clock cycle
227 if RTS_N /= rts_last then
228 writetimestamp(oline, CLK_CYCLE, ": rts ");
229 write(oline, string'(" RTS_N "));
230 write(oline, rts_last, right, 1);
231 write(oline, string'(" -> "));
232 write(oline, RTS_N, right, 1);
233 write(oline, string'(" after "));
234 write(oline, ncycle, right, 5);
235 write(oline, string'(" cycles"));
236 writeline(output, oline);
237 rts_last := RTS_N;
238 ncycle := 0;
239 end if;
240 ncycle := ncycle + 1;
241 end loop;
242 end process proc_moni;
243
244end syn;
CDWIDTH positive := 13
in CLKDIV slv( CDWIDTH- 1 downto 0)
CDWIDTH positive := 13
in CLKDIV slv( CDWIDTH- 1 downto 0)
out CLK_CYCLE integer
Definition: simclkcnt.vhd:29
in CLK slbit
Definition: simclkcnt.vhd:27
std_logic_vector( 12 downto 0) slv13
Definition: slvtypes.vhd:45
std_logic_vector( 3 downto 0) slv4
Definition: slvtypes.vhd:36
std_logic_vector( 8 downto 0) slv9
Definition: slvtypes.vhd:41
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 slv
Definition: slvtypes.vhd:31