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

Subversion Repositories w11

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

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

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

powered by: WebSVN 2.1.0

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