w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
ibd_kw11l.vhd
Go to the documentation of this file.
1-- $Id: ibd_kw11l.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2008-2019 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: ibd_kw11l - syn
7-- Description: ibus dev(loc): KW11-L (line clock)
8--
9-- Dependencies: -
10-- Test bench: -
11-- Target Devices: generic
12-- Tool versions: ise 8.2-14.7; viv 2017.2; ghdl 0.18-0.35
13--
14-- Synthesized (xst):
15-- Date Rev ise Target flop lutl lutm slic t peri
16-- 2010-10-17 333 12.1 M53d xc3s1000-4 9 23 0 14 s 5.3
17-- 2009-07-11 232 10.1.03 K39 xc3s1000-4 8 25 0 15 s 5.3
18--
19-- Revision History:
20-- Date Rev Version Comment
21-- 2019-04-24 1138 1.2.1 add csr.ir; csr only loc writable;
22-- csr.moni can be cleared, but not set by loc write
23-- 2015-05-09 676 1.2 add CPUSUSP, freeze timer when cpu suspended
24-- 2011-11-18 427 1.1.1 now numeric_std clean
25-- 2010-10-17 333 1.1 use ibus V2 interface
26-- 2009-06-01 221 1.0.5 BUGFIX: add RESET; don't clear tcnt on ibus reset
27-- 2008-08-22 161 1.0.4 use iblib; add EI_ACK to proc_next sens. list
28-- 2008-05-09 144 1.0.3 use intreq flop, use EI_ACK
29-- 2008-01-20 112 1.0.2 fix proc_next sensitivity list; use BRESET
30-- 2008-01-06 111 1.0.1 Renamed to ibd_kw11l (RRI_REQ not used)
31-- 2008-01-05 110 1.0 Initial version
32------------------------------------------------------------------------------
33
34library ieee;
35use ieee.std_logic_1164.all;
36use ieee.numeric_std.all;
37
38use work.slvtypes.all;
39use work.iblib.all;
40
41-- ----------------------------------------------------------------------------
42entity ibd_kw11l is -- ibus dev(loc): KW11-L (line clock)
43 -- fixed address: 177546
44 port (
45 CLK : in slbit; -- clock
46 CE_MSEC : in slbit; -- msec pulse
47 RESET : in slbit; -- system reset
48 BRESET : in slbit; -- ibus reset
49 CPUSUSP : in slbit; -- cpu suspended
50 IB_MREQ : in ib_mreq_type; -- ibus request
51 IB_SRES : out ib_sres_type; -- ibus response
52 EI_REQ : out slbit; -- interrupt request
53 EI_ACK : in slbit -- interrupt acknowledge
54 );
55end ibd_kw11l;
56
57architecture syn of ibd_kw11l is
58
59 constant ibaddr_kw11l : slv16 := slv(to_unsigned(8#177546#,16));
60
61 constant lks_ibf_moni : integer := 7;
62 constant lks_ibf_ie : integer := 6;
63 constant lks_ibf_ir : integer := 5;
64
65 constant twidth : natural := 5;
66 constant tdivide : natural := 20;
67
68 type regs_type is record -- state registers
69 ibsel : slbit; -- ibus select
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', -- ibsel
78 '0', -- ie
79 '1', -- moni (set on reset !!)
80 '0', -- intreq
81 (others=>'0') -- tcnt
82 );
83
86
87begin
88
89 proc_regs: process (CLK)
90 begin
91 if rising_edge(CLK) then
92 if BRESET = '1' then -- BRESET is 1 for system and ibus reset
94 if RESET = '0' then -- if RESET=0 we do just an ibus reset
95 R_REGS.tcnt <= N_REGS.tcnt; -- don't clear msec tick counter
96 end if;
97 else
98 R_REGS <= N_REGS;
99 end if;
100 end if;
101 end process proc_regs;
102
103 proc_next : process (R_REGS, IB_MREQ, CE_MSEC, CPUSUSP, EI_ACK)
104 variable r : regs_type := regs_init;
105 variable n : regs_type := regs_init;
106 variable idout : slv16 := (others=>'0');
107 variable ibreq : slbit := '0';
108 variable ibw0 : slbit := '0';
109 begin
110
111 r := R_REGS;
112 n := R_REGS;
113
114 idout := (others=>'0');
115 ibreq := IB_MREQ.re or IB_MREQ.we;
116 ibw0 := IB_MREQ.we and IB_MREQ.be0;
117
118 -- ibus address decoder
119 n.ibsel := '0';
120 if IB_MREQ.aval='1' and
121 IB_MREQ.addr=ibaddr_kw11l(12 downto 1) then
122 n.ibsel := '1';
123 end if;
124
125 -- ibus output driver
126 if r.ibsel = '1' then
127 idout(lks_ibf_moni) := r.moni;
128 idout(lks_ibf_ie) := r.ie;
129 if IB_MREQ.racc = '1' then -- rri ---------------------
130 idout(lks_ibf_ir) := r.intreq;
131 end if;
132 end if;
133
134 -- ibus write transactions
135 if r.ibsel='1' and ibw0='1' then
136 if IB_MREQ.racc = '0' then -- cpu ---------------------
137 n.ie := IB_MREQ.din(lks_ibf_ie);
138 if IB_MREQ.din(lks_ibf_moni) = '0' then -- write 0 to moni
139 n.moni := '0'; -- clears moni
140 end if;
141 if IB_MREQ.din(lks_ibf_ie) = '0' then -- ie set 0
142 n.intreq := '0'; -- cancel interrupt
143 end if;
144 end if;
145 end if;
146
147 -- other state changes
148 if CE_MSEC='1' and CPUSUSP='0' then -- on msec and not suspended
149 n.tcnt := slv(unsigned(r.tcnt) + 1);
150 if unsigned(r.tcnt) = tdivide-1 then
151 n.tcnt := (others=>'0');
152 n.moni := '1';
153 if r.ie = '1' then
154 n.intreq := '1';
155 end if;
156 end if;
157 end if;
158
159 if EI_ACK = '1' then
160 n.intreq := '0';
161 end if;
162
163 N_REGS <= n;
164
165 IB_SRES.dout <= idout;
166 IB_SRES.ack <= r.ibsel and ibreq;
167 IB_SRES.busy <= '0';
168
169 EI_REQ <= r.intreq;
170
171 end process proc_next;
172
173end syn;
natural := 5 twidth
Definition: ibd_kw11l.vhd:65
integer := 5 lks_ibf_ir
Definition: ibd_kw11l.vhd:63
integer := 7 lks_ibf_moni
Definition: ibd_kw11l.vhd:61
slv16 := slv( to_unsigned( 8#177546#, 16) ) ibaddr_kw11l
Definition: ibd_kw11l.vhd:59
regs_type := regs_init N_REGS
Definition: ibd_kw11l.vhd:85
natural := 20 tdivide
Definition: ibd_kw11l.vhd:66
regs_type := regs_init R_REGS
Definition: ibd_kw11l.vhd:84
regs_type :=( '0', '0', '1', '0',( others => '0')) regs_init
Definition: ibd_kw11l.vhd:76
integer := 6 lks_ibf_ie
Definition: ibd_kw11l.vhd:62
out EI_REQ slbit
Definition: ibd_kw11l.vhd:52
in RESET slbit
Definition: ibd_kw11l.vhd:47
in BRESET slbit
Definition: ibd_kw11l.vhd:48
in CLK slbit
Definition: ibd_kw11l.vhd:45
in IB_MREQ ib_mreq_type
Definition: ibd_kw11l.vhd:50
in CPUSUSP slbit
Definition: ibd_kw11l.vhd:49
out IB_SRES ib_sres_type
Definition: ibd_kw11l.vhd:51
in EI_ACK slbit
Definition: ibd_kw11l.vhd:54
in CE_MSEC slbit
Definition: ibd_kw11l.vhd:46
Definition: iblib.vhd:33
std_logic_vector( 15 downto 0) slv16
Definition: slvtypes.vhd:48
std_logic slbit
Definition: slvtypes.vhd:30
std_logic_vector slv
Definition: slvtypes.vhd:31