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

Subversion Repositories w11

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

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

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

powered by: WebSVN 2.1.0

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