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

Subversion Repositories w11

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

powered by: WebSVN 2.1.0

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