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

Subversion Repositories w11

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 wfjm
-- $Id: ibd_kw11l.vhd 427 2011-11-19 21:04:11Z mueller $
2 2 wfjm
--
3 13 wfjm
-- Copyright 2008-2011 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:    ibd_kw11l - syn
16
-- Description:    ibus dev(loc): KW11-L (line clock)
17
--
18
-- Dependencies:   -
19
-- Test bench:     -
20
-- Target Devices: generic
21 13 wfjm
-- Tool versions:  xst 8.2, 9.1, 9.2, 10.1, 12.1, 13.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     9   23    0   14 s  5.3
26
-- 2009-07-11   232 10.1.03 K39  xc3s1000-4     8   25    0   15 s  5.3
27 2 wfjm
--
28
-- Revision History: 
29
-- Date         Rev Version  Comment
30 13 wfjm
-- 2011-11-18   427   1.1.1  now numeric_std clean
31 8 wfjm
-- 2010-10-17   333   1.1    use ibus V2 interface
32 2 wfjm
-- 2009-06-01   221   1.0.5  BUGFIX: add RESET; don't clear tcnt on ibus reset
33
-- 2008-08-22   161   1.0.4  use iblib; add EI_ACK to proc_next sens. list
34
-- 2008-05-09   144   1.0.3  use intreq flop, use EI_ACK
35
-- 2008-01-20   112   1.0.2  fix proc_next sensitivity list; use BRESET
36
-- 2008-01-06   111   1.0.1  Renamed to ibd_kw11l (RRI_REQ not used)
37
-- 2008-01-05   110   1.0    Initial version 
38
------------------------------------------------------------------------------
39
 
40
library ieee;
41
use ieee.std_logic_1164.all;
42 13 wfjm
use ieee.numeric_std.all;
43 2 wfjm
 
44
use work.slvtypes.all;
45
use work.iblib.all;
46
 
47
-- ----------------------------------------------------------------------------
48
entity ibd_kw11l is                     -- ibus dev(loc): KW11-L (line clock)
49
                                        -- fixed address: 177546
50
  port (
51
    CLK : in slbit;                     -- clock
52
    CE_MSEC : in slbit;                 -- msec pulse
53
    RESET : in slbit;                   -- system reset
54
    BRESET : in slbit;                  -- ibus reset
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 ibd_kw11l;
61
 
62
architecture syn of ibd_kw11l is
63
 
64 13 wfjm
  constant ibaddr_kw11l : slv16 := slv(to_unsigned(8#177546#,16));
65 2 wfjm
 
66
  constant lks_ibf_ie :   integer :=  6;
67
  constant lks_ibf_moni : integer :=  7;
68
 
69
  constant twidth : natural  :=  5;
70
  constant tdivide : natural := 20;
71
 
72
  type regs_type is record              -- state registers
73 8 wfjm
    ibsel : slbit;                      -- ibus select    
74 2 wfjm
    ie : slbit;                         -- interrupt enable
75
    moni : slbit;                       -- monitor bit
76
    intreq : slbit;                     -- interrupt request
77
    tcnt : slv(twidth-1 downto 0);      -- timer counter
78
  end record regs_type;
79
 
80
  constant regs_init : regs_type := (
81 8 wfjm
    '0',                                -- ibsel
82 2 wfjm
    '0',                                -- ie
83
    '1',                                -- moni (set on reset !!)
84
    '0',                                -- intreq
85
    (others=>'0')                       -- tcnt
86
  );
87
 
88
  signal R_REGS : regs_type := regs_init;
89
  signal N_REGS : regs_type := regs_init;
90
 
91
begin
92
 
93
  proc_regs: process (CLK)
94
  begin
95 13 wfjm
    if rising_edge(CLK) then
96 2 wfjm
      if BRESET = '1' then             -- BRESET is 1 for system and ibus reset
97
        R_REGS <= regs_init;
98
        if RESET = '0' then               -- if RESET=0 we do just an ibus reset
99
          R_REGS.tcnt <= N_REGS.tcnt;       -- don't clear msec tick counter
100
        end if;
101 8 wfjm
      else
102 2 wfjm
        R_REGS <= N_REGS;
103
      end if;
104
    end if;
105
  end process proc_regs;
106
 
107
  proc_next : process (R_REGS, IB_MREQ, CE_MSEC, EI_ACK)
108
    variable r : regs_type := regs_init;
109
    variable n : regs_type := regs_init;
110
    variable idout : slv16 := (others=>'0');
111 8 wfjm
    variable ibreq : slbit := '0';
112
    variable ibw0 : slbit := '0';
113 2 wfjm
  begin
114
 
115
    r := R_REGS;
116
    n := R_REGS;
117
 
118
    idout := (others=>'0');
119 8 wfjm
    ibreq := IB_MREQ.re or IB_MREQ.we;
120
    ibw0  := IB_MREQ.we and IB_MREQ.be0;
121 2 wfjm
 
122
    -- ibus address decoder
123 8 wfjm
    n.ibsel := '0';
124
    if IB_MREQ.aval='1' and
125
       IB_MREQ.addr=ibaddr_kw11l(12 downto 1) then
126
      n.ibsel := '1';
127 2 wfjm
    end if;
128
 
129
    -- ibus output driver
130 8 wfjm
    if r.ibsel = '1' then
131 2 wfjm
      idout(lks_ibf_ie)   := R_REGS.ie;
132
      idout(lks_ibf_moni) := R_REGS.moni;
133
    end if;
134
 
135
    -- ibus write transactions
136 8 wfjm
    if r.ibsel='1' and ibw0='1' then
137 2 wfjm
      n.ie   := IB_MREQ.din(lks_ibf_ie);
138
      n.moni := IB_MREQ.din(lks_ibf_moni);
139
      if IB_MREQ.din(lks_ibf_ie)='0' or IB_MREQ.din(lks_ibf_moni)='0' then
140
        n.intreq := '0';
141
      end if;
142
    end if;
143
 
144
    -- other state changes
145
    if CE_MSEC = '1' then
146 13 wfjm
      n.tcnt := slv(unsigned(r.tcnt) + 1);
147 2 wfjm
      if unsigned(r.tcnt) = tdivide-1 then
148
        n.tcnt := (others=>'0');
149
        n.moni := '1';
150
        if r.ie = '1' then
151
          n.intreq := '1';
152
        end if;
153
      end if;
154
    end if;
155
 
156
    if EI_ACK = '1' then
157
      n.intreq := '0';
158
    end if;
159
 
160
    N_REGS <= n;
161
 
162
    IB_SRES.dout <= idout;
163 8 wfjm
    IB_SRES.ack  <= r.ibsel and ibreq;
164 2 wfjm
    IB_SRES.busy <= '0';
165
 
166
    EI_REQ <= r.intreq;
167
 
168
  end process proc_next;
169
 
170
end syn;

powered by: WebSVN 2.1.0

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