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

Subversion Repositories w11

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

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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