OpenCores
URL https://opencores.org/ocsvn/w11/w11/trunk

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [rtl/] [vlib/] [rlink/] [rlinklib.vhd] - Blame information for rev 12

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.