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

Subversion Repositories w11

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

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

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

powered by: WebSVN 2.1.0

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