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

Subversion Repositories w11

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

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

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

powered by: WebSVN 2.1.0

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