w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
ibdr_deuna.vhd
Go to the documentation of this file.
1-- $Id: ibdr_deuna.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2014-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: ibdr_deuna - syn
7-- Description: ibus dev(rem): DEUNA
8--
9-- Dependencies: -
10-- Test bench: -
11-- Target Devices: generic
12-- Tool versions: ise 14.7; viv 2016.4-2017.1; ghdl 0.33-0.34
13--
14-- Synthesized (xst):
15-- Date Rev ise Target flop lutl lutm slic t peri
16-- 2017-05-06 894 14.7 131013 xc6slx16-2 53 92 0 42 s 4.4
17-- 2017-04-14 874 14.7 131013 xc6slx16-2 50 79 0 40 s 4.1
18-- 2017-01-29 847 14.7 131013 xc6slx16-2 42 70 0 36 s 4.1
19--
20-- Revision History:
21-- Date Rev Version Comment
22-- 2017-05-06 894 1.0 Initial version (full functionality)
23-- 2017-04-14 875 0.5 Initial version (partial functionality)
24-- 2014-06-09 561 0.1 First draft
25------------------------------------------------------------------------------
26
27library ieee;
28use ieee.std_logic_1164.all;
29use ieee.numeric_std.all;
30
31use work.slvtypes.all;
32use work.iblib.all;
33
34-- ----------------------------------------------------------------------------
35entity ibdr_deuna is -- ibus dev(rem): DEUNA
36 -- fixed address: 174510
37 port (
38 CLK : in slbit; -- clock
39 BRESET : in slbit; -- ibus reset
40 RB_LAM : out slbit; -- remote attention
41 IB_MREQ : in ib_mreq_type; -- ibus request
42 IB_SRES : out ib_sres_type; -- ibus response
43 EI_REQ : out slbit; -- interrupt request
44 EI_ACK : in slbit -- interrupt acknowledge
45 );
46end ibdr_deuna;
47
48architecture syn of ibdr_deuna is
49
50 constant ibaddr_deuna : slv16 := slv(to_unsigned(8#174510#,16));
51
52 constant ibaddr_pr0 : slv2 := "00"; -- pcsr0 address offset
53 constant ibaddr_pr1 : slv2 := "01"; -- pcsr1 address offset
54 constant ibaddr_pr2 : slv2 := "10"; -- pcsr2 address offset
55 constant ibaddr_pr3 : slv2 := "11"; -- pcsr3 address offset
56
57 constant pr0_ibf_seri : integer := 15;
58 constant pr0_ibf_pcei : integer := 14;
59 constant pr0_ibf_rxi : integer := 13;
60 constant pr0_ibf_txi : integer := 12;
61 constant pr0_ibf_dni : integer := 11;
62 constant pr0_ibf_rcbi : integer := 10;
63 constant pr0_ibf_usci : integer := 8;
64 constant pr0_ibf_intr : integer := 7;
65 constant pr0_ibf_inte : integer := 6;
66 constant pr0_ibf_rset : integer := 5;
67 subtype pr0_ibf_pcmd is integer range 3 downto 0;
68 -- additional rem view assignments
69 subtype pr0_ibf_pcmdbp is integer range 15 downto 12;
70 constant pr0_ibf_pdmdwb: integer := 10;
71 constant pr0_ibf_busy : integer := 9;
72 constant pr0_ibf_pcwwb : integer := 8;
73 constant pr0_ibf_brst : integer := 4;
74
75 constant pcmd_noop : slv4 := "0000"; -- pcmd: noop (DNI not set !)
76 constant pcmd_pdmd : slv4 := "1000"; -- pcmd: pdmd
77
78 constant pr1_ibf_xpwr : integer := 15;
79 constant pr1_ibf_icab : integer := 14;
80 subtype pr1_ibf_ecod is integer range 13 downto 8;
81 constant pr1_ibf_pcto : integer := 7;
82 constant pr1_ibf_deuna : integer := 4; -- id bit 0 (0=DEUNA;1=DELUA)
83 subtype pr1_ibf_state is integer range 3 downto 0;
84
85 constant state_reset : slv4 := "0000"; -- state: reset
86 constant state_ready : slv4 := "0010"; -- state: ready
87
88 type regs_type is record -- state registers
89 ibsel : slbit; -- ibus select
90 pr0seri : slbit; -- pr0: status error intr
91 pr0pcei : slbit; -- pr0: port command error intr
92 pr0rxi : slbit; -- pr0: receive ring intr
93 pr0txi : slbit; -- pr0: transmit ring intr
94 pr0dni : slbit; -- pr0: done interrupt
95 pr0rcbi : slbit; -- pr0: receive buffer unavail intr
96 pr0usci : slbit; -- pr0: unsolicited state change intr
97 pr0intr : slbit; -- pr0: intr summary
98 pr0inte : slbit; -- pr0: intr enable
99 pr0rset : slbit; -- pr0: software reset
100 pr0brst : slbit; -- pr0: BRESET reset
101 pr0pcmd : slv4; -- pr0: port command
102 pr1xpwr : slbit; -- pr1: transmitter power fail
103 pr1icab : slbit; -- pr1: port/link cabling fail
104 pr1pcto : slbit; -- pr1: port command time out
105 pr1deuna : slbit; -- pr1: bit 0 of ID (0=DEUNA;1=DELUA)
106 pr1state : slv4; -- pr1: port status
107 pcbb : slv18_1; -- pr2+3: port conrol block base
108 pdmdwb : slbit; -- restart for pdmd while busy
109 busy : slbit; -- busy
110 pcmdwwb : slbit; -- pcmd written while busy
111 pcmdbp : slv4; -- pcmd busy protected
112 resreq : slbit; -- reset requested
113 ireq : slbit; -- interrupt request flag
114 end record regs_type;
115
116 constant regs_init : regs_type := (
117 '0', -- ibsel
118 '0','0','0','0', -- pr0seri,pr0pcei,pr0rxi,pr0txi
119 '0','0','0', -- pr0dni,pr0rcbi,pr0usci
120 '0','0', -- pr0intr,pr0inte
121 '0','0', -- pr0rset,pr0brst
122 (others=>'0'), -- pr0pcmd
123 '1','1', -- pr1xpwr,pr1icab
124 '0','0', -- pr1pcto,pr1deuna
125 state_reset, -- pr1state
126 (others=>'0'), -- pcbb
127 '0','0','0', -- pdmdwb,busy,pcmdwwb
128 (others=>'0'), -- pcmdbp
129 '0', -- resreq
130 '0' -- ireq
131 );
132
135
136begin
137
138 proc_regs: process (CLK)
139 begin
140 if rising_edge(CLK) then
141 R_REGS <= N_REGS;
142 end if;
143 end process proc_regs;
144
145 proc_next : process (R_REGS, IB_MREQ, BRESET)
146 variable r : regs_type := regs_init;
147 variable n : regs_type := regs_init;
148 variable ibhold : slbit := '0';
149 variable idout : slv16 := (others=>'0');
150 variable ibrem : slbit := '0';
151 variable ibreq : slbit := '0';
152 variable ibrd : slbit := '0';
153 variable ibw0 : slbit := '0';
154 variable ibw1 : slbit := '0';
155 variable ibwrem : slbit := '0';
156 variable ilam : slbit := '0';
157
158 begin
159
160 r := R_REGS;
161 n := R_REGS;
162
163 ibhold := '0';
164 idout := (others=>'0');
165 ibrem := IB_MREQ.racc;
166 ibreq := IB_MREQ.re or IB_MREQ.we;
167 ibrd := IB_MREQ.re;
168 ibw0 := IB_MREQ.we and IB_MREQ.be0;
169 ibw1 := IB_MREQ.we and IB_MREQ.be1;
170 ibwrem := IB_MREQ.we and ibrem;
171 ilam := '0';
172
173 -- ibus address decoder
174 n.ibsel := '0';
175 if IB_MREQ.aval = '1' and
176 IB_MREQ.addr(12 downto 3)=ibaddr_deuna(12 downto 3) then
177 n.ibsel := '1';
178 end if;
179
180 -- ibus transactions
181
182 if r.ibsel='1' then -- selected
183
184 case IB_MREQ.addr(2 downto 1) is
185
186 when ibaddr_pr0 => -- PCSR0 - intr and pcmd -----------
187 if ibrem = '0' then -- loc view of upper byte
188 idout(pr0_ibf_seri) := r.pr0seri;
189 idout(pr0_ibf_pcei) := r.pr0pcei;
190 idout(pr0_ibf_rxi) := r.pr0rxi;
191 idout(pr0_ibf_txi) := r.pr0txi;
192 idout(pr0_ibf_dni) := r.pr0dni;
193 idout(pr0_ibf_rcbi) := r.pr0rcbi;
194 idout(pr0_ibf_usci) := r.pr0usci;
195 else -- rem view of upper byte
196 idout(pr0_ibf_pcmdbp) := r.pcmdbp;
197 idout(pr0_ibf_pdmdwb) := r.pdmdwb;
198 idout(pr0_ibf_busy) := r.busy;
199 idout(pr0_ibf_pcwwb) := r.pcmdwwb;
200 end if;
201 idout(pr0_ibf_intr) := r.pr0intr;
202 idout(pr0_ibf_inte) := r.pr0inte;
203 if ibrem = '1' then
204 idout(pr0_ibf_rset) := r.pr0rset; -- only seen from rem side
205 idout(pr0_ibf_brst) := r.pr0brst; -- only seen from rem side
206 end if;
207 idout(pr0_ibf_pcmd) := r.pr0pcmd;
208
209 if IB_MREQ.we = '1' then
210 if ibrem = '1' then -- rem write
211 if IB_MREQ.din(pr0_ibf_seri) = '1' then n.pr0seri := '1'; end if;
212 if IB_MREQ.din(pr0_ibf_pcei) = '1' then
213 n.pcmdwwb := '0';
214 n.pdmdwb := '0';
215 n.busy := '0';
216 n.pr0pcei := '1';
217 end if;
218 if IB_MREQ.din(pr0_ibf_rxi) = '1' then n.pr0rxi := '1'; end if;
219 if IB_MREQ.din(pr0_ibf_txi) = '1' then n.pr0txi := '1'; end if;
220 if IB_MREQ.din(pr0_ibf_dni) = '1' then
221 n.pcmdwwb := '0';
222 n.pdmdwb := '0';
223 -- if pdmd issued while busy, restart with pdmd, else end pcmd
224 if r.pcmdwwb = '1' and r.pr0pcmd = pcmd_pdmd then
225 n.pcmdbp := pcmd_pdmd;
226 n.pdmdwb := '1';
227 ilam := '1'; -- rri lam: restart with pdmd
228 else
229 n.busy := '0';
230 n.pr0dni := '1';
231 end if;
232 end if;
233 if IB_MREQ.din(pr0_ibf_rcbi) = '1' then n.pr0rcbi := '1'; end if;
234 if IB_MREQ.din(pr0_ibf_busy) = '1' then n.busy := '0'; end if;
235 if IB_MREQ.din(pr0_ibf_usci) = '1' then n.pr0usci := '1'; end if;
236 if IB_MREQ.din(pr0_ibf_rset) = '1' then
237 n.busy := '0';
238 n.pr0rset := '0';
239 end if;
240 if IB_MREQ.din(pr0_ibf_brst) = '1' then
241 n.busy := '0';
242 n.pr0brst := '0';
243 end if;
244
245 else -- loc write
246 if IB_MREQ.be1 = '1' then
247 if IB_MREQ.din(pr0_ibf_seri) = '1' then n.pr0seri := '0'; end if;
248 if IB_MREQ.din(pr0_ibf_pcei) = '1' then n.pr0pcei := '0'; end if;
249 if IB_MREQ.din(pr0_ibf_rxi) = '1' then n.pr0rxi := '0'; end if;
250 if IB_MREQ.din(pr0_ibf_txi) = '1' then n.pr0txi := '0'; end if;
251 if IB_MREQ.din(pr0_ibf_dni) = '1' then n.pr0dni := '0'; end if;
252 if IB_MREQ.din(pr0_ibf_rcbi) = '1' then n.pr0rcbi := '0'; end if;
253 if IB_MREQ.din(pr0_ibf_usci) = '1' then n.pr0usci := '0'; end if;
254 end if;
255 if IB_MREQ.be0 = '1' then
256 if IB_MREQ.din(pr0_ibf_rset) = '1' then -- RESET requested ?
257 n.resreq := '1';
258 n.pr0rset := '1';
259 elsif IB_MREQ.din(pr0_ibf_inte) /= r.pr0inte then -- INTE change?
260 n.pr0inte := IB_MREQ.din(pr0_ibf_inte);
261 n.pr0dni := '1';
262 elsif r.pr1state /= state_reset then -- not in reset
263 n.pr0pcmd := IB_MREQ.din(pr0_ibf_pcmd);
264 if r.busy = '0' then -- if not busy execute
265 n.pcmdbp := IB_MREQ.din(pr0_ibf_pcmd);
266 if IB_MREQ.din(pr0_ibf_pcmd) /= pcmd_noop then
267 n.busy := '1'; -- signal busy
268 ilam := '1'; -- rri lam
269 end if;
270 else -- if busy set pcmdwwf flag
271 n.pcmdwwb := '1';
272 end if;
273 end if;
274 end if; -- if IB_MREQ.be0 = '1'
275 end if; -- else ibrem = '1'
276 end if; -- if IB_MREQ.we = '1'
277
278 when ibaddr_pr1 => -- PCSR1 - status ------------------
279 idout(pr1_ibf_xpwr) := r.pr1xpwr;
280 idout(pr1_ibf_icab) := r.pr1icab;
281 idout(pr1_ibf_pcto) := r.pr1pcto;
282 idout(pr1_ibf_deuna) := r.pr1deuna;
283 idout(pr1_ibf_state) := r.pr1state;
284 if IB_MREQ.we = '1' then
285 if ibrem = '1' then
286 n.pr1xpwr := IB_MREQ.din(pr1_ibf_xpwr);
287 n.pr1icab := IB_MREQ.din(pr1_ibf_icab);
288 n.pr1pcto := IB_MREQ.din(pr1_ibf_pcto);
289 n.pr1deuna := IB_MREQ.din(pr1_ibf_deuna);
290 n.pr1state := IB_MREQ.din(pr1_ibf_state);
291 end if;
292 end if;
293
294 when ibaddr_pr2 => -- PCSR2 - pcbb low order ----------
295 idout(15 downto 1) := r.pcbb(15 downto 1);
296 if IB_MREQ.we = '1' then
297 n.pcbb(15 downto 1) := IB_MREQ.din(15 downto 1);
298 end if;
299
300 when ibaddr_pr3 => -- PCSR2 - pcbb high order ---------
301 idout( 1 downto 0) := r.pcbb(17 downto 16);
302 if IB_MREQ.we = '1' then
303 n.pcbb(17 downto 16) := IB_MREQ.din( 1 downto 0);
304 end if;
305
306 when others => null;
307
308 end case;
309 end if;
310
311 if BRESET = '1' then
312 n.resreq := '1';
313 n.pr0brst := '1';
314 end if;
315
316 if r.resreq = '1' then
317 n.pr0seri := '0';
318 n.pr0pcei := '0';
319 n.pr0rxi := '0';
320 n.pr0txi := '0';
321 n.pr0dni := '0';
322 n.pr0rcbi := '0';
323 n.pr0usci := '0';
324 n.pr1pcto := '0';
325 n.pr0inte := '0';
326 n.pr1state := state_reset;
327 n.pcbb := (others => '0');
328 n.resreq := '0';
329 -- send lam on soft or bus reset only when not in state_reset
330 -- the startup default is state_reset, so without active backend
331 -- this device will not send lam's on bus resets
332 if r.pr1state /= state_reset then
333 n.busy := '1'; -- signal busy
334 ilam := '1'; -- rri lam unless reset handling pending
335 end if;
336
337 end if;
338
339 n.pr0intr := r.pr0seri or r.pr0pcei or r.pr0rxi or r.pr0txi or
340 r.pr0dni or r.pr0rcbi or r.pr0usci;
341
342 if r.pr0inte = '1' then
343 n.ireq := r.pr0intr;
344 else
345 n.ireq := '0';
346 end if;
347
348 N_REGS <= n;
349
350 IB_SRES.dout <= idout;
351 IB_SRES.ack <= r.ibsel and ibreq;
352 IB_SRES.busy <= ibhold and ibreq;
353
354 RB_LAM <= ilam;
355 EI_REQ <= r.ireq;
356
357 end process proc_next;
358
359
360end syn;
regs_type :=( '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',( others => '0'), '1', '1', '0', '0', state_reset,( others => '0'), '0', '0', '0',( others => '0'), '0', '0') regs_init
Definition: ibdr_deuna.vhd:116
slv2 := "10" ibaddr_pr2
Definition: ibdr_deuna.vhd:54
integer range 3 downto 0 pr0_ibf_pcmd
Definition: ibdr_deuna.vhd:67
slv4 := "0010" state_ready
Definition: ibdr_deuna.vhd:86
integer := 11 pr0_ibf_dni
Definition: ibdr_deuna.vhd:61
integer := 12 pr0_ibf_txi
Definition: ibdr_deuna.vhd:60
integer := 10 pr0_ibf_rcbi
Definition: ibdr_deuna.vhd:62
integer := 15 pr0_ibf_seri
Definition: ibdr_deuna.vhd:57
integer := 9 pr0_ibf_busy
Definition: ibdr_deuna.vhd:71
slv4 := "0000" state_reset
Definition: ibdr_deuna.vhd:85
integer range 3 downto 0 pr1_ibf_state
Definition: ibdr_deuna.vhd:83
integer := 14 pr1_ibf_icab
Definition: ibdr_deuna.vhd:79
slv2 := "11" ibaddr_pr3
Definition: ibdr_deuna.vhd:55
slv4 := "0000" pcmd_noop
Definition: ibdr_deuna.vhd:75
slv4 := "1000" pcmd_pdmd
Definition: ibdr_deuna.vhd:76
regs_type := regs_init N_REGS
Definition: ibdr_deuna.vhd:134
integer := 14 pr0_ibf_pcei
Definition: ibdr_deuna.vhd:58
integer := 6 pr0_ibf_inte
Definition: ibdr_deuna.vhd:65
integer range 13 downto 8 pr1_ibf_ecod
Definition: ibdr_deuna.vhd:80
integer := 4 pr1_ibf_deuna
Definition: ibdr_deuna.vhd:82
integer := 15 pr1_ibf_xpwr
Definition: ibdr_deuna.vhd:78
integer := 10 pr0_ibf_pdmdwb
Definition: ibdr_deuna.vhd:70
integer := 7 pr1_ibf_pcto
Definition: ibdr_deuna.vhd:81
integer := 13 pr0_ibf_rxi
Definition: ibdr_deuna.vhd:59
regs_type := regs_init R_REGS
Definition: ibdr_deuna.vhd:133
slv16 := slv( to_unsigned( 8#174510#, 16) ) ibaddr_deuna
Definition: ibdr_deuna.vhd:50
slv2 := "00" ibaddr_pr0
Definition: ibdr_deuna.vhd:52
integer range 15 downto 12 pr0_ibf_pcmdbp
Definition: ibdr_deuna.vhd:69
slv2 := "01" ibaddr_pr1
Definition: ibdr_deuna.vhd:53
integer := 4 pr0_ibf_brst
Definition: ibdr_deuna.vhd:73
integer := 5 pr0_ibf_rset
Definition: ibdr_deuna.vhd:66
integer := 8 pr0_ibf_pcwwb
Definition: ibdr_deuna.vhd:72
integer := 7 pr0_ibf_intr
Definition: ibdr_deuna.vhd:64
integer := 8 pr0_ibf_usci
Definition: ibdr_deuna.vhd:63
out EI_REQ slbit
Definition: ibdr_deuna.vhd:43
in BRESET slbit
Definition: ibdr_deuna.vhd:39
out RB_LAM slbit
Definition: ibdr_deuna.vhd:40
in CLK slbit
Definition: ibdr_deuna.vhd:38
in IB_MREQ ib_mreq_type
Definition: ibdr_deuna.vhd:41
out IB_SRES ib_sres_type
Definition: ibdr_deuna.vhd:42
in EI_ACK slbit
Definition: ibdr_deuna.vhd:45
Definition: iblib.vhd:33
std_logic_vector( 3 downto 0) slv4
Definition: slvtypes.vhd:36
std_logic_vector( 15 downto 0) slv16
Definition: slvtypes.vhd:48
std_logic slbit
Definition: slvtypes.vhd:30
std_logic_vector( 17 downto 1) slv18_1
Definition: slvtypes.vhd:68
std_logic_vector( 1 downto 0) slv2
Definition: slvtypes.vhd:34
std_logic_vector slv
Definition: slvtypes.vhd:31