w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
ibdr_tm11.vhd
Go to the documentation of this file.
1-- $Id: ibdr_tm11.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2015- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: ibdr_tm11 - syn
7-- Description: ibus dev(rem): TM11
8--
9-- Dependencies: -
10-- Test bench: -
11-- Target Devices: generic
12-- Tool versions: ise 14.7; viv 2014.4; ghdl 0.31
13--
14-- Synthesized (xst):
15-- Date Rev ise Target flop lutl lutm slic t peri
16-- 2015-06-04 686 14.7 131013 xc6slx16-2 79 144 0 53 s 4.4
17-- 2015-05-15 682 14.7 131013 xc6slx16-2 117 209 0 76 s 3.7
18--
19-- Revision History:
20-- Date Rev Version Comment
21-- 2015-06-27 695 1.0.1 add missing BESET to sensitivity list
22-- 2015-06-04 686 1.0 Initial version
23-- 2015-05-15 682 0.1 First draft
24------------------------------------------------------------------------------
25
26library ieee;
27use ieee.std_logic_1164.all;
28use ieee.numeric_std.all;
29
30use work.slvtypes.all;
31use work.iblib.all;
32
33-- ----------------------------------------------------------------------------
34entity ibdr_tm11 is -- ibus dev(rem): TM11
35 -- fixed address: 172520
36 port (
37 CLK : in slbit; -- clock
38 BRESET : in slbit; -- ibus reset
39 RB_LAM : out slbit; -- remote attention
40 IB_MREQ : in ib_mreq_type; -- ibus request
41 IB_SRES : out ib_sres_type; -- ibus response
42 EI_REQ : out slbit; -- interrupt request
43 EI_ACK : in slbit -- interrupt acknowledge
44 );
45end ibdr_tm11;
46
47architecture syn of ibdr_tm11 is
48
49 constant ibaddr_tm11 : slv16 := slv(to_unsigned(8#172520#,16));
50
51 constant ibaddr_sr : slv3 := "000"; -- sr address offset
52 constant ibaddr_cr : slv3 := "001"; -- cr address offset
53 constant ibaddr_bc : slv3 := "010"; -- bc address offset
54 constant ibaddr_ba : slv3 := "011"; -- ba address offset
55 constant ibaddr_db : slv3 := "100"; -- db address offset
56 constant ibaddr_rl : slv3 := "101"; -- rl address offset
57
58 constant sr_ibf_icmd : integer := 15;
59 constant sr_ibf_eof : integer := 14;
60 constant sr_ibf_pae : integer := 12;
61 constant sr_ibf_eot : integer := 10;
62 constant sr_ibf_rle : integer := 9;
63 constant sr_ibf_bte : integer := 8;
64 constant sr_ibf_nxm : integer := 7;
65 constant sr_ibf_onl : integer := 6;
66 constant sr_ibf_bot : integer := 5;
67 constant sr_ibf_wrl : integer := 2;
68 constant sr_ibf_rew : integer := 1;
69 constant sr_ibf_tur : integer := 0;
70
71 constant cr_ibf_err : integer := 15;
72 subtype cr_ibf_den is integer range 14 downto 13;
73 constant cr_ibf_ini : integer := 12;
74 constant cr_ibf_pevn : integer := 11;
75 constant cr_ibf_unit2 : integer := 10;
76 subtype cr_ibf_unit is integer range 9 downto 8;
77 constant cr_ibf_rdy : integer := 7;
78 constant cr_ibf_ie : integer := 6;
79 subtype cr_ibf_ea is integer range 5 downto 4;
80 subtype cr_ibf_func is integer range 3 downto 1;
81 constant cr_ibf_go : integer := 0;
82
83 subtype ba_ibf_ba is integer range 15 downto 1;
84 subtype db_ibf_db is integer range 7 downto 0;
85
86 constant rl_ibf_reof : integer := 10;
87 constant rl_ibf_reot : integer := 9;
88 constant rl_ibf_ronl : integer := 8;
89 constant rl_ibf_rbot : integer := 7;
90 constant rl_ibf_rwrl : integer := 6;
91 constant rl_ibf_rrew : integer := 5;
92 subtype rl_ibf_runit is integer range 2 downto 1;
93
94 constant func_unload : slv3 := "000"; -- func: unload
95 constant func_read : slv3 := "001"; -- func: read
96 constant func_write : slv3 := "010"; -- func: write
97 constant func_weof : slv3 := "011"; -- func: write eof
98 constant func_sforw : slv3 := "100"; -- func: space forward
99 constant func_sback : slv3 := "101"; -- func: space backward
100 constant func_wrteg : slv3 := "110"; -- func: write extend interrec gap
101 constant func_rewind : slv3 := "111"; -- func: rewind
102
103 constant rfunc_wunit : slv3 := "001"; -- rem func: write runit
104 constant rfunc_done : slv3 := "010"; -- rem func: done (set rdy)
105
106 -- cs1 usage for rem functions
107 subtype cr_ibf_runit is integer range 5 downto 4; -- new runit (_wunit)
108 constant cr_ibf_ricmd : integer := 15; -- new icmd (_done)
109 constant cr_ibf_rpae : integer := 12; -- new pae (_done)
110 constant cr_ibf_rrle : integer := 9; -- new rle (_done)
111 constant cr_ibf_rbte : integer := 8; -- new bte (_done)
112 constant cr_ibf_rnxm : integer := 7; -- new nxm (_done)
113 constant cr_ibf_reaena : integer := 6; -- ena ea (_done)
114 subtype cr_ibf_rea is integer range 5 downto 4; -- new ea (_done)
115
116 type regs_type is record -- state registers
117 ibsel : slbit; -- ibus select
118 sricmd : slbit; -- sr: invalid command
119 srpae: slbit; -- sr: parity error
120 srrle: slbit; -- sr: record length error
121 srbte: slbit; -- sr: bad tape error
122 srnxm: slbit; -- sr: non-existent memory
123 sreof: slv4; -- sr: eof-of-file
124 sreot: slv4; -- sr: eof-of-tape
125 sronl: slv4; -- sr: online
126 srbot: slv4; -- sr: begin-of-tape
127 srwrl: slv4; -- sr: write-locked
128 srrew: slv4; -- sr: rewinding
129 crden: slv2; -- cr: density
130 crpevn: slbit; -- cr: even oarity
131 crunit2: slbit; -- cr: unit[2]
132 crunit: slv2; -- cr: unit[1:0]
133 crrdy: slbit; -- cr: controller ready
134 crie: slbit; -- cr: interrupt enable
135 crea: slv2; -- cr: address extension
136 crfunc: slv3; -- cr: func code
137 bc : slv16; -- bc: byte count
138 ba : slv16_1; -- ba: bus address
139 runit : slv2; -- rem access unit
140 resreq : slbit; -- reset requested
141 ireq : slbit; -- interrupt request flag
142 end record regs_type;
143
144 constant regs_init : regs_type := (
145 '0', -- ibsel
146 '0','0','0','0','0', -- sricmd,srpae,srrle,srbte,srnxm
147 (others=>'0'), -- sreof
148 (others=>'0'), -- sreot
149 (others=>'0'), -- sronl
150 (others=>'0'), -- srbot
151 (others=>'0'), -- srwrl
152 (others=>'0'), -- srrew
153 (others=>'0'), -- crden
154 '0','0', -- crpevn,crunit2
155 (others=>'0'), -- crunit
156 '1','0', -- crrdy, crie
157 (others=>'0'), -- crea
158 (others=>'0'), -- crfunc
159 (others=>'0'), -- bc
160 (others=>'0'), -- ba
161 (others=>'0'), -- runit
162 '0', -- resreq
163 '0' -- ireq
164 );
165
168
169begin
170
171 proc_regs: process (CLK)
172 begin
173 if rising_edge(CLK) then
174 R_REGS <= N_REGS;
175 end if;
176 end process proc_regs;
177
178 proc_next : process (R_REGS, IB_MREQ, EI_ACK, BRESET)
179 variable r : regs_type := regs_init;
180 variable n : regs_type := regs_init;
181 variable ibhold : slbit := '0';
182 variable idout : slv16 := (others=>'0');
183 variable ibrem : slbit := '0';
184 variable ibreq : slbit := '0';
185 variable ibrd : slbit := '0';
186 variable ibw0 : slbit := '0';
187 variable ibw1 : slbit := '0';
188 variable ibwrem : slbit := '0';
189 variable ilam : slbit := '0';
190
191 begin
192
193 r := R_REGS;
194 n := R_REGS;
195
196 ibhold := '0';
197 idout := (others=>'0');
198 ibrem := IB_MREQ.racc;
199 ibreq := IB_MREQ.re or IB_MREQ.we;
200 ibrd := IB_MREQ.re;
201 ibw0 := IB_MREQ.we and IB_MREQ.be0;
202 ibw1 := IB_MREQ.we and IB_MREQ.be1;
203 ibwrem := IB_MREQ.we and ibrem;
204 ilam := '0';
205
206 -- ibus address decoder
207 n.ibsel := '0';
208 if IB_MREQ.aval = '1' and
209 IB_MREQ.addr(12 downto 4)=ibaddr_tm11(12 downto 4) and
210 unsigned(IB_MREQ.addr(3 downto 1)) <= unsigned(ibaddr_rl) then
211 n.ibsel := '1';
212 end if;
213
214 -- ibus transactions
215
216 if r.ibsel='1' then -- selected
217
218 case IB_MREQ.addr(3 downto 1) is
219
220 when ibaddr_sr => -- SR -- status register ----------
221 idout(sr_ibf_icmd) := r.sricmd;
222 idout(sr_ibf_pae) := r.srpae;
223 idout(sr_ibf_rle) := r.srrle;
224 idout(sr_ibf_bte) := r.srbte;
225 idout(sr_ibf_nxm) := r.srnxm;
226 idout(sr_ibf_tur) := r.crrdy; -- FIXME: is this correct ??
227 -- only units 0,..3 supported, for unit 4,..,7 return 0 --> ONL=0
228 if r.crunit2 = '0' then
229 idout(sr_ibf_eof) := r.sreof(to_integer(unsigned(r.crunit)));
230 idout(sr_ibf_eot) := r.sreot(to_integer(unsigned(r.crunit)));
231 idout(sr_ibf_onl) := r.sronl(to_integer(unsigned(r.crunit)));
232 idout(sr_ibf_bot) := r.srbot(to_integer(unsigned(r.crunit)));
233 idout(sr_ibf_wrl) := r.srwrl(to_integer(unsigned(r.crunit)));
234 idout(sr_ibf_rew) := r.srrew(to_integer(unsigned(r.crunit)));
235 end if;
236
237 when ibaddr_cr => -- CR -- control register ---------
238 idout(cr_ibf_err) := r.sricmd or
239 r.sreof(to_integer(unsigned(r.crunit))) or
240 r.srpae or
241 r.sreot(to_integer(unsigned(r.crunit))) or
242 r.srrle or
243 r.srnxm;
244 idout(cr_ibf_den) := r.crden;
245 idout(cr_ibf_pevn) := r.crpevn;
246 idout(cr_ibf_unit2) := r.crunit2;
247 idout(cr_ibf_unit) := r.crunit;
248 idout(cr_ibf_rdy) := r.crrdy;
249 idout(cr_ibf_ie) := r.crie;
250 idout(cr_ibf_ea) := r.crea;
251 idout(cr_ibf_func) := r.crfunc;
252
253 if IB_MREQ.we = '1' then
254 if ibrem = '0' then
255
256 if r.crrdy = '1' then
257 if IB_MREQ.be1 = '1' then
258 n.crden := IB_MREQ.din(cr_ibf_den);
259 if IB_MREQ.din(cr_ibf_ini) = '1' then
260 n.resreq := '1';
261 end if;
262 n.crpevn := IB_MREQ.din(cr_ibf_pevn);
263 n.crunit2 := IB_MREQ.din(cr_ibf_unit2);
264 n.crunit := IB_MREQ.din(cr_ibf_unit);
265 end if;
266 if IB_MREQ.be0 = '1' then
267 n.crie := IB_MREQ.din(cr_ibf_ie);
268 if n.crie = '0' then -- if IE set to 0
269 n.ireq := '0'; -- cancel pending interrupt
270 end if;
271 n.crea := IB_MREQ.din(cr_ibf_ea);
272 n.crfunc := IB_MREQ.din(cr_ibf_func);
273
274 if IB_MREQ.din(cr_ibf_go) = '1' then
275 n.sricmd := '0'; -- clear errors
276 n.srpae := '0';
277 n.srrle := '0';
278 n.srbte := '0';
279 n.srnxm := '0';
280 n.sreof := (others=>'0'); -- clear position status flags
281 n.sreot := (others=>'0');
282 n.srbot := (others=>'0');
283 n.srrew := (others=>'0');
284 n.crrdy := '0'; -- mark busy
285 ilam := '1'; -- rri lam
286 else
287 if r.crie='0' and n.crie='1' then -- if IDE 0->1 transition
288 n.ireq := '1'; -- issue software interrupt
289 end if;
290 end if;
291 end if;
292 else
293 n.sricmd := '1';
294 end if;
295
296 else -- rem write access. GO not checked
297 -- always treated as remote function
298 case IB_MREQ.din(cr_ibf_func) is
299 when rfunc_wunit => -- rfunc: wunit -----------------
300 n.runit := IB_MREQ.din(cr_ibf_runit);
301
302 when rfunc_done => -- rfunc: done ------------------
303 n.sricmd := IB_MREQ.din(cr_ibf_ricmd);
304 n.srpae := IB_MREQ.din(cr_ibf_rpae);
305 n.srrle := IB_MREQ.din(cr_ibf_rrle);
306 n.srbte := IB_MREQ.din(cr_ibf_rbte);
307 n.srnxm := IB_MREQ.din(cr_ibf_rnxm);
308 if IB_MREQ.din(cr_ibf_reaena) = '1' then
309 n.crea := IB_MREQ.din(cr_ibf_rea);
310 end if;
311 n.crrdy := '1';
312 if r.crie = '1' then
313 n.ireq := '1';
314 end if;
315
316 when others => null; -- <>
317 end case;
318
319 end if; -- if ibrem
320
321 end if; -- if IB_MREQ.we='1'
322
323 when ibaddr_bc => -- BC -- byte count register -------
324 idout := r.bc;
325 if ibw1 = '1' then
326 n.bc(15 downto 8) := IB_MREQ.din(15 downto 8);
327 end if;
328 if ibw0 = '1' then
329 n.bc( 7 downto 0) := IB_MREQ.din( 7 downto 0);
330 end if;
331
332 when ibaddr_ba => -- BA -- bus address register ------
333 idout(ba_ibf_ba) := r.ba;
334 if ibw1 = '1' then
335 n.ba(15 downto 8) := IB_MREQ.din(15 downto 8);
336 end if;
337 if ibw0 = '1' then
338 n.ba( 7 downto 1) := IB_MREQ.din( 7 downto 1);
339 end if;
340
341 when ibaddr_db => -- DB -- data buffer ---------------
342 null;
343
344 when ibaddr_rl => -- RL -- read lines ----------------
345 if ibrem = '0' then
346 null;
347 else
348 idout(rl_ibf_reof) := r.sreof(to_integer(unsigned(r.runit)));
349 idout(rl_ibf_reot) := r.sreot(to_integer(unsigned(r.runit)));
350 idout(rl_ibf_ronl) := r.sronl(to_integer(unsigned(r.runit)));
351 idout(rl_ibf_rbot) := r.srbot(to_integer(unsigned(r.runit)));
352 idout(rl_ibf_rwrl) := r.srwrl(to_integer(unsigned(r.runit)));
353 idout(rl_ibf_rrew) := r.srrew(to_integer(unsigned(r.runit)));
354 idout(rl_ibf_runit) := r.runit;
355 if IB_MREQ.we = '1' then
356 n.sreof(to_integer(unsigned(r.runit))) := IB_MREQ.din(rl_ibf_reof);
357 n.sreot(to_integer(unsigned(r.runit))) := IB_MREQ.din(rl_ibf_reot);
358 n.sronl(to_integer(unsigned(r.runit))) := IB_MREQ.din(rl_ibf_ronl);
359 n.srbot(to_integer(unsigned(r.runit))) := IB_MREQ.din(rl_ibf_rbot);
360 n.srwrl(to_integer(unsigned(r.runit))) := IB_MREQ.din(rl_ibf_rwrl);
361 n.srrew(to_integer(unsigned(r.runit))) := IB_MREQ.din(rl_ibf_rrew);
362 end if;
363 end if;
364
365 when others => -- doesn't happen, ibsel only for
366 -- subrange up to rl, and all regs are
367 -- decoded above
368 null;
369
370 end case;
371 end if;
372
373 if BRESET = '1' then
374 n.resreq := '1';
375 end if;
376
377 if r.resreq = '1' then
378 n.sricmd := '0';
379 n.srpae := '0';
380 n.srrle := '0';
381 n.srbte := '0';
382 n.srnxm := '0';
383 n.sreof := (others=>'0');
384 n.sreot := (others=>'0');
385 n.crden := (others=>'0');
386 n.crpevn := '0';
387 n.crunit2 := '0';
388 n.crunit := (others=>'0');
389 n.crrdy := '1';
390 n.crie := '0';
391 n.crea := (others=>'0');
392 n.crfunc := (others=>'0');
393 n.bc := (others=>'0');
394 n.ba := (others=>'0');
395 n.resreq := '0';
396 n.ireq := '0';
397 end if;
398
399 if EI_ACK = '1' or n.crie = '0' then -- interrupt executed or ie disabled
400 n.ireq := '0'; -- cancel request
401 end if;
402
403 N_REGS <= n;
404
405 IB_SRES.dout <= idout;
406 IB_SRES.ack <= r.ibsel and ibreq;
407 IB_SRES.busy <= ibhold and ibreq;
408
409 RB_LAM <= ilam;
410 EI_REQ <= r.ireq;
411
412 end process proc_next;
413
414
415end syn;
slv3 := "010" ibaddr_bc
Definition: ibdr_tm11.vhd:53
integer := 8 rl_ibf_ronl
Definition: ibdr_tm11.vhd:88
integer := 9 rl_ibf_reot
Definition: ibdr_tm11.vhd:87
slv3 := "011" ibaddr_ba
Definition: ibdr_tm11.vhd:54
integer range 7 downto 0 db_ibf_db
Definition: ibdr_tm11.vhd:84
integer := 6 cr_ibf_reaena
Definition: ibdr_tm11.vhd:113
slv3 := "010" rfunc_done
Definition: ibdr_tm11.vhd:104
integer := 0 cr_ibf_go
Definition: ibdr_tm11.vhd:81
integer range 14 downto 13 cr_ibf_den
Definition: ibdr_tm11.vhd:72
integer := 10 sr_ibf_eot
Definition: ibdr_tm11.vhd:61
slv3 := "110" func_wrteg
Definition: ibdr_tm11.vhd:100
integer := 12 sr_ibf_pae
Definition: ibdr_tm11.vhd:60
integer := 8 cr_ibf_rbte
Definition: ibdr_tm11.vhd:111
integer range 15 downto 1 ba_ibf_ba
Definition: ibdr_tm11.vhd:83
regs_type := regs_init N_REGS
Definition: ibdr_tm11.vhd:167
slv3 := "000" func_unload
Definition: ibdr_tm11.vhd:94
integer := 9 cr_ibf_rrle
Definition: ibdr_tm11.vhd:110
integer := 7 sr_ibf_nxm
Definition: ibdr_tm11.vhd:64
slv3 := "111" func_rewind
Definition: ibdr_tm11.vhd:101
integer := 15 cr_ibf_ricmd
Definition: ibdr_tm11.vhd:108
integer := 15 cr_ibf_err
Definition: ibdr_tm11.vhd:71
integer := 11 cr_ibf_pevn
Definition: ibdr_tm11.vhd:74
integer := 12 cr_ibf_rpae
Definition: ibdr_tm11.vhd:109
integer := 10 rl_ibf_reof
Definition: ibdr_tm11.vhd:86
integer := 10 cr_ibf_unit2
Definition: ibdr_tm11.vhd:75
integer := 12 cr_ibf_ini
Definition: ibdr_tm11.vhd:73
integer := 2 sr_ibf_wrl
Definition: ibdr_tm11.vhd:67
integer := 7 rl_ibf_rbot
Definition: ibdr_tm11.vhd:89
integer := 6 sr_ibf_onl
Definition: ibdr_tm11.vhd:65
integer := 7 cr_ibf_rdy
Definition: ibdr_tm11.vhd:77
regs_type := regs_init R_REGS
Definition: ibdr_tm11.vhd:166
integer := 6 cr_ibf_ie
Definition: ibdr_tm11.vhd:78
integer := 5 sr_ibf_bot
Definition: ibdr_tm11.vhd:66
slv3 := "000" ibaddr_sr
Definition: ibdr_tm11.vhd:51
integer range 3 downto 1 cr_ibf_func
Definition: ibdr_tm11.vhd:80
slv3 := "001" ibaddr_cr
Definition: ibdr_tm11.vhd:52
slv16 := slv( to_unsigned( 8#172520#, 16) ) ibaddr_tm11
Definition: ibdr_tm11.vhd:49
slv3 := "100" func_sforw
Definition: ibdr_tm11.vhd:98
integer := 0 sr_ibf_tur
Definition: ibdr_tm11.vhd:69
integer range 2 downto 1 rl_ibf_runit
Definition: ibdr_tm11.vhd:92
slv3 := "001" rfunc_wunit
Definition: ibdr_tm11.vhd:103
integer := 1 sr_ibf_rew
Definition: ibdr_tm11.vhd:68
slv3 := "010" func_write
Definition: ibdr_tm11.vhd:96
slv3 := "101" func_sback
Definition: ibdr_tm11.vhd:99
integer := 5 rl_ibf_rrew
Definition: ibdr_tm11.vhd:91
integer range 9 downto 8 cr_ibf_unit
Definition: ibdr_tm11.vhd:76
integer range 5 downto 4 cr_ibf_runit
Definition: ibdr_tm11.vhd:107
slv3 := "011" func_weof
Definition: ibdr_tm11.vhd:97
integer := 9 sr_ibf_rle
Definition: ibdr_tm11.vhd:62
integer range 5 downto 4 cr_ibf_ea
Definition: ibdr_tm11.vhd:79
integer := 14 sr_ibf_eof
Definition: ibdr_tm11.vhd:59
regs_type :=( '0', '0', '0', '0', '0', '0',( others => '0'),( others => '0'),( others => '0'),( others => '0'),( others => '0'),( others => '0'),( others => '0'), '0', '0',( others => '0'), '1', '0',( others => '0'),( others => '0'),( others => '0'),( others => '0'),( others => '0'), '0', '0') regs_init
Definition: ibdr_tm11.vhd:144
integer range 5 downto 4 cr_ibf_rea
Definition: ibdr_tm11.vhd:114
integer := 6 rl_ibf_rwrl
Definition: ibdr_tm11.vhd:90
slv3 := "001" func_read
Definition: ibdr_tm11.vhd:95
integer := 15 sr_ibf_icmd
Definition: ibdr_tm11.vhd:58
integer := 7 cr_ibf_rnxm
Definition: ibdr_tm11.vhd:112
integer := 8 sr_ibf_bte
Definition: ibdr_tm11.vhd:63
slv3 := "101" ibaddr_rl
Definition: ibdr_tm11.vhd:56
slv3 := "100" ibaddr_db
Definition: ibdr_tm11.vhd:55
out EI_REQ slbit
Definition: ibdr_tm11.vhd:42
in BRESET slbit
Definition: ibdr_tm11.vhd:38
out RB_LAM slbit
Definition: ibdr_tm11.vhd:39
in CLK slbit
Definition: ibdr_tm11.vhd:37
in IB_MREQ ib_mreq_type
Definition: ibdr_tm11.vhd:40
out IB_SRES ib_sres_type
Definition: ibdr_tm11.vhd:41
in EI_ACK slbit
Definition: ibdr_tm11.vhd:44
Definition: iblib.vhd:33
std_logic_vector( 3 downto 0) slv4
Definition: slvtypes.vhd:36
std_logic_vector( 2 downto 0) slv3
Definition: slvtypes.vhd:35
std_logic_vector( 15 downto 1) slv16_1
Definition: slvtypes.vhd:67
std_logic_vector( 15 downto 0) slv16
Definition: slvtypes.vhd:48
std_logic slbit
Definition: slvtypes.vhd:30
std_logic_vector( 1 downto 0) slv2
Definition: slvtypes.vhd:34
std_logic_vector slv
Definition: slvtypes.vhd:31