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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.74/] [rtl/] [ibus/] [ibdr_tm11.vhd] - Blame information for rev 38

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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