1 |
30 |
wfjm |
-- $Id: rlinklib.vhd 672 2015-05-02 21:58:28Z mueller $
|
2 |
2 |
wfjm |
--
|
3 |
29 |
wfjm |
-- Copyright 2007-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
4 |
2 |
wfjm |
--
|
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 |
-- Package Name: rlinklib
|
16 |
|
|
-- Description: Definitions for rlink interface and bus entities
|
17 |
2 |
wfjm |
--
|
18 |
|
|
-- Dependencies: -
|
19 |
29 |
wfjm |
-- Tool versions: ise 8.2-14.7; viv 2014.4; ghdl 0.18-0.31
|
20 |
9 |
wfjm |
--
|
21 |
2 |
wfjm |
-- Revision History:
|
22 |
|
|
-- Date Rev Version Comment
|
23 |
30 |
wfjm |
--
|
24 |
|
|
-- 2015-04-11 666 4.1.2 rlink_core8: add ESC(XON|FILL);
|
25 |
|
|
-- rlink_sp1c: rename ENAESC->ESCFILL
|
26 |
|
|
-- 2015-02-21 649 4.1.1 add ioleds_sp1c
|
27 |
28 |
wfjm |
-- 2014-12-21 617 4.1 use stat(2) to signal rbus timeout
|
28 |
27 |
wfjm |
-- 2014-10-12 596 4.0 now rlink v4.0 iface, 4 bit STAT
|
29 |
|
|
-- 2014-08-15 583 3.5 rb_mreq addr now 16 bit
|
30 |
20 |
wfjm |
-- 2013-04-21 509 3.3.2 add rlb_moni record definition
|
31 |
17 |
wfjm |
-- 2012-12-29 466 3.3.1 add rlink_rlbmux
|
32 |
|
|
-- 2011-12-23 444 3.3 CLK_CYCLE now integer
|
33 |
16 |
wfjm |
-- 2011-12-21 442 3.2.1 retire old, deprecated interfaces
|
34 |
|
|
-- 2011-12-09 437 3.2 add rlink_core8
|
35 |
13 |
wfjm |
-- 2011-11-18 427 3.1.3 now numeric_std clean
|
36 |
9 |
wfjm |
-- 2010-12-25 348 3.1.2 drop RL_FLUSH support, add RL_MONI for rlink_core;
|
37 |
|
|
-- new rlink_serport interface;
|
38 |
|
|
-- rename rlink_core_serport->rlink_base_serport
|
39 |
|
|
-- 2010-12-24 347 3.1.1 rename: CP_*->RL->*
|
40 |
|
|
-- 2010-12-22 346 3.1 rename: [cd]crc->[cd]err, ioto->rbnak, ioerr->rberr
|
41 |
|
|
-- 2010-12-04 343 3.0 move rbus components to rbus/rblib; renames
|
42 |
|
|
-- rri_ -> rlink and c_rri -> c_rlink;
|
43 |
2 |
wfjm |
-- 2010-06-18 306 2.5.1 rename rbus data fields to _rbf_
|
44 |
|
|
-- 2010-06-06 302 2.5 use sop/eop framing instead of soc+chaining
|
45 |
|
|
-- 2010-06-03 300 2.1.5 use FAWIDTH=5 for rri_serport
|
46 |
|
|
-- 2010-05-02 287 2.1.4 ren CE_XSEC->CE_INT,RP_STAT->RB_STAT,AP_LAM->RB_LAM
|
47 |
|
|
-- drop RP_IINT from interfaces; drop RTSFLUSH generic
|
48 |
|
|
-- 2010-05-01 285 2.1.3 remove rri_rb_rpcompat, now obsolete
|
49 |
|
|
-- 2010-04-18 279 2.1.2 rri_core_serport: drop RTSFBUF generic
|
50 |
|
|
-- 2010-04-10 275 2.1.1 add rri_core_serport
|
51 |
|
|
-- 2010-04-03 274 2.1 add CP_FLUSH for rri_core, rri_serport;
|
52 |
|
|
-- CE_USEC, RTSFLUSH, CTS_N, RTS_N for rri_serport
|
53 |
|
|
-- 2008-08-24 162 2.0 all with new rb_mreq/rb_sres interface
|
54 |
|
|
-- 2008-08-22 161 1.3 renamed rri_rbres_ -> rb_sres_; drop rri_[24]rp
|
55 |
|
|
-- 2008-02-16 116 1.2.1 added rri_wreg(rw|w|r)_3
|
56 |
|
|
-- 2008-01-20 113 1.2 added rb_[mreq|sres]; _rbres_or_*; _rb_rpcompat
|
57 |
|
|
-- 2007-11-24 98 1.1 added RP_IINT for rri_core.
|
58 |
|
|
-- 2007-09-09 81 1.0 Initial version
|
59 |
|
|
------------------------------------------------------------------------------
|
60 |
|
|
|
61 |
|
|
library ieee;
|
62 |
|
|
use ieee.std_logic_1164.all;
|
63 |
13 |
wfjm |
use ieee.numeric_std.all;
|
64 |
2 |
wfjm |
|
65 |
|
|
use work.slvtypes.all;
|
66 |
9 |
wfjm |
use work.rblib.all;
|
67 |
19 |
wfjm |
use work.serportlib.all;
|
68 |
2 |
wfjm |
|
69 |
9 |
wfjm |
package rlinklib is
|
70 |
2 |
wfjm |
|
71 |
27 |
wfjm |
constant c_rlink_dat_sop : slv9 := "100000000";
|
72 |
|
|
constant c_rlink_dat_eop : slv9 := "100000001";
|
73 |
|
|
constant c_rlink_dat_nak : slv9 := "100000010";
|
74 |
|
|
constant c_rlink_dat_attn : slv9 := "100000011";
|
75 |
2 |
wfjm |
|
76 |
9 |
wfjm |
constant c_rlink_cmd_rreg : slv3 := "000";
|
77 |
|
|
constant c_rlink_cmd_rblk : slv3 := "001";
|
78 |
|
|
constant c_rlink_cmd_wreg : slv3 := "010";
|
79 |
|
|
constant c_rlink_cmd_wblk : slv3 := "011";
|
80 |
27 |
wfjm |
constant c_rlink_cmd_labo : slv3 := "100";
|
81 |
9 |
wfjm |
constant c_rlink_cmd_attn : slv3 := "101";
|
82 |
|
|
constant c_rlink_cmd_init : slv3 := "110";
|
83 |
2 |
wfjm |
|
84 |
9 |
wfjm |
subtype c_rlink_cmd_rbf_seq is integer range 7 downto 3; -- sequence number
|
85 |
|
|
subtype c_rlink_cmd_rbf_code is integer range 2 downto 0; -- command code
|
86 |
2 |
wfjm |
|
87 |
27 |
wfjm |
subtype c_rlink_stat_rbf_stat is integer range 7 downto 4; -- ext status bits
|
88 |
|
|
constant c_rlink_stat_rbf_attn: integer := 3; -- attention flags set
|
89 |
28 |
wfjm |
constant c_rlink_stat_rbf_rbtout: integer := 2; -- rbus timeout
|
90 |
|
|
constant c_rlink_stat_rbf_rbnak: integer := 1; -- rbus no ack
|
91 |
9 |
wfjm |
constant c_rlink_stat_rbf_rberr: integer := 0; -- rbus err bit set
|
92 |
2 |
wfjm |
|
93 |
27 |
wfjm |
constant c_rlink_nakcode_ccrc : slv3 := "000"; -- cmd crc error
|
94 |
|
|
constant c_rlink_nakcode_dcrc : slv3 := "001"; -- data crc error
|
95 |
|
|
constant c_rlink_nakcode_frame : slv3 := "010"; -- framing error
|
96 |
|
|
constant c_rlink_nakcode_unused : slv3 := "011"; -- <unused code>
|
97 |
|
|
constant c_rlink_nakcode_cmd : slv3 := "100"; -- bad cmd
|
98 |
|
|
constant c_rlink_nakcode_cnt : slv3 := "101"; -- bad cnt
|
99 |
|
|
constant c_rlink_nakcode_rtovfl : slv3 := "110"; -- rtbuf ovfl
|
100 |
|
|
constant c_rlink_nakcode_rtwblk : slv3 := "111"; -- rtbuf ovfl in wblk
|
101 |
|
|
|
102 |
9 |
wfjm |
type rl_moni_type is record -- rlink_core monitor port
|
103 |
|
|
eop : slbit; -- eop send in last cycle
|
104 |
|
|
attn : slbit; -- attn send in last cycle
|
105 |
|
|
lamp : slbit; -- attn (lam) pending
|
106 |
|
|
end record rl_moni_type;
|
107 |
2 |
wfjm |
|
108 |
9 |
wfjm |
constant rl_moni_init : rl_moni_type :=
|
109 |
|
|
('0','0','0'); -- eop,attn,lamp
|
110 |
2 |
wfjm |
|
111 |
20 |
wfjm |
type rlb_moni_type is record -- rlink 8b monitor port
|
112 |
|
|
rxval : slbit; -- data in valid
|
113 |
|
|
rxhold : slbit; -- data in hold
|
114 |
|
|
txena : slbit; -- data out enable
|
115 |
|
|
txbusy : slbit; -- data out busy
|
116 |
|
|
end record rlb_moni_type;
|
117 |
|
|
|
118 |
|
|
constant rlb_moni_init : rlb_moni_type :=
|
119 |
|
|
('0','0','0','0'); -- rxval,rxhold,txena,txbusy
|
120 |
|
|
|
121 |
27 |
wfjm |
-- these definitions logically belongs into the 'for test benches' section'
|
122 |
|
|
-- it is here for convenience to simplify instantiations.
|
123 |
|
|
constant sbcntl_sbf_rlmon : integer := 15;
|
124 |
|
|
constant sbcntl_sbf_rlbmon : integer := 14;
|
125 |
13 |
wfjm |
|
126 |
9 |
wfjm |
component rlink_core is -- rlink core with 9bit iface
|
127 |
2 |
wfjm |
generic (
|
128 |
27 |
wfjm |
BTOWIDTH : positive := 5; -- rbus timeout counter width
|
129 |
|
|
RTAWIDTH : positive := 12; -- retransmit buffer address width
|
130 |
|
|
SYSID : slv32 := (others=>'0'); -- rlink system id
|
131 |
|
|
ENAPIN_RLMON : integer := -1; -- SB_CNTL for rlmon (-1=none)
|
132 |
|
|
ENAPIN_RBMON : integer := -1); -- SB_CNTL for rbmon (-1=none)
|
133 |
2 |
wfjm |
port (
|
134 |
|
|
CLK : in slbit; -- clock
|
135 |
27 |
wfjm |
CE_INT : in slbit := '0'; -- rlink ato time unit clock enable
|
136 |
2 |
wfjm |
RESET : in slbit; -- reset
|
137 |
9 |
wfjm |
RL_DI : in slv9; -- rlink 9b: data in
|
138 |
|
|
RL_ENA : in slbit; -- rlink 9b: data enable
|
139 |
|
|
RL_BUSY : out slbit; -- rlink 9b: data busy
|
140 |
|
|
RL_DO : out slv9; -- rlink 9b: data out
|
141 |
|
|
RL_VAL : out slbit; -- rlink 9b: data valid
|
142 |
|
|
RL_HOLD : in slbit; -- rlink 9b: data hold
|
143 |
|
|
RL_MONI : out rl_moni_type; -- rlink: monitor port
|
144 |
2 |
wfjm |
RB_MREQ : out rb_mreq_type; -- rbus: request
|
145 |
|
|
RB_SRES : in rb_sres_type; -- rbus: response
|
146 |
|
|
RB_LAM : in slv16; -- rbus: look at me
|
147 |
27 |
wfjm |
RB_STAT : in slv4 -- rbus: status flags
|
148 |
2 |
wfjm |
);
|
149 |
|
|
end component;
|
150 |
|
|
|
151 |
9 |
wfjm |
component rlink_aif is -- rlink, abstract interface
|
152 |
2 |
wfjm |
port (
|
153 |
|
|
CLK : in slbit; -- clock
|
154 |
27 |
wfjm |
CE_INT : in slbit := '0'; -- rlink ato time unit clock enable
|
155 |
2 |
wfjm |
RESET : in slbit :='0'; -- reset
|
156 |
9 |
wfjm |
RL_DI : in slv9; -- rlink 9b: data in
|
157 |
|
|
RL_ENA : in slbit; -- rlink 9b: data enable
|
158 |
|
|
RL_BUSY : out slbit; -- rlink 9b: data busy
|
159 |
|
|
RL_DO : out slv9; -- rlink 9b: data out
|
160 |
|
|
RL_VAL : out slbit; -- rlink 9b: data valid
|
161 |
|
|
RL_HOLD : in slbit := '0' -- rlink 9b: data hold
|
162 |
2 |
wfjm |
);
|
163 |
|
|
end component;
|
164 |
|
|
|
165 |
16 |
wfjm |
component rlink_core8 is -- rlink core with 8bit iface
|
166 |
9 |
wfjm |
generic (
|
167 |
27 |
wfjm |
BTOWIDTH : positive := 5; -- rbus timeout counter width
|
168 |
|
|
RTAWIDTH : positive := 12; -- retransmit buffer address width
|
169 |
|
|
SYSID : slv32 := (others=>'0'); -- rlink system id
|
170 |
|
|
ENAPIN_RLMON : integer := -1; -- SB_CNTL for rlmon (-1=none)
|
171 |
|
|
ENAPIN_RLBMON: integer := -1; -- SB_CNTL for rlbmon (-1=none)
|
172 |
|
|
ENAPIN_RBMON : integer := -1); -- SB_CNTL for rbmon (-1=none)
|
173 |
9 |
wfjm |
port (
|
174 |
|
|
CLK : in slbit; -- clock
|
175 |
27 |
wfjm |
CE_INT : in slbit := '0'; -- rlink ato time unit clock enable
|
176 |
9 |
wfjm |
RESET : in slbit; -- reset
|
177 |
30 |
wfjm |
ESCXON : in slbit := '0'; -- enable xon/xoff escaping
|
178 |
|
|
ESCFILL : in slbit := '0'; -- enable fill escaping
|
179 |
9 |
wfjm |
RLB_DI : in slv8; -- rlink 8b: data in
|
180 |
|
|
RLB_ENA : in slbit; -- rlink 8b: data enable
|
181 |
|
|
RLB_BUSY : out slbit; -- rlink 8b: data busy
|
182 |
|
|
RLB_DO : out slv8; -- rlink 8b: data out
|
183 |
|
|
RLB_VAL : out slbit; -- rlink 8b: data valid
|
184 |
|
|
RLB_HOLD : in slbit; -- rlink 8b: data hold
|
185 |
|
|
RL_MONI : out rl_moni_type; -- rlink: monitor port
|
186 |
|
|
RB_MREQ : out rb_mreq_type; -- rbus: request
|
187 |
|
|
RB_SRES : in rb_sres_type; -- rbus: response
|
188 |
|
|
RB_LAM : in slv16; -- rbus: look at me
|
189 |
27 |
wfjm |
RB_STAT : in slv4 -- rbus: status flags
|
190 |
9 |
wfjm |
);
|
191 |
|
|
end component;
|
192 |
|
|
|
193 |
17 |
wfjm |
component rlink_rlbmux is -- rlink rlb multiplexer
|
194 |
|
|
port (
|
195 |
|
|
SEL : in slbit; -- port select (0:RLB<->P0; 1:RLB<->P1)
|
196 |
|
|
RLB_DI : out slv8; -- rlb: data in
|
197 |
|
|
RLB_ENA : out slbit; -- rlb: data enable
|
198 |
|
|
RLB_BUSY : in slbit; -- rlb: data busy
|
199 |
|
|
RLB_DO : in slv8; -- rlb: data out
|
200 |
|
|
RLB_VAL : in slbit; -- rlb: data valid
|
201 |
|
|
RLB_HOLD : out slbit; -- rlb: data hold
|
202 |
|
|
P0_RXDATA : in slv8; -- p0: rx data
|
203 |
|
|
P0_RXVAL : in slbit; -- p0: rx valid
|
204 |
|
|
P0_RXHOLD : out slbit; -- p0: rx hold
|
205 |
|
|
P0_TXDATA : out slv8; -- p0: tx data
|
206 |
|
|
P0_TXENA : out slbit; -- p0: tx enable
|
207 |
|
|
P0_TXBUSY : in slbit; -- p0: tx busy
|
208 |
|
|
P1_RXDATA : in slv8; -- p1: rx data
|
209 |
|
|
P1_RXVAL : in slbit; -- p1: rx valid
|
210 |
|
|
P1_RXHOLD : out slbit; -- p1: rx hold
|
211 |
|
|
P1_TXDATA : out slv8; -- p1: tx data
|
212 |
|
|
P1_TXENA : out slbit; -- p1: tx enable
|
213 |
|
|
P1_TXBUSY : in slbit -- p1: tx busy
|
214 |
|
|
);
|
215 |
|
|
end component;
|
216 |
|
|
|
217 |
16 |
wfjm |
--
|
218 |
|
|
-- core + concrete_interface combo's
|
219 |
|
|
--
|
220 |
9 |
wfjm |
|
221 |
16 |
wfjm |
component rlink_sp1c is -- rlink_core8+serport_1clock combo
|
222 |
9 |
wfjm |
generic (
|
223 |
27 |
wfjm |
BTOWIDTH : positive := 5; -- rbus timeout counter width
|
224 |
|
|
RTAWIDTH : positive := 12; -- retransmit buffer address width
|
225 |
|
|
SYSID : slv32 := (others=>'0'); -- rlink system id
|
226 |
9 |
wfjm |
IFAWIDTH : natural := 5; -- input fifo address width (0=none)
|
227 |
|
|
OFAWIDTH : natural := 5; -- output fifo address width (0=none)
|
228 |
27 |
wfjm |
ENAPIN_RLMON : integer := -1; -- SB_CNTL for rlmon (-1=none)
|
229 |
|
|
ENAPIN_RLBMON: integer := -1; -- SB_CNTL for rlbmon (-1=none)
|
230 |
|
|
ENAPIN_RBMON : integer := -1; -- SB_CNTL for rbmon (-1=none)
|
231 |
2 |
wfjm |
CDWIDTH : positive := 13; -- clk divider width
|
232 |
30 |
wfjm |
CDINIT : natural := 15; -- clk divider initial/reset setting
|
233 |
|
|
RBMON_AWIDTH : natural := 0; -- rbmon: buffer size, (0=none)
|
234 |
|
|
RBMON_RBADDR : slv16 := slv(to_unsigned(16#ffe8#,16))); -- rbmon: base addr
|
235 |
2 |
wfjm |
port (
|
236 |
|
|
CLK : in slbit; -- clock
|
237 |
|
|
CE_USEC : in slbit; -- 1 usec clock enable
|
238 |
|
|
CE_MSEC : in slbit; -- 1 msec clock enable
|
239 |
27 |
wfjm |
CE_INT : in slbit := '0'; -- rri ato time unit clock enable
|
240 |
2 |
wfjm |
RESET : in slbit; -- reset
|
241 |
30 |
wfjm |
ENAXON : in slbit := '0'; -- enable xon/xoff handling
|
242 |
|
|
ESCFILL : in slbit := '0'; -- enable fill escaping
|
243 |
2 |
wfjm |
RXSD : in slbit; -- receive serial data (board view)
|
244 |
|
|
TXSD : out slbit; -- transmit serial data (board view)
|
245 |
|
|
CTS_N : in slbit := '0'; -- clear to send (act.low, board view)
|
246 |
|
|
RTS_N : out slbit; -- request to send (act.low, board view)
|
247 |
|
|
RB_MREQ : out rb_mreq_type; -- rbus: request
|
248 |
|
|
RB_SRES : in rb_sres_type; -- rbus: response
|
249 |
|
|
RB_LAM : in slv16; -- rbus: look at me
|
250 |
27 |
wfjm |
RB_STAT : in slv4; -- rbus: status flags
|
251 |
9 |
wfjm |
RL_MONI : out rl_moni_type; -- rlink_core: monitor port
|
252 |
16 |
wfjm |
SER_MONI : out serport_moni_type -- serport: monitor port
|
253 |
2 |
wfjm |
);
|
254 |
|
|
end component;
|
255 |
|
|
|
256 |
9 |
wfjm |
--
|
257 |
29 |
wfjm |
-- io activity leds
|
258 |
|
|
--
|
259 |
|
|
component ioleds_sp1c -- io activity leds for rlink_sp1c
|
260 |
|
|
port (
|
261 |
|
|
SER_MONI : in serport_moni_type; -- ser: monitor port
|
262 |
|
|
IOLEDS : out slv4 -- 4 bit IO monitor (e.g. for DSP_DP)
|
263 |
|
|
);
|
264 |
|
|
end component;
|
265 |
|
|
|
266 |
|
|
--
|
267 |
9 |
wfjm |
-- components for use in test benches (not synthesizable)
|
268 |
|
|
--
|
269 |
2 |
wfjm |
|
270 |
9 |
wfjm |
component rlink_mon is -- rlink monitor
|
271 |
2 |
wfjm |
generic (
|
272 |
9 |
wfjm |
DWIDTH : positive := 9); -- data port width (8 or 9)
|
273 |
2 |
wfjm |
port (
|
274 |
|
|
CLK : in slbit; -- clock
|
275 |
17 |
wfjm |
CLK_CYCLE : in integer := 0; -- clock cycle number
|
276 |
9 |
wfjm |
ENA : in slbit := '1'; -- enable monitor output
|
277 |
|
|
RL_DI : in slv(DWIDTH-1 downto 0); -- rlink: data in
|
278 |
|
|
RL_ENA : in slbit; -- rlink: data enable
|
279 |
|
|
RL_BUSY : in slbit; -- rlink: data busy
|
280 |
|
|
RL_DO : in slv(DWIDTH-1 downto 0); -- rlink: data out
|
281 |
|
|
RL_VAL : in slbit; -- rlink: data valid
|
282 |
|
|
RL_HOLD : in slbit -- rlink: data hold
|
283 |
2 |
wfjm |
);
|
284 |
|
|
end component;
|
285 |
|
|
|
286 |
9 |
wfjm |
component rlink_mon_sb is -- simbus wrap for rlink monitor
|
287 |
2 |
wfjm |
generic (
|
288 |
9 |
wfjm |
DWIDTH : positive := 9; -- data port width (8 or 9)
|
289 |
|
|
ENAPIN : integer := sbcntl_sbf_rlmon); -- SB_CNTL signal to use for enable
|
290 |
2 |
wfjm |
port (
|
291 |
|
|
CLK : in slbit; -- clock
|
292 |
9 |
wfjm |
RL_DI : in slv(DWIDTH-1 downto 0); -- rlink: data in
|
293 |
|
|
RL_ENA : in slbit; -- rlink: data enable
|
294 |
|
|
RL_BUSY : in slbit; -- rlink: data busy
|
295 |
|
|
RL_DO : in slv(DWIDTH-1 downto 0); -- rlink: data out
|
296 |
|
|
RL_VAL : in slbit; -- rlink: data valid
|
297 |
|
|
RL_HOLD : in slbit -- rlink: data hold
|
298 |
2 |
wfjm |
);
|
299 |
|
|
end component;
|
300 |
|
|
|
301 |
12 |
wfjm |
end package rlinklib;
|