w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
ibdr_lp11.vhd
Go to the documentation of this file.
1-- $Id: ibdr_lp11.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2009-2019 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: ibdr_lp11 - syn
7-- Description: ibus dev(rem): LP11
8--
9-- Dependencies: -
10-- Test bench: -
11-- Target Devices: generic
12-- Tool versions: ise 8.2-14.7; viv 2014.4-2018.3; 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 12 35 0 24 s 5.6
17-- 2009-07-11 232 10.1.03 K39 xc3s1000-4 11 30 0 19 s 5.8
18--
19-- Revision History:
20-- Date Rev Version Comment
21-- 2019-04-24 1138 1.3.3 add csr.ir (intreq monitor)
22-- 2019-03-10 1121 1.3.2 ignore buf write if csr.err=1 for lp11_buf compat
23-- 2019-03-03 1118 1.3.1 VAL in bit 15 and 8 for lp11_buf compat
24-- 2013-05-04 515 1.3 BUGFIX: r.err was cleared in racc read !
25-- 2011-11-18 427 1.2.2 now numeric_std clean
26-- 2010-10-23 335 1.2.1 rename RRI_LAM->RB_LAM;
27-- 2010-10-17 333 1.2 use ibus V2 interface
28-- 2010-06-11 303 1.1 use IB_MREQ.racc instead of RRI_REQ
29-- 2009-06-21 228 1.0.1 generate interrupt locally when err=1
30-- 2009-05-30 220 1.0 Initial version
31------------------------------------------------------------------------------
32--
33-- Notes:
34-- - the ERR bit is just a status flag
35-- - no hardware interlock (DONE forced 0 when ERR=1), like in simh
36-- - also no interrupt when ERR goes 1, like in simh
37
38
39library ieee;
40use ieee.std_logic_1164.all;
41use ieee.numeric_std.all;
42
43use work.slvtypes.all;
44use work.iblib.all;
45
46-- ----------------------------------------------------------------------------
47entity ibdr_lp11 is -- ibus dev(rem): LP11
48 -- fixed address: 177514
49 port (
50 CLK : in slbit; -- clock
51 RESET : in slbit; -- system reset
52 BRESET : in slbit; -- ibus reset
53 RB_LAM : out slbit; -- remote attention
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 );
59end ibdr_lp11;
60
61architecture syn of ibdr_lp11 is
62
63 constant ibaddr_lp11 : slv16 := slv(to_unsigned(8#177514#,16));
64
65 constant ibaddr_csr : slv1 := "0"; -- csr address offset
66 constant ibaddr_buf : slv1 := "1"; -- buf address offset
67
68 constant csr_ibf_err : integer := 15;
69 constant csr_ibf_done : integer := 7;
70 constant csr_ibf_ie : integer := 6;
71 constant csr_ibf_ir : integer := 5;
72 constant buf_ibf_val : integer := 15;
73 constant buf_ibf_val8: integer := 8;
74
75 type regs_type is record -- state registers
76 ibsel : slbit; -- ibus select
77 err : slbit; -- csr: error flag
78 done : slbit; -- csr: done flag
79 ie : slbit; -- csr: interrupt enable
80 buf : slv7; -- buf:
81 intreq : slbit; -- interrupt request
82 end record regs_type;
83
84 constant regs_init : regs_type := (
85 '0', -- ibsel
86 '1', -- err !! is set !!
87 '1', -- done !! is set !!
88 '0', -- ie
89 (others=>'0'), -- buf
90 '0' -- intreq
91 );
92
95
96begin
97
98 proc_regs: process (CLK)
99 begin
100 if rising_edge(CLK) then
101 if BRESET = '1' then -- BRESET is 1 for system and ibus reset
102 R_REGS <= regs_init;
103 if RESET = '0' then -- if RESET=0 we do just an ibus reset
104 R_REGS.err <= N_REGS.err; -- don't reset ERR flag
105 end if;
106 else
107 R_REGS <= N_REGS;
108 end if;
109 end if;
110 end process proc_regs;
111
112 proc_next : process (R_REGS, IB_MREQ, EI_ACK)
113 variable r : regs_type := regs_init;
114 variable n : regs_type := regs_init;
115 variable idout : slv16 := (others=>'0');
116 variable ibreq : slbit := '0';
117 variable ibrd : slbit := '0';
118 variable ibw0 : slbit := '0';
119 variable ibw1 : slbit := '0';
120 variable ilam : slbit := '0';
121 begin
122
123 r := R_REGS;
124 n := R_REGS;
125
126 idout := (others=>'0');
127 ibreq := IB_MREQ.re or IB_MREQ.we;
128 ibrd := IB_MREQ.re;
129 ibw0 := IB_MREQ.we and IB_MREQ.be0;
130 ibw1 := IB_MREQ.we and IB_MREQ.be1;
131 ilam := '0';
132
133 -- ibus address decoder
134 n.ibsel := '0';
135 if IB_MREQ.aval='1' and
136 IB_MREQ.addr(12 downto 2)=ibaddr_lp11(12 downto 2) then
137 n.ibsel := '1';
138 end if;
139
140 -- ibus transactions
141 if r.ibsel = '1' then
142 case IB_MREQ.addr(1 downto 1) is
143
144 when ibaddr_csr => -- CSR -- control status -------------
145 idout(csr_ibf_err) := r.err;
146 idout(csr_ibf_done) := r.done;
147 idout(csr_ibf_ie) := r.ie;
148
149 if IB_MREQ.racc = '0' then -- cpu ---------------------
150 if ibw0 = '1' then
151 n.ie := IB_MREQ.din(csr_ibf_ie);
152 if IB_MREQ.din(csr_ibf_ie) = '1' then
153 if r.done='1' and r.ie='0' then -- ie set while done=1
154 n.intreq := '1'; -- request interrupt
155 end if;
156 else
157 n.intreq := '0';
158 end if;
159 end if;
160
161 else -- rri ---------------------
162 idout(csr_ibf_ir) := r.intreq;
163 if ibw1 = '1' then
164 n.err := IB_MREQ.din(csr_ibf_err);
165 if IB_MREQ.din(csr_ibf_err) = '1' then
166 n.done := '1';
167 n.intreq := '0'; -- clear irupt (like simh!)
168 end if;
169 end if;
170 end if;
171
172 when ibaddr_buf => -- BUF -- data buffer ----------------
173
174 if IB_MREQ.racc = '0' then -- cpu ---------------------
175 if ibw0 = '1' then
176 if r.done = '1' then -- ignore buf write when done=0
177 n.buf := IB_MREQ.din(n.buf'range);
178 if r.err = '0' then -- if online (handle via rbus)
179 ilam := '1'; -- request attention
180 n.done := '0'; -- clear done
181 n.intreq := '0'; -- clear interrupt
182 else -- if offline (discard locally)
183 n.done := '1'; -- set done
184 if r.ie = '1' then -- if interrupts enabled
185 n.intreq := '1'; -- request interrupt
186 end if;
187 end if; -- r.err = '0'
188 end if; -- r.done = '1'
189 end if; -- ibw0 = '1'
190
191 else -- rri ---------------------
192 idout(r.buf'range) := r.buf;
193 idout(buf_ibf_val) := not r.done;
194 idout(buf_ibf_val8) := not r.done;
195 if ibrd = '1' then
196 n.done := '1';
197 if r.ie = '1' then
198 n.intreq := '1';
199 end if;
200 end if;
201 end if;
202
203 when others => null;
204 end case;
205
206 end if;
207
208 -- other state changes
209 if EI_ACK = '1' then
210 n.intreq := '0';
211 end if;
212
213 N_REGS <= n;
214
215 IB_SRES.dout <= idout;
216 IB_SRES.ack <= r.ibsel and ibreq;
217 IB_SRES.busy <= '0';
218
219 RB_LAM <= ilam;
220 EI_REQ <= r.intreq;
221
222 end process proc_next;
223
224
225end syn;
integer := 6 csr_ibf_ie
Definition: ibdr_lp11.vhd:70
slv1 := "1" ibaddr_buf
Definition: ibdr_lp11.vhd:66
integer := 15 csr_ibf_err
Definition: ibdr_lp11.vhd:68
integer := 8 buf_ibf_val8
Definition: ibdr_lp11.vhd:73
regs_type := regs_init N_REGS
Definition: ibdr_lp11.vhd:94
slv1 := "0" ibaddr_csr
Definition: ibdr_lp11.vhd:65
integer := 7 csr_ibf_done
Definition: ibdr_lp11.vhd:69
slv16 := slv( to_unsigned( 8#177514#, 16) ) ibaddr_lp11
Definition: ibdr_lp11.vhd:63
regs_type :=( '0', '1', '1', '0',( others => '0'), '0') regs_init
Definition: ibdr_lp11.vhd:84
regs_type := regs_init R_REGS
Definition: ibdr_lp11.vhd:93
integer := 15 buf_ibf_val
Definition: ibdr_lp11.vhd:72
integer := 5 csr_ibf_ir
Definition: ibdr_lp11.vhd:71
out EI_REQ slbit
Definition: ibdr_lp11.vhd:56
in RESET slbit
Definition: ibdr_lp11.vhd:51
in BRESET slbit
Definition: ibdr_lp11.vhd:52
out RB_LAM slbit
Definition: ibdr_lp11.vhd:53
in CLK slbit
Definition: ibdr_lp11.vhd:50
in IB_MREQ ib_mreq_type
Definition: ibdr_lp11.vhd:54
out IB_SRES ib_sres_type
Definition: ibdr_lp11.vhd:55
in EI_ACK slbit
Definition: ibdr_lp11.vhd:58
Definition: iblib.vhd:33
std_logic_vector( 6 downto 0) slv7
Definition: slvtypes.vhd:39
std_logic_vector( 0 downto 0) slv1
Definition: slvtypes.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