1 |
37 |
wfjm |
-- $Id: ibdr_rl11.vhd 784 2016-07-09 22:17:01Z mueller $
|
2 |
29 |
wfjm |
--
|
3 |
36 |
wfjm |
-- Copyright 2014-2016 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
4 |
29 |
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 |
|
|
-- Module Name: ibdr_rl11 - syn
|
16 |
|
|
-- Description: ibus dev(rem): RL11
|
17 |
|
|
--
|
18 |
|
|
-- Dependencies: ram_1swar_gen
|
19 |
|
|
-- Test bench: -
|
20 |
|
|
-- Target Devices: generic
|
21 |
36 |
wfjm |
-- Tool versions: ise 14.7; viv 2014.4-2016.1; ghdl 0.31-0.33
|
22 |
29 |
wfjm |
--
|
23 |
|
|
-- Synthesized (xst):
|
24 |
|
|
-- Date Rev ise Target flop lutl lutm slic t peri
|
25 |
|
|
-- 2015-02-28 653 14.7 131013 xc6slx16-2 80 197 12 80 s 7.9
|
26 |
|
|
-- 2014-06-15 562 14.7 131013 xc6slx16-2 81 199 13 78 s 8.0
|
27 |
|
|
--
|
28 |
|
|
-- Revision History:
|
29 |
|
|
-- Date Rev Version Comment
|
30 |
37 |
wfjm |
-- 2016-05-22 767 1.0.2 don't init N_REGS (vivado fix for fsm inference)
|
31 |
29 |
wfjm |
-- 2015-03-04 655 1.0.1 seek: ignore da(6:5), don't check for 0 anymore
|
32 |
|
|
-- 2015-02-28 653 1.0 Initial verison
|
33 |
|
|
-- 2014-06-09 561 0.1 First draft
|
34 |
|
|
------------------------------------------------------------------------------
|
35 |
|
|
|
36 |
|
|
library ieee;
|
37 |
|
|
use ieee.std_logic_1164.all;
|
38 |
|
|
use ieee.numeric_std.all;
|
39 |
|
|
|
40 |
|
|
use work.slvtypes.all;
|
41 |
|
|
use work.memlib.all;
|
42 |
|
|
use work.iblib.all;
|
43 |
|
|
|
44 |
|
|
-- ----------------------------------------------------------------------------
|
45 |
|
|
entity ibdr_rl11 is -- ibus dev(rem): RL11
|
46 |
|
|
-- fixed address: 174400
|
47 |
|
|
port (
|
48 |
|
|
CLK : in slbit; -- clock
|
49 |
|
|
CE_MSEC : in slbit; -- msec pulse
|
50 |
|
|
BRESET : in slbit; -- ibus reset
|
51 |
|
|
RB_LAM : out slbit; -- remote attention
|
52 |
|
|
IB_MREQ : in ib_mreq_type; -- ibus request
|
53 |
|
|
IB_SRES : out ib_sres_type; -- ibus response
|
54 |
|
|
EI_REQ : out slbit; -- interrupt request
|
55 |
|
|
EI_ACK : in slbit -- interrupt acknowledge
|
56 |
|
|
);
|
57 |
|
|
end ibdr_rl11;
|
58 |
|
|
|
59 |
|
|
architecture syn of ibdr_rl11 is
|
60 |
|
|
|
61 |
|
|
constant ibaddr_rl11 : slv16 := slv(to_unsigned(8#174400#,16));
|
62 |
|
|
|
63 |
|
|
constant ibaddr_rlcs : slv2 := "00"; -- rlcs address offset
|
64 |
|
|
constant ibaddr_rlba : slv2 := "01"; -- rlba address offset
|
65 |
|
|
constant ibaddr_rlda : slv2 := "10"; -- rlda address offset
|
66 |
|
|
constant ibaddr_rlmp : slv2 := "11"; -- rlmp address offset
|
67 |
|
|
|
68 |
|
|
-- usage of 16x16 memory bank
|
69 |
|
|
-- 0 0000 unused (but mirrors rlcs)
|
70 |
|
|
-- 1 0001 rlba
|
71 |
|
|
-- 2 0010 unused (but mirrors rlda)
|
72 |
|
|
-- 3 0011 rlmp (1st value)
|
73 |
|
|
-- 4 0100 rlmp (3rd value after gs; the crc)
|
74 |
|
|
-- 5 0101 unused
|
75 |
|
|
-- 6 0110 unused
|
76 |
|
|
-- 7 0111 unused (target for bad mprem states)
|
77 |
|
|
-- 11: 8 10-- sta(ds) (drive status)
|
78 |
|
|
-- 15:12 11-- pos(ds) (drive disk address)
|
79 |
|
|
constant imem_cs : slv4 := "0000"; -- unused
|
80 |
|
|
constant imem_ba : slv4 := "0001";
|
81 |
|
|
constant imem_da : slv4 := "0010"; -- unused
|
82 |
|
|
constant imem_mp : slv4 := "0011";
|
83 |
|
|
constant imem_crc : slv4 := "0100";
|
84 |
|
|
constant imem_bad : slv4 := "0111"; -- target for bad mprem states
|
85 |
|
|
constant imem_sta : slv4 := "1000";
|
86 |
|
|
constant imem_pos : slv4 := "1100";
|
87 |
|
|
|
88 |
|
|
subtype imf_typ is integer range 3 downto 2;
|
89 |
|
|
subtype imf_ds is integer range 1 downto 0;
|
90 |
|
|
|
91 |
|
|
constant rlcs_ibf_err : integer := 15;
|
92 |
|
|
constant rlcs_ibf_de : integer := 14;
|
93 |
|
|
subtype rlcs_ibf_e is integer range 13 downto 10;
|
94 |
|
|
subtype rlcs_ibf_ds is integer range 9 downto 8;
|
95 |
|
|
constant rlcs_ibf_crdy : integer := 7;
|
96 |
|
|
constant rlcs_ibf_ie : integer := 6;
|
97 |
|
|
subtype rlcs_ibf_bae is integer range 5 downto 4;
|
98 |
|
|
subtype rlcs_ibf_func is integer range 3 downto 1;
|
99 |
|
|
constant rlcs_ibf_drdy : integer := 0;
|
100 |
|
|
|
101 |
|
|
constant func_noop : slv3 := "000"; -- func: noop
|
102 |
|
|
constant func_wchk : slv3 := "001"; -- func: write check
|
103 |
|
|
constant func_gs : slv3 := "010"; -- func: get status
|
104 |
|
|
constant func_seek : slv3 := "011"; -- func: seek
|
105 |
|
|
constant func_rhdr : slv3 := "100"; -- func: read header
|
106 |
|
|
constant func_write : slv3 := "101"; -- func: write data
|
107 |
|
|
constant func_read : slv3 := "110"; -- func: read data
|
108 |
|
|
constant func_rnhc : slv3 := "111"; -- func: read data without header check
|
109 |
|
|
|
110 |
|
|
constant e_ok : slv4 := "0000"; -- e code: ok
|
111 |
|
|
constant e_incomp : slv4 := "0001"; -- e code: operation incomplete
|
112 |
|
|
|
113 |
|
|
-- defs for rem access of rlcs; func codes
|
114 |
|
|
constant rfunc_wcs : slv3 := "001"; -- rem func: write cs (err,de,e,drdy)
|
115 |
|
|
constant rfunc_wmp : slv3 := "010"; -- rem func: write mprem or mploc
|
116 |
|
|
|
117 |
|
|
-- rlcs usage or rem func=wmp
|
118 |
|
|
subtype rlcs_ibf_mprem is integer range 15 downto 11;
|
119 |
|
|
subtype rlcs_ibf_mploc is integer range 10 downto 8;
|
120 |
|
|
constant rlcs_ibf_ena_mprem : integer := 5;
|
121 |
|
|
constant rlcs_ibf_ena_mploc : integer := 4;
|
122 |
|
|
|
123 |
|
|
subtype rlda_ibf_seek_df is integer range 15 downto 7;
|
124 |
|
|
constant rlda_ibf_seek_hs : integer := 4;
|
125 |
|
|
constant rlda_ibf_seek_dir : integer := 2;
|
126 |
|
|
constant rlda_msk_seek : slv16 := "0000000000001011";
|
127 |
|
|
constant rlda_val_seek : slv16 := "0000000000000001";
|
128 |
|
|
|
129 |
|
|
constant rlda_ibf_gs_rst : integer := 3;
|
130 |
|
|
constant rlda_msk_gs : slv16 := "0000000011110111";
|
131 |
|
|
constant rlda_val_gs : slv16 := "0000000000000011";
|
132 |
|
|
|
133 |
|
|
constant sta_ibf_wde : integer := 15; -- Write data error - always 0
|
134 |
|
|
constant sta_ibf_che : integer := 14; -- Current head error - always 0
|
135 |
|
|
constant sta_ibf_wl : integer := 13; -- Write lock - used
|
136 |
|
|
constant sta_ibf_sto : integer := 12; -- Seek time out - used
|
137 |
|
|
constant sta_ibf_spe : integer := 11; -- Spin error - used
|
138 |
|
|
constant sta_ibf_wge : integer := 10; -- Write gate error - used
|
139 |
|
|
constant sta_ibf_vce : integer := 9; -- Volume check - used
|
140 |
|
|
constant sta_ibf_dse : integer := 8; -- Drive select error - used
|
141 |
|
|
constant sta_ibf_dt : integer := 7; -- Drive type - used
|
142 |
|
|
constant sta_ibf_hs : integer := 6; -- Head select - used
|
143 |
|
|
constant sta_ibf_co : integer := 5; -- Cover open - used
|
144 |
|
|
constant sta_ibf_ho : integer := 4; -- Heads out - used
|
145 |
|
|
constant sta_ibf_bh : integer := 3; -- Brush home - always 1
|
146 |
|
|
subtype sta_ibf_st is integer range 2 downto 0; -- Drive state
|
147 |
|
|
|
148 |
|
|
constant st_load : slv3 := "000"; -- st: Load(ing) cartidge - used
|
149 |
|
|
constant st_spin : slv3 := "001"; -- st: Spin(ing) up - !unused!
|
150 |
|
|
constant st_brush : slv3 := "010"; -- st: Brush(ing) cycle - !unused!
|
151 |
|
|
constant st_hload : slv3 := "011"; -- st: Load(ing) heads - !unused!
|
152 |
|
|
constant st_seek : slv3 := "100"; -- st: Seek(ing) - may be used
|
153 |
|
|
constant st_lock : slv3 := "101"; -- st: Lock(ed) on - used
|
154 |
|
|
constant st_unl : slv3 := "110"; -- st: Unload(ing) heads - !unused!
|
155 |
|
|
constant st_down : slv3 := "111"; -- st: Spin(ing) down - !unused!
|
156 |
|
|
-- only two mayor drive states are used
|
157 |
|
|
-- on: st=lock; ho=1; co=0; ( file connected in backend)
|
158 |
|
|
-- off: st=load; ho=0; co=1; (no file connected in backend)
|
159 |
|
|
|
160 |
|
|
subtype pos_ibf_ca is integer range 15 downto 7;
|
161 |
|
|
constant pos_ibf_hs : integer := 6;
|
162 |
|
|
subtype pos_ibf_sa is integer range 5 downto 0;
|
163 |
|
|
|
164 |
|
|
constant mploc_mp : slv3 := "000"; -- return imem(mp)
|
165 |
|
|
constant mploc_sta : slv3 := "001"; -- return sta(ds)
|
166 |
|
|
constant mploc_pos : slv3 := "010"; -- return pos(ds)
|
167 |
|
|
constant mploc_zero : slv3 := "011"; -- return 0
|
168 |
|
|
constant mploc_crc : slv3 := "100"; -- return imem(crc)
|
169 |
|
|
|
170 |
|
|
constant mprem_f_map : integer := 4; -- mprem map enable
|
171 |
|
|
subtype mprem_f_addr is integer range 3 downto 0;
|
172 |
|
|
constant mprem_f_seq : integer := 3; -- mprem seq enable
|
173 |
|
|
subtype mprem_f_state is integer range 2 downto 0;
|
174 |
|
|
constant mprem_mapseq : slv2 := "11"; -- enable map + seq
|
175 |
|
|
constant mprem_s_mp : slv3 := "000"; -- access imem(mp)
|
176 |
|
|
constant mprem_s_sta : slv3 := "001"; -- access sta(ds)
|
177 |
|
|
constant mprem_s_pos : slv3 := "010"; -- access pos(ds)
|
178 |
|
|
constant mprem_init : slv5 := "10000"; -- enable map,fix, show mp
|
179 |
|
|
|
180 |
|
|
constant ca_max_rl01 : slv9 := "011111111"; -- max cylinder for RL01 (255)
|
181 |
|
|
constant ca_max_rl02 : slv9 := "111111111"; -- max cylinder for RL02 (511)
|
182 |
|
|
|
183 |
|
|
type state_type is (
|
184 |
|
|
s_idle, -- idle: handle ibus
|
185 |
|
|
s_csread, -- csread: handle cs read
|
186 |
|
|
s_gs_rpos, -- gs_rpos: read pos(ds)
|
187 |
|
|
s_gs_sta, -- gs_sta: handle status
|
188 |
|
|
s_seek_rsta, -- seek_rsta: read sta(ds)
|
189 |
|
|
s_seek_rpos, -- seek_rpos: read pos(ds)
|
190 |
|
|
s_seek_clip, -- seek_clip: clip new ca
|
191 |
|
|
s_seek_wpos, -- seek_wpos: write pos(ds)
|
192 |
|
|
s_init -- init: handle init
|
193 |
|
|
);
|
194 |
|
|
|
195 |
|
|
type regs_type is record -- state registers
|
196 |
|
|
ibsel : slbit; -- ibus select
|
197 |
|
|
state : state_type; -- state
|
198 |
|
|
iaddr : slv4; -- init addr counter
|
199 |
|
|
cserr : slbit; -- rlcs: composite error
|
200 |
|
|
csde : slbit; -- rlcs: drive error
|
201 |
|
|
cse : slv4; -- rlcs: error
|
202 |
|
|
csds : slv2; -- rlcs: drive select
|
203 |
|
|
cscrdy : slbit; -- rlcs: controller ready
|
204 |
|
|
csie : slbit; -- rlcs: interrupt enable
|
205 |
|
|
csbae : slv2; -- rlcs: bus address extenstion
|
206 |
|
|
csfunc : slv3; -- rlcs: function code
|
207 |
|
|
csdrdy : slbit; -- rlcs: drive ready
|
208 |
|
|
da : slv16; -- rlda shadow reg
|
209 |
|
|
gshs : slbit; -- gs: pos(ds)(hs) (head select)
|
210 |
|
|
seekdt : slbit; -- seek: drive type: 0=RL01, 1=RL02
|
211 |
|
|
seekcan: slv10; -- seek: cylinder address, new
|
212 |
|
|
seekcac: slv9; -- seek: cylinder address, clipped
|
213 |
|
|
ireq : slbit; -- interrupt request flag
|
214 |
|
|
mploc : slv3; -- mp loc state
|
215 |
|
|
mprem : slv5; -- mp rem state
|
216 |
|
|
crdone : slbit; -- control reset done since last fdone
|
217 |
|
|
end record regs_type;
|
218 |
|
|
|
219 |
|
|
constant regs_init : regs_type := (
|
220 |
|
|
'0', -- ibsel
|
221 |
|
|
s_init, -- state
|
222 |
|
|
imem_ba, -- iaddr
|
223 |
|
|
'0','0', -- cserr,csde
|
224 |
|
|
(others=>'0'), -- cse
|
225 |
|
|
(others=>'0'), -- csds
|
226 |
|
|
'1','0', -- cscrdy, csie
|
227 |
|
|
(others=>'0'), -- csbae
|
228 |
|
|
(others=>'0'), -- csfunc
|
229 |
|
|
'0', -- csdrdy
|
230 |
|
|
(others=>'0'), -- da
|
231 |
|
|
'0', -- gshs
|
232 |
|
|
'0', -- seekdt
|
233 |
|
|
(others=>'0'), -- seekcan
|
234 |
|
|
(others=>'0'), -- seekcac
|
235 |
|
|
'0', -- ireq
|
236 |
|
|
mploc_mp, -- mploc
|
237 |
|
|
mprem_init, -- mprem
|
238 |
|
|
'1' -- crdone
|
239 |
|
|
);
|
240 |
|
|
|
241 |
|
|
signal R_REGS : regs_type := regs_init;
|
242 |
36 |
wfjm |
signal N_REGS : regs_type; -- don't init (vivado fix for fsm infer)
|
243 |
29 |
wfjm |
|
244 |
|
|
signal MEM_1_WE : slbit := '0';
|
245 |
|
|
signal MEM_0_WE : slbit := '0';
|
246 |
|
|
signal MEM_ADDR : slv4 := (others=>'0');
|
247 |
|
|
signal MEM_DIN : slv16 := (others=>'0');
|
248 |
|
|
signal MEM_DOUT : slv16 := (others=>'0');
|
249 |
|
|
|
250 |
|
|
begin
|
251 |
|
|
|
252 |
|
|
MEM_1 : ram_1swar_gen
|
253 |
|
|
generic map (
|
254 |
|
|
AWIDTH => 4,
|
255 |
|
|
DWIDTH => 8)
|
256 |
|
|
port map (
|
257 |
|
|
CLK => CLK,
|
258 |
|
|
WE => MEM_1_WE,
|
259 |
|
|
ADDR => MEM_ADDR,
|
260 |
|
|
DI => MEM_DIN(ibf_byte1),
|
261 |
|
|
DO => MEM_DOUT(ibf_byte1));
|
262 |
|
|
|
263 |
|
|
MEM_0 : ram_1swar_gen
|
264 |
|
|
generic map (
|
265 |
|
|
AWIDTH => 4,
|
266 |
|
|
DWIDTH => 8)
|
267 |
|
|
port map (
|
268 |
|
|
CLK => CLK,
|
269 |
|
|
WE => MEM_0_WE,
|
270 |
|
|
ADDR => MEM_ADDR,
|
271 |
|
|
DI => MEM_DIN(ibf_byte0),
|
272 |
|
|
DO => MEM_DOUT(ibf_byte0));
|
273 |
|
|
|
274 |
|
|
proc_regs: process (CLK)
|
275 |
|
|
begin
|
276 |
|
|
if rising_edge(CLK) then
|
277 |
|
|
if BRESET='1' then
|
278 |
|
|
R_REGS <= regs_init;
|
279 |
|
|
else
|
280 |
|
|
R_REGS <= N_REGS;
|
281 |
|
|
end if;
|
282 |
|
|
end if;
|
283 |
|
|
end process proc_regs;
|
284 |
|
|
|
285 |
|
|
proc_next : process (R_REGS, CE_MSEC, IB_MREQ, MEM_DOUT, EI_ACK)
|
286 |
|
|
variable r : regs_type := regs_init;
|
287 |
|
|
variable n : regs_type := regs_init;
|
288 |
|
|
variable ibhold : slbit := '0';
|
289 |
|
|
variable idout : slv16 := (others=>'0');
|
290 |
|
|
variable ibrem : slbit := '0';
|
291 |
|
|
variable ibreq : slbit := '0';
|
292 |
|
|
variable ibrd : slbit := '0';
|
293 |
|
|
variable ibw0 : slbit := '0';
|
294 |
|
|
variable ibw1 : slbit := '0';
|
295 |
|
|
variable ibwrem : slbit := '0';
|
296 |
|
|
variable ilam : slbit := '0';
|
297 |
|
|
variable iei_req : slbit := '0';
|
298 |
|
|
|
299 |
|
|
variable imem_we0 : slbit := '0';
|
300 |
|
|
variable imem_we1 : slbit := '0';
|
301 |
|
|
variable imem_addr : slv4 := (others=>'0');
|
302 |
|
|
variable imem_din : slv16 := (others=>'0');
|
303 |
|
|
begin
|
304 |
|
|
|
305 |
|
|
r := R_REGS;
|
306 |
|
|
n := R_REGS;
|
307 |
|
|
|
308 |
|
|
ibhold := '0';
|
309 |
|
|
idout := (others=>'0');
|
310 |
|
|
ibrem := IB_MREQ.racc;
|
311 |
|
|
ibreq := IB_MREQ.re or IB_MREQ.we;
|
312 |
|
|
ibrd := IB_MREQ.re;
|
313 |
|
|
ibw0 := IB_MREQ.we and IB_MREQ.be0;
|
314 |
|
|
ibw1 := IB_MREQ.we and IB_MREQ.be1;
|
315 |
|
|
ibwrem := IB_MREQ.we and ibrem;
|
316 |
|
|
ilam := '0';
|
317 |
|
|
iei_req := '0';
|
318 |
|
|
|
319 |
|
|
imem_we0 := '0';
|
320 |
|
|
imem_we1 := '0';
|
321 |
|
|
imem_addr := "00" & IB_MREQ.addr(2 downto 1);
|
322 |
|
|
imem_din := IB_MREQ.din;
|
323 |
|
|
|
324 |
|
|
-- ibus address decoder
|
325 |
|
|
n.ibsel := '0';
|
326 |
|
|
if IB_MREQ.aval = '1' and
|
327 |
|
|
IB_MREQ.addr(12 downto 3)=ibaddr_rl11(12 downto 3) then
|
328 |
|
|
n.ibsel := '1';
|
329 |
|
|
end if;
|
330 |
|
|
|
331 |
|
|
-- internal state machine
|
332 |
|
|
case r.state is
|
333 |
|
|
when s_idle => -- idle: handle ibus -----------------
|
334 |
|
|
|
335 |
|
|
if r.ibsel='1' then -- selected
|
336 |
|
|
idout := MEM_DOUT;
|
337 |
|
|
imem_we0 := ibw0;
|
338 |
|
|
imem_we1 := ibw1;
|
339 |
|
|
|
340 |
|
|
case IB_MREQ.addr(2 downto 1) is
|
341 |
|
|
|
342 |
|
|
when ibaddr_rlcs => -- RLCS - control register -------
|
343 |
|
|
imem_we0 := '0'; -- MEM not used for rlcs
|
344 |
|
|
imem_we1 := '0';
|
345 |
|
|
imem_addr := imem_sta(imf_typ) & r.csds; -- get sta(ds)
|
346 |
|
|
|
347 |
|
|
-- determine DRDY
|
348 |
|
|
n.csdrdy := '1';
|
349 |
|
|
if MEM_DOUT(sta_ibf_st) /= st_lock or -- drive not on and locked
|
350 |
|
|
MEM_DOUT(sta_ibf_vce) = '1' then -- or volume check
|
351 |
|
|
-- ??? also CRDY=0 here ???
|
352 |
|
|
n.csdrdy := '0';
|
353 |
|
|
end if;
|
354 |
|
|
|
355 |
|
|
-- determine DE and ERR
|
356 |
|
|
n.cserr := '0';
|
357 |
|
|
if MEM_DOUT(sta_ibf_st) = st_load or -- drive off
|
358 |
|
|
MEM_DOUT(sta_ibf_vce) = '1' then -- or volume check
|
359 |
|
|
n.csde := '1';
|
360 |
|
|
n.cserr := '1';
|
361 |
|
|
end if;
|
362 |
|
|
if r.csde = '1' or r.cse /= e_ok then
|
363 |
|
|
n.cserr := '1';
|
364 |
|
|
end if;
|
365 |
|
|
|
366 |
|
|
if ibrd = '1' then -- cs read
|
367 |
|
|
ibhold := '1';
|
368 |
|
|
n.state := s_csread;
|
369 |
|
|
|
370 |
|
|
elsif IB_MREQ.we = '1' then -- cs write
|
371 |
|
|
|
372 |
|
|
if ibrem = '0' then -- loc write access
|
373 |
|
|
|
374 |
|
|
if IB_MREQ.be1 = '1' then
|
375 |
|
|
if r.cscrdy = '1' then -- freeze csds when busy
|
376 |
|
|
n.csds := IB_MREQ.din(rlcs_ibf_ds);
|
377 |
|
|
end if;
|
378 |
|
|
end if;
|
379 |
|
|
|
380 |
|
|
if IB_MREQ.be0 = '1' then
|
381 |
|
|
n.csie := IB_MREQ.din(rlcs_ibf_ie);
|
382 |
|
|
n.csbae := IB_MREQ.din(rlcs_ibf_bae);
|
383 |
|
|
|
384 |
|
|
if r.cscrdy = '1' then -- controller ready
|
385 |
|
|
|
386 |
|
|
n.csfunc := IB_MREQ.din(rlcs_ibf_func); -- latch func
|
387 |
|
|
if IB_MREQ.din(rlcs_ibf_crdy) = '1' then -- no crdy clr
|
388 |
|
|
if IB_MREQ.din(rlcs_ibf_ie) = '1' and r.csie = '0' then
|
389 |
|
|
n.ireq := '1';
|
390 |
|
|
end if;
|
391 |
|
|
else -- crdy clr --> handle func
|
392 |
|
|
|
393 |
|
|
n.cserr := '0'; -- clear errors
|
394 |
|
|
n.csde := '0';
|
395 |
|
|
n.cse := "0000";
|
396 |
|
|
|
397 |
|
|
case IB_MREQ.din(rlcs_ibf_func) is
|
398 |
|
|
when func_noop => -- noop -------
|
399 |
|
|
n.ireq := r.csie; -- interrupt
|
400 |
|
|
|
401 |
|
|
when func_gs => -- get status -
|
402 |
|
|
if (r.da and rlda_msk_gs) /= rlda_val_gs then
|
403 |
|
|
n.cserr := '1';
|
404 |
|
|
n.cse := e_incomp;
|
405 |
|
|
n.ireq := IB_MREQ.din(rlcs_ibf_ie);
|
406 |
|
|
else
|
407 |
|
|
ibhold := '1';
|
408 |
|
|
n.state := s_gs_rpos;
|
409 |
|
|
end if;
|
410 |
|
|
|
411 |
|
|
when func_seek => -- seek -------
|
412 |
|
|
if (r.da and rlda_msk_seek) /= rlda_val_seek then
|
413 |
|
|
n.cserr := '1';
|
414 |
|
|
n.cse := e_incomp;
|
415 |
|
|
n.ireq := IB_MREQ.din(rlcs_ibf_ie);
|
416 |
|
|
else
|
417 |
|
|
ibhold := '1';
|
418 |
|
|
n.state := s_seek_rsta;
|
419 |
|
|
end if;
|
420 |
|
|
|
421 |
|
|
when others => -- all other funcs
|
422 |
|
|
n.cscrdy := '0'; -- signal cntl busy
|
423 |
|
|
ilam := '1'; -- issue lam
|
424 |
|
|
end case;
|
425 |
|
|
|
426 |
|
|
end if; -- else IB_MREQ.din(rlcs_ibf_crdy) = '1'
|
427 |
|
|
end if; -- r.cscrdy = '1'
|
428 |
|
|
end if; -- IB_MREQ.be0 = '1'
|
429 |
|
|
|
430 |
|
|
else -- rem write access
|
431 |
|
|
case IB_MREQ.din(rlcs_ibf_func) is
|
432 |
|
|
|
433 |
|
|
when rfunc_wcs =>
|
434 |
|
|
n.csde := IB_MREQ.din(rlcs_ibf_de);
|
435 |
|
|
n.cse := IB_MREQ.din(rlcs_ibf_e);
|
436 |
|
|
n.cscrdy := IB_MREQ.din(rlcs_ibf_crdy);
|
437 |
|
|
n.csbae := IB_MREQ.din(rlcs_ibf_bae);
|
438 |
|
|
if r.cscrdy = '0' and IB_MREQ.din(rlcs_ibf_crdy) = '1' then
|
439 |
|
|
n.ireq := r.csie;
|
440 |
|
|
end if;
|
441 |
|
|
|
442 |
|
|
when rfunc_wmp =>
|
443 |
|
|
if IB_MREQ.din(rlcs_ibf_ena_mprem) = '1' then
|
444 |
|
|
n.mprem := IB_MREQ.din(rlcs_ibf_mprem);
|
445 |
|
|
end if;
|
446 |
|
|
if IB_MREQ.din(rlcs_ibf_ena_mploc) = '1' then
|
447 |
|
|
n.mploc := IB_MREQ.din(rlcs_ibf_mploc);
|
448 |
|
|
end if;
|
449 |
|
|
|
450 |
|
|
when others => null;
|
451 |
|
|
end case;
|
452 |
|
|
|
453 |
|
|
end if;
|
454 |
|
|
end if;
|
455 |
|
|
|
456 |
|
|
when ibaddr_rlba => -- RLBA - bus address register ---
|
457 |
|
|
imem_din(0) := '0'; -- lsb forced 0
|
458 |
|
|
null;
|
459 |
|
|
|
460 |
|
|
when ibaddr_rlda => -- RLDA - disk address register --
|
461 |
|
|
if ibw1 = '1' then
|
462 |
|
|
n.da(15 downto 8) := IB_MREQ.din(15 downto 8);
|
463 |
|
|
end if;
|
464 |
|
|
if ibw0 = '1' then
|
465 |
|
|
n.da( 7 downto 0) := IB_MREQ.din( 7 downto 0);
|
466 |
|
|
end if;
|
467 |
|
|
|
468 |
|
|
when ibaddr_rlmp => -- RLMP - multipurpose register --
|
469 |
|
|
|
470 |
|
|
if ibrem = '0' then -- loc access
|
471 |
|
|
if ibrd = '1' then -- loc mp read
|
472 |
|
|
case r.mploc is
|
473 |
|
|
when mploc_mp => -- return imem(mp)
|
474 |
|
|
null;
|
475 |
|
|
when mploc_sta => -- return sta(ds)
|
476 |
|
|
imem_addr := imem_sta(imf_typ) & r.csds;
|
477 |
|
|
when mploc_pos => -- return pos(ds)
|
478 |
|
|
imem_addr := imem_pos(imf_typ) & r.csds;
|
479 |
|
|
n.mploc := mploc_zero;
|
480 |
|
|
when mploc_zero => -- return 0
|
481 |
|
|
idout := (others => '0');
|
482 |
|
|
n.mploc := mploc_crc;
|
483 |
|
|
when mploc_crc => -- return imem(crc)
|
484 |
|
|
imem_addr := imem_crc;
|
485 |
|
|
when others => null;
|
486 |
|
|
end case;
|
487 |
|
|
elsif IB_MREQ.we = '1' then -- loc mp write
|
488 |
|
|
n.mploc := mploc_mp; -- use main mp reg in future
|
489 |
|
|
end if;
|
490 |
|
|
|
491 |
|
|
else -- rem access
|
492 |
|
|
if r.mprem(mprem_f_map) = '0' then -- map off - fixed addr
|
493 |
|
|
imem_addr := r.mprem(mprem_f_addr);
|
494 |
|
|
else -- sequence
|
495 |
|
|
case r.mprem(mprem_f_state) is
|
496 |
|
|
when mprem_s_mp => -- mp {used as wc}
|
497 |
|
|
imem_addr := imem_mp;
|
498 |
|
|
if r.mprem(mprem_f_seq) = '1' then -- ??? check re&we !!!
|
499 |
|
|
n.mprem := mprem_mapseq & mprem_s_sta;
|
500 |
|
|
end if;
|
501 |
|
|
when mprem_s_sta => -- sta(ds)
|
502 |
|
|
imem_addr := imem_sta(imf_typ) & r.csds;
|
503 |
|
|
if r.mprem(mprem_f_seq) = '1' then -- ??? check re&we !!!
|
504 |
|
|
n.mprem := mprem_mapseq & mprem_s_pos;
|
505 |
|
|
end if;
|
506 |
|
|
when mprem_s_pos => -- pos(ds)
|
507 |
|
|
imem_addr := imem_pos(imf_typ) & r.csds;
|
508 |
|
|
when others => -- bad state
|
509 |
|
|
imem_addr := imem_bad;
|
510 |
|
|
|
511 |
|
|
end case;
|
512 |
|
|
end if;
|
513 |
|
|
end if;
|
514 |
|
|
|
515 |
|
|
when others => null;
|
516 |
|
|
|
517 |
|
|
end case;
|
518 |
|
|
|
519 |
|
|
end if;
|
520 |
|
|
|
521 |
|
|
when s_csread => -- csread: handle cs read -----------
|
522 |
|
|
idout(rlcs_ibf_err) := r.cserr;
|
523 |
|
|
idout(rlcs_ibf_de) := r.csde;
|
524 |
|
|
idout(rlcs_ibf_e) := r.cse;
|
525 |
|
|
idout(rlcs_ibf_ds) := r.csds;
|
526 |
|
|
idout(rlcs_ibf_crdy) := r.cscrdy;
|
527 |
|
|
idout(rlcs_ibf_ie) := r.csie;
|
528 |
|
|
idout(rlcs_ibf_bae) := r.csbae;
|
529 |
|
|
idout(rlcs_ibf_func) := r.csfunc;
|
530 |
|
|
idout(rlcs_ibf_drdy) := r.csdrdy;
|
531 |
|
|
n.state := s_idle;
|
532 |
|
|
|
533 |
|
|
when s_gs_rpos => -- gs_rpos: read pos(ds) -----------
|
534 |
|
|
imem_addr := imem_pos(imf_typ) & r.csds; -- get pos(ds)
|
535 |
|
|
n.gshs := MEM_DOUT(pos_ibf_hs); -- get hs bit
|
536 |
|
|
ibhold := r.ibsel;
|
537 |
|
|
n.state := s_gs_sta;
|
538 |
|
|
|
539 |
|
|
when s_gs_sta => -- gs_sta: handle status -----------
|
540 |
|
|
imem_addr := imem_sta(imf_typ) & r.csds; -- get sta(ds)
|
541 |
|
|
imem_we0 := '1'; -- always update
|
542 |
|
|
imem_we1 := '1';
|
543 |
|
|
imem_din := MEM_DOUT;
|
544 |
|
|
imem_din(sta_ibf_hs) := r.gshs;
|
545 |
|
|
if r.da(rlda_ibf_gs_rst) = '1' then -- if RST set
|
546 |
|
|
imem_din(sta_ibf_wde) := '0'; -- clear error bits
|
547 |
|
|
imem_din(sta_ibf_che) := '0';
|
548 |
|
|
imem_din(sta_ibf_sto) := '0';
|
549 |
|
|
imem_din(sta_ibf_spe) := '0';
|
550 |
|
|
imem_din(sta_ibf_wge) := '0';
|
551 |
|
|
imem_din(sta_ibf_vce) := '0';
|
552 |
|
|
imem_din(sta_ibf_dse) := '0';
|
553 |
|
|
end if;
|
554 |
|
|
n.mploc := mploc_sta; -- use sta(ds) as mp
|
555 |
|
|
n.ireq := r.csie; -- interrupt
|
556 |
|
|
n.state := s_idle;
|
557 |
|
|
|
558 |
|
|
when s_seek_rsta => -- seek_rsta: read sta(ds) -----------
|
559 |
|
|
imem_addr := imem_sta(imf_typ) & r.csds; -- get sta(ds)
|
560 |
|
|
n.seekdt := MEM_DOUT(sta_ibf_dt);
|
561 |
|
|
imem_din := MEM_DOUT;
|
562 |
|
|
if MEM_DOUT(sta_ibf_st) /= st_lock then -- drive off
|
563 |
|
|
imem_we0 := '1'; -- update sta
|
564 |
|
|
imem_we1 := '1';
|
565 |
|
|
imem_din(sta_ibf_sto) := '1'; -- set STO (seek time out)
|
566 |
|
|
n.cse := e_incomp;
|
567 |
|
|
n.ireq := r.csie; -- interrupt
|
568 |
|
|
n.state := s_idle;
|
569 |
|
|
else -- drive on
|
570 |
|
|
ibhold := r.ibsel;
|
571 |
|
|
n.state := s_seek_rpos;
|
572 |
|
|
end if;
|
573 |
|
|
|
574 |
|
|
when s_seek_rpos => -- seek_rpos: read pos(ds) -----------
|
575 |
|
|
imem_addr := imem_pos(imf_typ) & r.csds; -- get pos(ds)
|
576 |
|
|
if r.da(rlda_ibf_seek_dir) = '1' then
|
577 |
|
|
n.seekcan := slv(unsigned('0' & MEM_DOUT(pos_ibf_ca)) +
|
578 |
|
|
unsigned('0' & r.da(rlda_ibf_seek_df)) );
|
579 |
|
|
else
|
580 |
|
|
n.seekcan := slv(unsigned('0' & MEM_DOUT(pos_ibf_ca)) -
|
581 |
|
|
unsigned('0' & r.da(rlda_ibf_seek_df)) );
|
582 |
|
|
end if;
|
583 |
|
|
ibhold := r.ibsel;
|
584 |
|
|
n.state := s_seek_clip;
|
585 |
|
|
|
586 |
|
|
when s_seek_clip => -- seek_clip: clip new ca ------------
|
587 |
|
|
n.seekcac := r.seekcan(8 downto 0);
|
588 |
|
|
-- new ca overflowed ? for RL02 (9) and for RL01 (9:8) must be "00"
|
589 |
|
|
if r.seekcan(9) = '1' or
|
590 |
|
|
(r.seekdt = '0' and r.seekcan(8) = '1') then
|
591 |
|
|
if r.da(rlda_ibf_seek_dir) = '1' then -- outward seek
|
592 |
|
|
if r.seekdt = '1' then -- is RL02
|
593 |
|
|
n.seekcac := ca_max_rl02; -- clip to RL02 max ca
|
594 |
|
|
else -- is RL01
|
595 |
|
|
n.seekcac := ca_max_rl01; -- clip to RL01 max ca
|
596 |
|
|
end if;
|
597 |
|
|
else -- inward seek
|
598 |
|
|
n.seekcac := "000000000"; -- clip to 0
|
599 |
|
|
end if;
|
600 |
|
|
end if;
|
601 |
|
|
ibhold := r.ibsel;
|
602 |
|
|
n.state := s_seek_wpos;
|
603 |
|
|
|
604 |
|
|
when s_seek_wpos => -- seek_wpos: write pos(ds) ----------
|
605 |
|
|
imem_addr := imem_pos(imf_typ) & r.csds; -- get pos(ds)
|
606 |
|
|
imem_we0 := '1';
|
607 |
|
|
imem_we1 := '1';
|
608 |
|
|
imem_din := MEM_DOUT;
|
609 |
|
|
imem_din(pos_ibf_ca) := r.seekcac;
|
610 |
|
|
imem_din(pos_ibf_hs) := r.da(rlda_ibf_seek_hs);
|
611 |
|
|
n.ireq := r.csie; -- interrupt
|
612 |
|
|
n.state := s_idle;
|
613 |
|
|
|
614 |
|
|
when s_init => -- init: handle init -----------------
|
615 |
|
|
ibhold := r.ibsel; -- hold ibus when controller busy
|
616 |
|
|
imem_addr := r.iaddr;
|
617 |
|
|
imem_din := (others=>'0');
|
618 |
|
|
imem_we0 := '1';
|
619 |
|
|
imem_we1 := '1';
|
620 |
|
|
if r.iaddr(imf_typ) = imem_sta(imf_typ) then -- if sta(x)
|
621 |
|
|
imem_din := MEM_DOUT; -- keep state
|
622 |
|
|
imem_din(sta_ibf_wde) := '0'; -- and clear err
|
623 |
|
|
imem_din(sta_ibf_che) := '0';
|
624 |
|
|
imem_din(sta_ibf_sto) := '0';
|
625 |
|
|
imem_din(sta_ibf_spe) := '0';
|
626 |
|
|
imem_din(sta_ibf_wge) := '0';
|
627 |
|
|
imem_din(sta_ibf_vce) := '0';
|
628 |
|
|
imem_din(sta_ibf_dse) := '0';
|
629 |
|
|
end if;
|
630 |
|
|
n.iaddr := slv(unsigned(r.iaddr) + 1);
|
631 |
|
|
if unsigned(r.iaddr) = unsigned(imem_sta)+3 then -- stop after sta(3)
|
632 |
|
|
n.state := s_idle;
|
633 |
|
|
end if;
|
634 |
|
|
|
635 |
|
|
when others => null;
|
636 |
|
|
end case;
|
637 |
|
|
|
638 |
|
|
iei_req := r.ireq; -- ??? simplify, use r.ireq directly
|
639 |
|
|
|
640 |
|
|
if EI_ACK = '1' or r.csie = '0' then -- interrupt executed or ie disabled
|
641 |
|
|
n.ireq := '0'; -- cancel request
|
642 |
|
|
end if;
|
643 |
|
|
|
644 |
|
|
N_REGS <= n;
|
645 |
|
|
|
646 |
|
|
MEM_0_WE <= imem_we0;
|
647 |
|
|
MEM_1_WE <= imem_we1;
|
648 |
|
|
MEM_ADDR <= imem_addr;
|
649 |
|
|
MEM_DIN <= imem_din;
|
650 |
|
|
|
651 |
|
|
IB_SRES.dout <= idout;
|
652 |
|
|
IB_SRES.ack <= r.ibsel and ibreq;
|
653 |
|
|
IB_SRES.busy <= ibhold and ibreq;
|
654 |
|
|
|
655 |
|
|
RB_LAM <= ilam;
|
656 |
|
|
EI_REQ <= iei_req;
|
657 |
|
|
|
658 |
|
|
end process proc_next;
|
659 |
|
|
|
660 |
|
|
|
661 |
|
|
end syn;
|