1 |
13 |
wfjm |
-- $Id: rlinklib.vhd 427 2011-11-19 21:04:11Z mueller $
|
2 |
2 |
wfjm |
--
|
3 |
13 |
wfjm |
-- Copyright 2007-2011 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 |
13 |
wfjm |
-- Tool versions: xst 8.2, 9.1, 9.2, 11.4, 12.1, 13.1; ghdl 0.18-0.29
|
20 |
9 |
wfjm |
--
|
21 |
2 |
wfjm |
-- Revision History:
|
22 |
|
|
-- Date Rev Version Comment
|
23 |
13 |
wfjm |
-- 2011-11-18 427 3.1.3 now numeric_std clean
|
24 |
9 |
wfjm |
-- 2010-12-25 348 3.1.2 drop RL_FLUSH support, add RL_MONI for rlink_core;
|
25 |
|
|
-- new rlink_serport interface;
|
26 |
|
|
-- rename rlink_core_serport->rlink_base_serport
|
27 |
|
|
-- 2010-12-24 347 3.1.1 rename: CP_*->RL->*
|
28 |
|
|
-- 2010-12-22 346 3.1 rename: [cd]crc->[cd]err, ioto->rbnak, ioerr->rberr
|
29 |
|
|
-- 2010-12-04 343 3.0 move rbus components to rbus/rblib; renames
|
30 |
|
|
-- rri_ -> rlink and c_rri -> c_rlink;
|
31 |
2 |
wfjm |
-- 2010-06-18 306 2.5.1 rename rbus data fields to _rbf_
|
32 |
|
|
-- 2010-06-06 302 2.5 use sop/eop framing instead of soc+chaining
|
33 |
|
|
-- 2010-06-03 300 2.1.5 use FAWIDTH=5 for rri_serport
|
34 |
|
|
-- 2010-05-02 287 2.1.4 ren CE_XSEC->CE_INT,RP_STAT->RB_STAT,AP_LAM->RB_LAM
|
35 |
|
|
-- drop RP_IINT from interfaces; drop RTSFLUSH generic
|
36 |
|
|
-- 2010-05-01 285 2.1.3 remove rri_rb_rpcompat, now obsolete
|
37 |
|
|
-- 2010-04-18 279 2.1.2 rri_core_serport: drop RTSFBUF generic
|
38 |
|
|
-- 2010-04-10 275 2.1.1 add rri_core_serport
|
39 |
|
|
-- 2010-04-03 274 2.1 add CP_FLUSH for rri_core, rri_serport;
|
40 |
|
|
-- CE_USEC, RTSFLUSH, CTS_N, RTS_N for rri_serport
|
41 |
|
|
-- 2008-08-24 162 2.0 all with new rb_mreq/rb_sres interface
|
42 |
|
|
-- 2008-08-22 161 1.3 renamed rri_rbres_ -> rb_sres_; drop rri_[24]rp
|
43 |
|
|
-- 2008-02-16 116 1.2.1 added rri_wreg(rw|w|r)_3
|
44 |
|
|
-- 2008-01-20 113 1.2 added rb_[mreq|sres]; _rbres_or_*; _rb_rpcompat
|
45 |
|
|
-- 2007-11-24 98 1.1 added RP_IINT for rri_core.
|
46 |
|
|
-- 2007-09-09 81 1.0 Initial version
|
47 |
|
|
------------------------------------------------------------------------------
|
48 |
|
|
|
49 |
|
|
library ieee;
|
50 |
|
|
use ieee.std_logic_1164.all;
|
51 |
13 |
wfjm |
use ieee.numeric_std.all;
|
52 |
2 |
wfjm |
|
53 |
|
|
use work.slvtypes.all;
|
54 |
9 |
wfjm |
use work.rblib.all;
|
55 |
2 |
wfjm |
|
56 |
9 |
wfjm |
package rlinklib is
|
57 |
2 |
wfjm |
|
58 |
9 |
wfjm |
constant c_rlink_cpref : slv4 := "1000"; -- default comma prefix
|
59 |
|
|
constant c_rlink_ncomm : positive := 4; -- number commas (sop,eop,nak,attn)
|
60 |
2 |
wfjm |
|
61 |
9 |
wfjm |
constant c_rlink_dat_idle : slv9 := "100000000";
|
62 |
|
|
constant c_rlink_dat_sop : slv9 := "100000001";
|
63 |
|
|
constant c_rlink_dat_eop : slv9 := "100000010";
|
64 |
|
|
constant c_rlink_dat_nak : slv9 := "100000011";
|
65 |
|
|
constant c_rlink_dat_attn : slv9 := "100000100";
|
66 |
2 |
wfjm |
|
67 |
9 |
wfjm |
constant c_rlink_cmd_rreg : slv3 := "000";
|
68 |
|
|
constant c_rlink_cmd_rblk : slv3 := "001";
|
69 |
|
|
constant c_rlink_cmd_wreg : slv3 := "010";
|
70 |
|
|
constant c_rlink_cmd_wblk : slv3 := "011";
|
71 |
|
|
constant c_rlink_cmd_stat : slv3 := "100";
|
72 |
|
|
constant c_rlink_cmd_attn : slv3 := "101";
|
73 |
|
|
constant c_rlink_cmd_init : slv3 := "110";
|
74 |
2 |
wfjm |
|
75 |
9 |
wfjm |
constant c_rlink_iint_rbf_anena: integer := 15; -- anena flag
|
76 |
|
|
constant c_rlink_iint_rbf_itoena: integer := 14; -- itoena flag
|
77 |
|
|
subtype c_rlink_iint_rbf_itoval is integer range 7 downto 0; -- command code
|
78 |
2 |
wfjm |
|
79 |
9 |
wfjm |
subtype c_rlink_cmd_rbf_seq is integer range 7 downto 3; -- sequence number
|
80 |
|
|
subtype c_rlink_cmd_rbf_code is integer range 2 downto 0; -- command code
|
81 |
2 |
wfjm |
|
82 |
9 |
wfjm |
subtype c_rlink_stat_rbf_stat is integer range 7 downto 5; -- ext status bits
|
83 |
|
|
constant c_rlink_stat_rbf_attn: integer := 4; -- attention flags set
|
84 |
|
|
constant c_rlink_stat_rbf_cerr: integer := 3; -- command error
|
85 |
|
|
constant c_rlink_stat_rbf_derr: integer := 2; -- data error
|
86 |
|
|
constant c_rlink_stat_rbf_rbnak: integer := 1; -- rbus no ack or timeout
|
87 |
|
|
constant c_rlink_stat_rbf_rberr: integer := 0; -- rbus err bit set
|
88 |
2 |
wfjm |
|
89 |
9 |
wfjm |
type rl_moni_type is record -- rlink_core monitor port
|
90 |
|
|
eop : slbit; -- eop send in last cycle
|
91 |
|
|
attn : slbit; -- attn send in last cycle
|
92 |
|
|
lamp : slbit; -- attn (lam) pending
|
93 |
|
|
end record rl_moni_type;
|
94 |
2 |
wfjm |
|
95 |
9 |
wfjm |
constant rl_moni_init : rl_moni_type :=
|
96 |
|
|
('0','0','0'); -- eop,attn,lamp
|
97 |
2 |
wfjm |
|
98 |
13 |
wfjm |
-- ise 13.1 xst can bug check if generic defaults in a package are defined via
|
99 |
|
|
-- 'slv(to_unsigned())'. The conv_ construct prior to numeric_std was ok.
|
100 |
|
|
-- As workaround the ibus default addresses are defined here as constant.
|
101 |
|
|
constant rbaddr_rlink_serport : slv8 := slv(to_unsigned(2#11111110#,8));
|
102 |
|
|
|
103 |
9 |
wfjm |
component rlink_core is -- rlink core with 9bit iface
|
104 |
2 |
wfjm |
generic (
|
105 |
|
|
ATOWIDTH : positive := 5; -- access timeout counter width
|
106 |
|
|
ITOWIDTH : positive := 6); -- idle timeout counter width
|
107 |
|
|
port (
|
108 |
|
|
CLK : in slbit; -- clock
|
109 |
9 |
wfjm |
CE_INT : in slbit := '0'; -- rlink ito time unit clock enable
|
110 |
2 |
wfjm |
RESET : in slbit; -- reset
|
111 |
9 |
wfjm |
RL_DI : in slv9; -- rlink 9b: data in
|
112 |
|
|
RL_ENA : in slbit; -- rlink 9b: data enable
|
113 |
|
|
RL_BUSY : out slbit; -- rlink 9b: data busy
|
114 |
|
|
RL_DO : out slv9; -- rlink 9b: data out
|
115 |
|
|
RL_VAL : out slbit; -- rlink 9b: data valid
|
116 |
|
|
RL_HOLD : in slbit; -- rlink 9b: data hold
|
117 |
|
|
RL_MONI : out rl_moni_type; -- rlink: monitor port
|
118 |
2 |
wfjm |
RB_MREQ : out rb_mreq_type; -- rbus: request
|
119 |
|
|
RB_SRES : in rb_sres_type; -- rbus: response
|
120 |
|
|
RB_LAM : in slv16; -- rbus: look at me
|
121 |
|
|
RB_STAT : in slv3 -- rbus: status flags
|
122 |
|
|
);
|
123 |
|
|
end component;
|
124 |
|
|
|
125 |
9 |
wfjm |
component rlink_aif is -- rlink, abstract interface
|
126 |
2 |
wfjm |
port (
|
127 |
|
|
CLK : in slbit; -- clock
|
128 |
9 |
wfjm |
CE_INT : in slbit := '0'; -- rlink ito time unit clock enable
|
129 |
2 |
wfjm |
RESET : in slbit :='0'; -- reset
|
130 |
9 |
wfjm |
RL_DI : in slv9; -- rlink 9b: data in
|
131 |
|
|
RL_ENA : in slbit; -- rlink 9b: data enable
|
132 |
|
|
RL_BUSY : out slbit; -- rlink 9b: data busy
|
133 |
|
|
RL_DO : out slv9; -- rlink 9b: data out
|
134 |
|
|
RL_VAL : out slbit; -- rlink 9b: data valid
|
135 |
|
|
RL_HOLD : in slbit := '0' -- rlink 9b: data hold
|
136 |
2 |
wfjm |
);
|
137 |
|
|
end component;
|
138 |
|
|
|
139 |
9 |
wfjm |
component rlink_rlb2rl is -- rlink 8 bit(rlb) to 9 bit(rl) adapter
|
140 |
|
|
generic (
|
141 |
|
|
CPREF : slv4 := c_rlink_cpref; -- comma prefix
|
142 |
|
|
IFAWIDTH : natural := 5; -- input fifo address width (0=none)
|
143 |
|
|
OFAWIDTH : natural := 5); -- output fifo address width (0=none)
|
144 |
2 |
wfjm |
port (
|
145 |
|
|
CLK : in slbit; -- clock
|
146 |
9 |
wfjm |
RESET : in slbit; -- reset
|
147 |
|
|
RLB_DI : in slv8; -- rlink 8b: data in
|
148 |
|
|
RLB_ENA : in slbit; -- rlink 8b: data enable
|
149 |
|
|
RLB_BUSY : out slbit; -- rlink 8b: data busy
|
150 |
|
|
RLB_DO : out slv8; -- rlink 8b: data out
|
151 |
|
|
RLB_VAL : out slbit; -- rlink 8b: data valid
|
152 |
|
|
RLB_HOLD : in slbit; -- rlink 8b: data hold
|
153 |
|
|
IFIFO_SIZE : out slv4; -- input fifo size (4 msb's)
|
154 |
|
|
OFIFO_SIZE : out slv4; -- output fifo fill (4 msb's)
|
155 |
|
|
RL_DI : out slv9; -- rlink 9b: data in
|
156 |
|
|
RL_ENA : out slbit; -- rlink 9b: data enable
|
157 |
|
|
RL_BUSY : in slbit; -- rlink 9b: data busy
|
158 |
|
|
RL_DO : in slv9; -- rlink 9b: data out
|
159 |
|
|
RL_VAL : in slbit; -- rlink 9b: data valid
|
160 |
|
|
RL_HOLD : out slbit -- rlink 9b: data hold
|
161 |
2 |
wfjm |
);
|
162 |
|
|
end component;
|
163 |
|
|
|
164 |
9 |
wfjm |
-- this definition logically belongs into the 'for test benches' section'
|
165 |
|
|
-- must be here because it is needed as generic default in rlink_base
|
166 |
|
|
-- simbus sb_cntl field usage for rlink
|
167 |
|
|
constant sbcntl_sbf_rlmon : integer := 15;
|
168 |
|
|
|
169 |
|
|
component rlink_base is -- rlink base: core+rl2rlb+rlmon+rbmon
|
170 |
|
|
-- with buffered 8bit interface
|
171 |
2 |
wfjm |
generic (
|
172 |
9 |
wfjm |
ATOWIDTH : positive := 5; -- access timeout counter width
|
173 |
|
|
ITOWIDTH : positive := 6; -- idle timeout counter width
|
174 |
|
|
CPREF : slv4 := c_rlink_cpref; -- comma prefix
|
175 |
|
|
IFAWIDTH : natural := 5; -- input fifo address width (0=none)
|
176 |
|
|
OFAWIDTH : natural := 5; -- output fifo address width (0=none)
|
177 |
|
|
ENAPIN_RLMON : integer := sbcntl_sbf_rlmon; -- SB_CNTL for rlmon (-1=none)
|
178 |
|
|
ENAPIN_RBMON : integer := sbcntl_sbf_rbmon); -- SB_CNTL for rbmon (-1=none)
|
179 |
|
|
port (
|
180 |
|
|
CLK : in slbit; -- clock
|
181 |
|
|
CE_INT : in slbit := '0'; -- rlink ito time unit clock enable
|
182 |
|
|
RESET : in slbit; -- reset
|
183 |
|
|
RLB_DI : in slv8; -- rlink 8b: data in
|
184 |
|
|
RLB_ENA : in slbit; -- rlink 8b: data enable
|
185 |
|
|
RLB_BUSY : out slbit; -- rlink 8b: data busy
|
186 |
|
|
RLB_DO : out slv8; -- rlink 8b: data out
|
187 |
|
|
RLB_VAL : out slbit; -- rlink 8b: data valid
|
188 |
|
|
RLB_HOLD : in slbit; -- rlink 8b: data hold
|
189 |
|
|
IFIFO_SIZE : out slv4; -- input fifo size (4 msb's)
|
190 |
|
|
OFIFO_SIZE : out slv4; -- output fifo fill (4 msb's)
|
191 |
|
|
RL_MONI : out rl_moni_type; -- rlink: monitor port
|
192 |
|
|
RB_MREQ : out rb_mreq_type; -- rbus: request
|
193 |
|
|
RB_SRES : in rb_sres_type; -- rbus: response
|
194 |
|
|
RB_LAM : in slv16; -- rbus: look at me
|
195 |
|
|
RB_STAT : in slv3 -- rbus: status flags
|
196 |
|
|
);
|
197 |
|
|
end component;
|
198 |
|
|
|
199 |
|
|
type rl_ser_moni_type is record -- rlink_serport monitor port
|
200 |
|
|
rxerr : slbit; -- rx err
|
201 |
|
|
rxdrop : slbit; -- rx drop
|
202 |
|
|
rxact : slbit; -- rx active
|
203 |
|
|
txact : slbit; -- tx active
|
204 |
|
|
abact : slbit; -- ab active
|
205 |
|
|
abdone : slbit; -- ab done
|
206 |
|
|
clkdiv : slv16; -- clock divider
|
207 |
|
|
end record rl_ser_moni_type;
|
208 |
|
|
|
209 |
|
|
constant rl_ser_moni_init : rl_ser_moni_type :=
|
210 |
|
|
('0','0', -- rxerr,rxdrop
|
211 |
|
|
'0','0', -- rxact,txact
|
212 |
|
|
'0','0', -- abact,abdone
|
213 |
|
|
(others=>'0')); -- clkdiv
|
214 |
|
|
|
215 |
|
|
constant c_rlink_serport_rbf_fena: integer := 12; --
|
216 |
|
|
subtype c_rlink_serport_rbf_fwidth is integer range 11 downto 9; --
|
217 |
|
|
subtype c_rlink_serport_rbf_fdelay is integer range 8 downto 6; --
|
218 |
|
|
subtype c_rlink_serport_rbf_rtsoff is integer range 5 downto 3; --
|
219 |
|
|
subtype c_rlink_serport_rbf_rtson is integer range 2 downto 0; --
|
220 |
|
|
|
221 |
|
|
component rlink_serport is -- rlink serport adapter
|
222 |
|
|
generic (
|
223 |
13 |
wfjm |
RB_ADDR : slv8 := rbaddr_rlink_serport;
|
224 |
2 |
wfjm |
CDWIDTH : positive := 13; -- clk divider width
|
225 |
|
|
CDINIT : natural := 15); -- clk divider initial/reset setting
|
226 |
|
|
port (
|
227 |
|
|
CLK : in slbit; -- clock
|
228 |
|
|
CE_USEC : in slbit; -- 1 usec clock enable
|
229 |
|
|
CE_MSEC : in slbit; -- 1 msec clock enable
|
230 |
|
|
RESET : in slbit; -- reset
|
231 |
|
|
RXSD : in slbit; -- receive serial data (board view)
|
232 |
|
|
TXSD : out slbit; -- transmit serial data (board view)
|
233 |
|
|
CTS_N : in slbit := '0'; -- clear to send (act.low, board view)
|
234 |
|
|
RTS_N : out slbit; -- request to send (act.low, board view)
|
235 |
9 |
wfjm |
RLB_DI : out slv8; -- rlink 8b: data in
|
236 |
|
|
RLB_ENA : out slbit; -- rlink 8b: data enable
|
237 |
|
|
RLB_BUSY : in slbit; -- rlink 8b: data busy
|
238 |
|
|
RLB_DO : in slv8; -- rlink 8b: data out
|
239 |
|
|
RLB_VAL : in slbit; -- rlink 8b: data valid
|
240 |
|
|
RLB_HOLD : out slbit; -- rlink 8b: data hold
|
241 |
|
|
RB_MREQ : in rb_mreq_type; -- rbus: request (for inits only)
|
242 |
|
|
IFIFO_SIZE : in slv4; -- rlink_rlb2rb: input fifo size
|
243 |
|
|
RL_MONI : in rl_moni_type; -- rlink_core: monitor port
|
244 |
|
|
RL_SER_MONI : out rl_ser_moni_type -- rlink_serport: monitor port
|
245 |
2 |
wfjm |
);
|
246 |
|
|
end component;
|
247 |
|
|
|
248 |
9 |
wfjm |
component rlink_base_serport is -- rlink base+serport combo
|
249 |
2 |
wfjm |
generic (
|
250 |
|
|
ATOWIDTH : positive := 5; -- access timeout counter width
|
251 |
|
|
ITOWIDTH : positive := 6; -- idle timeout counter width
|
252 |
9 |
wfjm |
CPREF : slv4 := c_rlink_cpref; -- comma prefix
|
253 |
|
|
IFAWIDTH : natural := 5; -- input fifo address width (0=none)
|
254 |
|
|
OFAWIDTH : natural := 5; -- output fifo address width (0=none)
|
255 |
|
|
ENAPIN_RLMON : integer := sbcntl_sbf_rlmon; -- SB_CNTL for rlmon (-1=none)
|
256 |
|
|
ENAPIN_RBMON : integer := sbcntl_sbf_rbmon; -- SB_CNTL for rbmon (-1=none)
|
257 |
13 |
wfjm |
RB_ADDR : slv8 := rbaddr_rlink_serport;
|
258 |
2 |
wfjm |
CDWIDTH : positive := 13; -- clk divider width
|
259 |
|
|
CDINIT : natural := 15); -- clk divider initial/reset setting
|
260 |
|
|
port (
|
261 |
|
|
CLK : in slbit; -- clock
|
262 |
|
|
CE_USEC : in slbit; -- 1 usec clock enable
|
263 |
|
|
CE_MSEC : in slbit; -- 1 msec clock enable
|
264 |
|
|
CE_INT : in slbit := '0'; -- rri ito time unit clock enable
|
265 |
|
|
RESET : in slbit; -- reset
|
266 |
|
|
RXSD : in slbit; -- receive serial data (board view)
|
267 |
|
|
TXSD : out slbit; -- transmit serial data (board view)
|
268 |
|
|
CTS_N : in slbit := '0'; -- clear to send (act.low, board view)
|
269 |
|
|
RTS_N : out slbit; -- request to send (act.low, board view)
|
270 |
|
|
RB_MREQ : out rb_mreq_type; -- rbus: request
|
271 |
|
|
RB_SRES : in rb_sres_type; -- rbus: response
|
272 |
|
|
RB_LAM : in slv16; -- rbus: look at me
|
273 |
9 |
wfjm |
RB_STAT : in slv3; -- rbus: status flags
|
274 |
|
|
RL_MONI : out rl_moni_type; -- rlink_core: monitor port
|
275 |
|
|
RL_SER_MONI : out rl_ser_moni_type -- rlink_serport: monitor port
|
276 |
2 |
wfjm |
);
|
277 |
|
|
end component;
|
278 |
|
|
|
279 |
9 |
wfjm |
--
|
280 |
|
|
-- components for use in test benches (not synthesizable)
|
281 |
|
|
--
|
282 |
2 |
wfjm |
|
283 |
9 |
wfjm |
component rlink_mon is -- rlink monitor
|
284 |
2 |
wfjm |
generic (
|
285 |
9 |
wfjm |
DWIDTH : positive := 9); -- data port width (8 or 9)
|
286 |
2 |
wfjm |
port (
|
287 |
|
|
CLK : in slbit; -- clock
|
288 |
9 |
wfjm |
CLK_CYCLE : in slv31 := (others=>'0'); -- clock cycle number
|
289 |
|
|
ENA : in slbit := '1'; -- enable monitor output
|
290 |
|
|
RL_DI : in slv(DWIDTH-1 downto 0); -- rlink: data in
|
291 |
|
|
RL_ENA : in slbit; -- rlink: data enable
|
292 |
|
|
RL_BUSY : in slbit; -- rlink: data busy
|
293 |
|
|
RL_DO : in slv(DWIDTH-1 downto 0); -- rlink: data out
|
294 |
|
|
RL_VAL : in slbit; -- rlink: data valid
|
295 |
|
|
RL_HOLD : in slbit -- rlink: data hold
|
296 |
2 |
wfjm |
);
|
297 |
|
|
end component;
|
298 |
|
|
|
299 |
9 |
wfjm |
component rlink_mon_sb is -- simbus wrap for rlink monitor
|
300 |
2 |
wfjm |
generic (
|
301 |
9 |
wfjm |
DWIDTH : positive := 9; -- data port width (8 or 9)
|
302 |
|
|
ENAPIN : integer := sbcntl_sbf_rlmon); -- SB_CNTL signal to use for enable
|
303 |
2 |
wfjm |
port (
|
304 |
|
|
CLK : in slbit; -- clock
|
305 |
9 |
wfjm |
RL_DI : in slv(DWIDTH-1 downto 0); -- rlink: data in
|
306 |
|
|
RL_ENA : in slbit; -- rlink: data enable
|
307 |
|
|
RL_BUSY : in slbit; -- rlink: data busy
|
308 |
|
|
RL_DO : in slv(DWIDTH-1 downto 0); -- rlink: data out
|
309 |
|
|
RL_VAL : in slbit; -- rlink: data valid
|
310 |
|
|
RL_HOLD : in slbit -- rlink: data hold
|
311 |
2 |
wfjm |
);
|
312 |
|
|
end component;
|
313 |
|
|
|
314 |
12 |
wfjm |
end package rlinklib;
|