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