w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
ibdr_dl11.vhd
Go to the documentation of this file.
1-- $Id: ibdr_dl11.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2008-2019 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: ibdr_dl11 - syn
7-- Description: ibus dev(rem): DL11-A/B
8--
9-- Dependencies: ib_rlim_slv
10-- Test bench: -
11-- Target Devices: generic
12-- Tool versions: ise 8.2-14.7; viv 2017.2; ghdl 0.18-0.35
13--
14-- Synthesized (xst):
15-- Date Rev ise Target flop lutl lutm slic t peri
16-- 2010-10-17 333 12.1 M53d xc3s1000-4 39 126 0 72 s 7.6
17-- 2009-07-12 233 10.1.03 K39 xc3s1000-4 38 119 0 69 s 6.3
18-- 2009-07-11 232 10.1.03 K39 xc3s1000-4 23 61 0 40 s 5.5
19--
20-- Revision History:
21-- Date Rev Version Comment
22-- 2019-04-27 1140 1.3.3 drop rbuf.rrdy, set rbuf.[rx]size0 instead
23-- 2019-04-24 1138 1.3.2 add rcsr.ir and xcsr.ir (intreq monitors)
24-- 2019-04-14 1131 1.3.1 RLIM_CEV now slv8
25-- 2019-04-07 1127 1.3 for dl11_buf compat: xbuf.val in bit 15 and 8;
26-- use rbuf instead xbuf for rdry reporting; remove
27-- maintenance mode; use ib_rlim_slv; drop CE_USEC
28-- 2011-11-18 427 1.2.2 now numeric_std clean
29-- 2010-10-23 335 1.2.1 rename RRI_LAM->RB_LAM;
30-- 2010-10-17 333 1.2 use ibus V2 interface
31-- 2010-06-11 303 1.1 use IB_MREQ.racc instead of RRI_REQ
32-- 2009-07-12 233 1.0.5 add RESET, CE_USEC port; implement input rate limit
33-- 2008-08-22 161 1.0.6 use iblib; add EI_ACK_* to proc_next sens. list
34-- 2008-05-09 144 1.0.5 use intreq flop, use EI_ACK
35-- 2008-03-22 128 1.0.4 rename xdone -> xval (no functional change)
36-- 2008-01-27 115 1.0.3 BUGFIX: set ilam when rbuf read by cpu;
37-- add xdone and rrdy bits to rri xbuf read
38-- 2008-01-20 113 1.0.2 fix maint mode logic (proper double buffer now)
39-- 2008-01-20 112 1.0.1 use BRESET
40-- 2008-01-05 108 1.0 Initial version
41------------------------------------------------------------------------------
42
43library ieee;
44use ieee.std_logic_1164.all;
45use ieee.numeric_std.all;
46
47use work.slvtypes.all;
48use work.iblib.all;
49
50-- ----------------------------------------------------------------------------
51entity ibdr_dl11 is -- ibus dev(rem): DL11-A/B
52 generic (
53 IB_ADDR : slv16 := slv(to_unsigned(8#177560#,16)));
54 port (
55 CLK : in slbit; -- clock
56 RESET : in slbit; -- system reset
57 BRESET : in slbit; -- ibus reset
58 RLIM_CEV : in slv8; -- clock enable vector
59 RB_LAM : out slbit; -- remote attention
60 IB_MREQ : in ib_mreq_type; -- ibus request
61 IB_SRES : out ib_sres_type; -- ibus response
62 EI_REQ_RX : out slbit; -- interrupt request, receiver
63 EI_REQ_TX : out slbit; -- interrupt request, transmitter
64 EI_ACK_RX : in slbit; -- interrupt acknowledge, receiver
65 EI_ACK_TX : in slbit -- interrupt acknowledge, transmitter
66 );
67end ibdr_dl11;
68
69architecture syn of ibdr_dl11 is
70
71 constant ibaddr_rcsr : slv2 := "00"; -- rcsr address offset
72 constant ibaddr_rbuf : slv2 := "01"; -- rbuf address offset
73 constant ibaddr_xcsr : slv2 := "10"; -- xcsr address offset
74 constant ibaddr_xbuf : slv2 := "11"; -- xbuf address offset
75
76 subtype rcsr_ibf_rrlim is integer range 14 downto 12;
77 constant rcsr_ibf_rdone : integer := 7;
78 constant rcsr_ibf_rie : integer := 6;
79 constant rcsr_ibf_rir : integer := 5;
80
81 constant rbuf_ibf_rsize0: integer := 8;
82 constant rbuf_ibf_xsize0: integer := 0;
83 subtype rbuf_ibf_data is integer range 7 downto 0;
84
85 constant xcsr_ibf_xrdy : integer := 7;
86 constant xcsr_ibf_xie : integer := 6;
87 constant xcsr_ibf_xir : integer := 5;
88
89 constant xbuf_ibf_xval : integer := 15;
90 constant xbuf_ibf_xval8 : integer := 8;
91
92 type regs_type is record -- state registers
93 ibsel : slbit; -- ibus select
94 rrlim : slv3; -- rcsr: receiver rate limit
95 rdone : slbit; -- rcsr: receiver done
96 rie : slbit; -- rcsr: receiver interrupt enable
97 rbuf : slv8; -- rbuf:
98 rval : slbit; -- rx rbuf valid
99 rintreq : slbit; -- rx interrupt request
100 xrdy : slbit; -- xcsr: transmitter ready
101 xie : slbit; -- xcsr: transmitter interrupt enable
102 xbuf : slv8; -- xbuf:
103 xintreq : slbit; -- tx interrupt request
104 end record regs_type;
105
106 constant regs_init : regs_type := (
107 '0', -- ibsel
108 (others=>'0'), -- rrlim
109 '0','0', -- rdone, rie
110 (others=>'0'), -- rbuf
111 '0','0', -- rval,rintreq
112 '1', -- xrdy !! is set !!
113 '0', -- xie
114 (others=>'0'), -- xbuf
115 '0' -- xintreq
116 );
117
120
121 signal RRLIM_START : slbit := '0';
122 signal RRLIM_BUSY : slbit := '0';
123
124begin
125
126 RRLIM : ib_rlim_slv
127 port map (
128 CLK => CLK,
129 RESET => RESET,
131 SEL => R_REGS.rrlim,
133 STOP => BRESET,
134 DONE => open,
136 );
137
138 proc_regs: process (CLK)
139 begin
140 if rising_edge(CLK) then
141 if BRESET = '1' then
142 R_REGS <= regs_init;
143 if RESET = '0' then -- if RESET=0 we do just an ibus reset
144 R_REGS.rrlim <= N_REGS.rrlim; -- keep RLIM flag
145 end if;
146 else
147 R_REGS <= N_REGS;
148 end if;
149 end if;
150 end process proc_regs;
151
152 proc_next : process (R_REGS, IB_MREQ, EI_ACK_RX, EI_ACK_TX, RRLIM_BUSY)
153 variable r : regs_type := regs_init;
154 variable n : regs_type := regs_init;
155 variable idout : slv16 := (others=>'0');
156 variable ibreq : slbit := '0';
157 variable ibrd : slbit := '0';
158 variable ibw0 : slbit := '0';
159 variable ibw1 : slbit := '0';
160 variable ilam : slbit := '0';
161 variable irrlimsta : slbit := '0';
162 begin
163
164 r := R_REGS;
165 n := R_REGS;
166
167 idout := (others=>'0');
168 ibreq := IB_MREQ.re or IB_MREQ.we;
169 ibrd := IB_MREQ.re;
170 ibw0 := IB_MREQ.we and IB_MREQ.be0;
171 ibw1 := IB_MREQ.we and IB_MREQ.be1;
172 ilam := '0';
173 irrlimsta := '0';
174
175 -- ibus address decoder
176 n.ibsel := '0';
177 if IB_MREQ.aval='1' and
178 IB_MREQ.addr(12 downto 3)=IB_ADDR(12 downto 3) then
179 n.ibsel := '1';
180 end if;
181
182 -- ibus transactions
183 if r.ibsel = '1' then
184 case IB_MREQ.addr(2 downto 1) is
185
186 when ibaddr_rcsr => -- RCSR -- receive control status ----
187 idout(rcsr_ibf_rdone) := r.rdone;
188 idout(rcsr_ibf_rie) := r.rie;
189
190 if IB_MREQ.racc = '0' then -- cpu ---------------------
191 if ibw0 = '1' then -- rcsr write
192 n.rie := IB_MREQ.din(rcsr_ibf_rie);
193 if IB_MREQ.din(rcsr_ibf_rie) = '1' then
194 if r.rdone='1' and r.rie='0' then -- ie set while done=1
195 n.rintreq := '1'; -- request interrupt
196 end if;
197 else
198 n.rintreq := '0';
199 end if;
200 end if;
201
202 else -- rri ---------------------
203 idout(rcsr_ibf_rrlim) := r.rrlim;
204 idout(rcsr_ibf_rir) := r.rintreq;
205 if ibw1 = '1' then
206 n.rrlim := IB_MREQ.din(rcsr_ibf_rrlim);
207 end if;
208 end if;
209
210 when ibaddr_rbuf => -- RBUF -- receive data buffer -------
211
212 if IB_MREQ.racc = '0' then -- cpu ---------------------
213 idout(rbuf_ibf_data) := r.rbuf;
214 if ibrd = '1' then -- rbuf read
215 n.rintreq := '0'; -- cancel interrupt
216 end if;
217 if ibrd='1' and r.rdone='1' then
218 n.rval := '0'; -- clear rbuf valid
219 irrlimsta := '1'; -- start rx timer
220 ilam := '1'; -- request rb attention
221 end if;
222
223 else -- rri ---------------------
224 idout(rbuf_ibf_rsize0) := r.rval; -- rbuf occupied when rval=1
225 idout(rbuf_ibf_xsize0) := not r.xrdy; -- xbuf empty when xrdy=1
226 if ibw0 = '1' then
227 n.rbuf := IB_MREQ.din(rbuf_ibf_data);
228 n.rval := '1'; -- set rbuf valid
229 end if;
230 end if;
231
232 when ibaddr_xcsr => -- XCSR -- transmit control status ---
233
234 idout(xcsr_ibf_xrdy) := r.xrdy;
235 idout(xcsr_ibf_xie) := r.xie;
236
237 if IB_MREQ.racc = '0' then -- cpu ---------------------
238 if ibw0 = '1' then
239 n.xie := IB_MREQ.din(xcsr_ibf_xie);
240 if IB_MREQ.din(xcsr_ibf_xie) = '1' then
241 if r.xrdy='1' and r.xie='0' then -- ie set while ready=1
242 n.xintreq := '1'; -- request interrupt
243 end if;
244 else
245 n.xintreq := '0';
246 end if;
247 end if;
248
249 else -- rri ---------------------
250 idout(xcsr_ibf_xir) := r.xintreq;
251 end if;
252
253 when ibaddr_xbuf => -- XBUF -- transmit data buffer ------
254
255 if IB_MREQ.racc = '0' then -- cpu ---------------------
256 if ibw0 = '1' then
257 n.xbuf := IB_MREQ.din(n.xbuf'range);
258 n.xrdy := '0';
259 n.xintreq := '0';
260 ilam := '1';
261 end if;
262
263 else -- rri ---------------------
264 idout(r.xbuf'range) := r.xbuf;
265 idout(xbuf_ibf_xval) := not r.xrdy;
266 idout(xbuf_ibf_xval8) := not r.xrdy;
267 if ibrd = '1' then
268 n.xrdy := '1';
269 if r.xie = '1' then
270 n.xintreq := '1';
271 end if;
272 end if;
273 end if;
274
275 when others => null;
276 end case;
277
278 end if;
279
280 -- other state changes
281
282 if EI_ACK_RX = '1' then
283 n.rintreq := '0';
284 end if;
285 if EI_ACK_TX = '1' then
286 n.xintreq := '0';
287 end if;
288
289 if (RRLIM_BUSY or (not r.rval)) = '1' then -- busy or no data
290 n.rdone := '0'; -- clear done
291 n.rintreq := '0'; -- clear pending interrupts
292 else -- not busy and data valid
293 n.rdone := '1'; -- set done
294 if r.rdone='0' and r.rie='1' then -- done going 0->1 and ie=1
295 n.rintreq := '1'; -- request rx interrupt
296 end if;
297 end if;
298
299 N_REGS <= n;
300
301 RRLIM_START <= irrlimsta;
302
303 IB_SRES.dout <= idout;
304 IB_SRES.ack <= r.ibsel and ibreq;
305 IB_SRES.busy <= '0';
306
307 RB_LAM <= ilam;
308 EI_REQ_RX <= r.rintreq;
309 EI_REQ_TX <= r.xintreq;
310
311 end process proc_next;
312
313
314end syn;
in STOP slbit
Definition: ib_rlim_slv.vhd:46
in RESET slbit
Definition: ib_rlim_slv.vhd:42
out BUSY slbit
Definition: ib_rlim_slv.vhd:49
out DONE slbit
Definition: ib_rlim_slv.vhd:47
in CLK slbit
Definition: ib_rlim_slv.vhd:41
in SEL slv3
Definition: ib_rlim_slv.vhd:44
in RLIM_CEV slv8
Definition: ib_rlim_slv.vhd:43
in START slbit
Definition: ib_rlim_slv.vhd:45
slv2 := "01" ibaddr_rbuf
Definition: ibdr_dl11.vhd:72
integer := 0 rbuf_ibf_xsize0
Definition: ibdr_dl11.vhd:82
integer := 8 xbuf_ibf_xval8
Definition: ibdr_dl11.vhd:90
integer := 7 xcsr_ibf_xrdy
Definition: ibdr_dl11.vhd:85
ib_rlim_slv rrlimrrlim
Definition: ibdr_dl11.vhd:136
slv2 := "00" ibaddr_rcsr
Definition: ibdr_dl11.vhd:71
regs_type := regs_init N_REGS
Definition: ibdr_dl11.vhd:119
integer := 5 rcsr_ibf_rir
Definition: ibdr_dl11.vhd:79
slv2 := "10" ibaddr_xcsr
Definition: ibdr_dl11.vhd:73
integer range 7 downto 0 rbuf_ibf_data
Definition: ibdr_dl11.vhd:83
integer := 6 xcsr_ibf_xie
Definition: ibdr_dl11.vhd:86
integer := 8 rbuf_ibf_rsize0
Definition: ibdr_dl11.vhd:81
regs_type :=( '0',( others => '0'), '0', '0',( others => '0'), '0', '0', '1', '0',( others => '0'), '0') regs_init
Definition: ibdr_dl11.vhd:106
slbit := '0' RRLIM_BUSY
Definition: ibdr_dl11.vhd:122
integer := 7 rcsr_ibf_rdone
Definition: ibdr_dl11.vhd:77
integer range 14 downto 12 rcsr_ibf_rrlim
Definition: ibdr_dl11.vhd:76
slbit := '0' RRLIM_START
Definition: ibdr_dl11.vhd:121
regs_type := regs_init R_REGS
Definition: ibdr_dl11.vhd:118
integer := 6 rcsr_ibf_rie
Definition: ibdr_dl11.vhd:78
slv2 := "11" ibaddr_xbuf
Definition: ibdr_dl11.vhd:74
integer := 15 xbuf_ibf_xval
Definition: ibdr_dl11.vhd:89
integer := 5 xcsr_ibf_xir
Definition: ibdr_dl11.vhd:87
IB_ADDR slv16 := slv( to_unsigned( 8#177560#, 16) )
Definition: ibdr_dl11.vhd:53
in RESET slbit
Definition: ibdr_dl11.vhd:56
in EI_ACK_TX slbit
Definition: ibdr_dl11.vhd:66
in EI_ACK_RX slbit
Definition: ibdr_dl11.vhd:64
in BRESET slbit
Definition: ibdr_dl11.vhd:57
out RB_LAM slbit
Definition: ibdr_dl11.vhd:59
in CLK slbit
Definition: ibdr_dl11.vhd:55
out EI_REQ_RX slbit
Definition: ibdr_dl11.vhd:62
in IB_MREQ ib_mreq_type
Definition: ibdr_dl11.vhd:60
out IB_SRES ib_sres_type
Definition: ibdr_dl11.vhd:61
in RLIM_CEV slv8
Definition: ibdr_dl11.vhd:58
out EI_REQ_TX slbit
Definition: ibdr_dl11.vhd:63
Definition: iblib.vhd:33
std_logic_vector( 2 downto 0) slv3
Definition: slvtypes.vhd:35
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( 1 downto 0) slv2
Definition: slvtypes.vhd:34
std_logic_vector slv
Definition: slvtypes.vhd:31