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

Subversion Repositories w11

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

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

Line No. Rev Author Line
1 9 wfjm
-- $Id: ibdr_lp11.vhd 350 2010-12-28 16:40:11Z mueller $
2 2 wfjm
--
3
-- Copyright 2009-2010 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_lp11 - syn
16
-- Description:    ibus dev(rem): LP11
17
--
18
-- Dependencies:   -
19
-- Test bench:     -
20
-- Target Devices: generic
21 8 wfjm
-- Tool versions:  xst 8.1, 8.2, 9.1, 9.2, 10.1, 12.1; ghdl 0.18-0.29
22 2 wfjm
--
23
-- Synthesized (xst):
24
-- Date         Rev  ise         Target      flop lutl lutm slic t peri
25 9 wfjm
-- 2010-10-17   333 12.1    M53d xc3s1000-4    12   35    0   24 s  5.6
26
-- 2009-07-11   232 10.1.03 K39  xc3s1000-4    11   30    0   19 s  5.8
27 2 wfjm
--
28
-- Revision History: 
29
-- Date         Rev Version  Comment
30 8 wfjm
-- 2010-10-23   335   1.2.1  rename RRI_LAM->RB_LAM;
31
-- 2010-10-17   333   1.2    use ibus V2 interface
32 2 wfjm
-- 2010-06-11   303   1.1    use IB_MREQ.racc instead of RRI_REQ
33
-- 2009-06-21   228   1.0.1  generate interrupt locally when err=1
34
-- 2009-05-30   220   1.0    Initial version 
35
------------------------------------------------------------------------------
36
--
37
-- Notes:
38
--   - the ERR bit is just a status flag
39
--   - no hardware interlock (DONE forced 0 when ERR=1), like in simh
40
--   - also no interrupt when ERR goes 1, like in simh
41
 
42
 
43
library ieee;
44
use ieee.std_logic_1164.all;
45
use ieee.std_logic_arith.all;
46
 
47
use work.slvtypes.all;
48
use work.iblib.all;
49
 
50
-- ----------------------------------------------------------------------------
51
entity ibdr_lp11 is                     -- ibus dev(rem): LP11
52
                                        -- fixed address: 177514
53
  port (
54
    CLK : in slbit;                     -- clock
55
    RESET : in slbit;                   -- system reset
56
    BRESET : in slbit;                  -- ibus reset
57 8 wfjm
    RB_LAM : out slbit;                 -- remote attention
58 2 wfjm
    IB_MREQ : in ib_mreq_type;          -- ibus request
59
    IB_SRES : out ib_sres_type;         -- ibus response
60
    EI_REQ : out slbit;                 -- interrupt request
61
    EI_ACK : in slbit                   -- interrupt acknowledge
62
  );
63
end ibdr_lp11;
64
 
65
architecture syn of ibdr_lp11 is
66
 
67
  constant ibaddr_lp11 : slv16 := conv_std_logic_vector(8#177514#,16);
68
 
69
  constant ibaddr_csr : slv1 := "0";   -- csr address offset
70
  constant ibaddr_buf : slv1 := "1";   -- buf address offset
71
 
72
  constant csr_ibf_err :   integer := 15;
73
  constant csr_ibf_done :  integer :=  7;
74
  constant csr_ibf_ie :    integer :=  6;
75
  constant buf_ibf_val :   integer :=  8;
76
 
77
  type regs_type is record              -- state registers
78 8 wfjm
    ibsel : slbit;                      -- ibus select
79 2 wfjm
    err : slbit;                        -- csr: error flag
80
    done : slbit;                       -- csr: done flag
81
    ie : slbit;                         -- csr: interrupt enable
82
    buf : slv7;                         -- buf:
83
    intreq : slbit;                     -- interrupt request
84
  end record regs_type;
85
 
86
  constant regs_init : regs_type := (
87 8 wfjm
    '0',                                -- ibsel
88 2 wfjm
    '1',                                -- err  !! is set !!
89
    '1',                                -- done !! is set !!
90
    '0',                                -- ie
91
    (others=>'0'),                      -- buf
92
    '0'                                 -- intreq
93
  );
94
 
95
  signal R_REGS : regs_type := regs_init;
96
  signal N_REGS : regs_type := regs_init;
97
 
98
begin
99
 
100
  proc_regs: process (CLK)
101
  begin
102
    if CLK'event and CLK='1' then
103
      if BRESET = '1' then              -- BRESET is 1 for system and ibus reset
104
        R_REGS <= regs_init;
105
        if RESET = '0' then               -- if RESET=0 we do just an ibus reset
106
          R_REGS.err <= N_REGS.err;         -- don't reset ERR flag
107
        end if;
108 8 wfjm
      else
109 2 wfjm
        R_REGS <= N_REGS;
110
      end if;
111
    end if;
112
  end process proc_regs;
113
 
114
  proc_next : process (R_REGS, IB_MREQ, EI_ACK)
115
    variable r : regs_type := regs_init;
116
    variable n : regs_type := regs_init;
117
    variable idout : slv16 := (others=>'0');
118 8 wfjm
    variable ibreq : slbit := '0';
119 2 wfjm
    variable ibrd : slbit := '0';
120
    variable ibw0 : slbit := '0';
121
    variable ilam : slbit := '0';
122
  begin
123
 
124
    r := R_REGS;
125
    n := R_REGS;
126
 
127
    idout := (others=>'0');
128 8 wfjm
    ibreq := IB_MREQ.re or IB_MREQ.we;
129
    ibrd  := IB_MREQ.re;
130 2 wfjm
    ibw0  := IB_MREQ.we and IB_MREQ.be0;
131
    ilam  := '0';
132
 
133
    -- ibus address decoder
134 8 wfjm
    n.ibsel := '0';
135
    if IB_MREQ.aval='1' and
136 2 wfjm
       IB_MREQ.addr(12 downto 2)=ibaddr_lp11(12 downto 2) then
137 8 wfjm
      n.ibsel := '1';
138 2 wfjm
    end if;
139
 
140
    -- ibus transactions
141 8 wfjm
    if r.ibsel = '1' then
142 2 wfjm
      case IB_MREQ.addr(1 downto 1) is
143
 
144
        when ibaddr_csr =>              -- CSR -- control status -------------
145
          idout(csr_ibf_err)  := r.err;
146
          idout(csr_ibf_done) := r.done;
147
          idout(csr_ibf_ie)   := r.ie;
148
          if IB_MREQ.racc = '0' then      -- cpu
149
            if ibw0 = '1' then
150
              n.ie   := IB_MREQ.din(csr_ibf_ie);
151
              if IB_MREQ.din(csr_ibf_ie) = '1' then
152
                if r.done='1' and r.ie='0' then   -- ie set while done=1
153
                  n.intreq := '1';                -- request interrupt
154
                end if;
155
              else
156
                n.intreq := '0';
157
              end if;
158
            end if;
159
          else                          -- rri
160
            n.err := IB_MREQ.din(csr_ibf_err);
161
          end if;
162
 
163
        when ibaddr_buf =>              -- BUF -- data buffer ----------------
164
          if IB_MREQ.racc = '0' then      -- cpu
165
            if ibw0 = '1' then
166
              n.buf    := IB_MREQ.din(n.buf'range);
167
              if r.err = '0' then         -- if online (handle via rbus)
168
                ilam     := '1';            -- request attention
169
                n.done   := '0';            -- clear done
170
                n.intreq := '0';            -- clear interrupt
171
              else                        -- if offline (discard locally)
172
                n.done   := '1';            -- set done
173
                if r.ie = '1' then          -- if interrupts enabled
174
                  n.intreq := '1';            -- request interrupt
175
                end if;
176
              end if;
177
            end if;
178
          else                          -- rri
179
            idout(r.buf'range)  := r.buf;
180
            idout(buf_ibf_val)  := not r.done;
181
            if ibrd = '1' then
182
              n.done := '1';
183
              if r.ie = '1' then
184
                n.intreq := '1';
185
              end if;
186
            end if;
187
          end if;
188
 
189
        when others => null;
190
      end case;
191
 
192
    end if;
193
 
194
    -- other state changes
195
    if EI_ACK = '1' then
196
      n.intreq := '0';
197
    end if;
198
 
199
    N_REGS <= n;
200
 
201
    IB_SRES.dout <= idout;
202 8 wfjm
    IB_SRES.ack  <= r.ibsel and ibreq;
203 2 wfjm
    IB_SRES.busy <= '0';
204
 
205 8 wfjm
    RB_LAM <= ilam;
206
    EI_REQ <= r.intreq;
207 2 wfjm
 
208
  end process proc_next;
209
 
210
 
211
end syn;

powered by: WebSVN 2.1.0

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