w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
ibdr_lp11_buf.vhd
Go to the documentation of this file.
1-- $Id: ibdr_lp11_buf.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2019- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: ibdr_lp11_buf - syn
7-- Description: ibus dev(rem): LP11
8--
9-- Dependencies: fifo_simple_dram
10-- ib_rlim_slv
11-- Test bench: -
12-- Target Devices: generic
13-- Tool versions: ise 8.2-14.7; viv 2017.2-2018.3; ghdl 0.35
14--
15-- Revision History:
16-- Date Rev Version Comment
17-- 2019-05-31 1156 1.0.4 size->fuse rename; re-organize rlim handling
18-- 2019-04-24 1138 1.0.3 add csr.ir (intreq monitor)
19-- 2019-04-20 1134 1.0.2 remove fifo clear on BRESET
20-- 2019-04-14 1131 1.0.1 RLIM_CEV now slv8
21-- 2019-03-17 1123 1.0 Initial version
22-- 2019-03-10 1121 0.1 First draft (derived from ibdr_lp11)
23------------------------------------------------------------------------------
24--
25-- Notes:
26-- - the ERR bit is just a status flag
27-- - no hardware interlock (DONE forced 0 when ERR=1), like in simh
28-- - also no interrupt when ERR goes 1, like in simh
29
30
31library ieee;
32use ieee.std_logic_1164.all;
33use ieee.numeric_std.all;
34
35use work.slvtypes.all;
36use work.memlib.all;
37use work.iblib.all;
38
39-- ----------------------------------------------------------------------------
40entity ibdr_lp11_buf is -- ibus dev(rem): LP11 (buffered)
41 -- fixed address: 177514
42 generic (
43 AWIDTH : natural := 5); -- fifo address width
44 port (
45 CLK : in slbit; -- clock
46 RESET : in slbit; -- system reset
47 BRESET : in slbit; -- ibus reset
48 RLIM_CEV : in slv8; -- clock enable vector
49 RB_LAM : out slbit; -- remote attention
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 );
56
57architecture syn of ibdr_lp11_buf is
58
59 constant ibaddr_lp11 : slv16 := slv(to_unsigned(8#177514#,16));
60
61 constant ibaddr_csr : slv1 := "0"; -- csr address offset
62 constant ibaddr_buf : slv1 := "1"; -- buf address offset
63
64 constant csr_ibf_err : integer := 15;
65 subtype csr_ibf_rlim is integer range 14 downto 12;
66 subtype csr_ibf_type is integer range 10 downto 8;
67 constant csr_ibf_done : integer := 7;
68 constant csr_ibf_ie : integer := 6;
69 constant csr_ibf_ir : integer := 5;
70 constant buf_ibf_val : integer := 15;
71 subtype buf_ibf_fuse is integer range AWIDTH-1+8 downto 8;
72 subtype buf_ibf_data is integer range 6 downto 0;
73
74 type regs_type is record -- state registers
75 ibsel : slbit; -- ibus select
76 err : slbit; -- csr: error flag
77 rlim : slv3; -- csr: rate limit
78 done : slbit; -- csr: done flag
79 ie : slbit; -- csr: interrupt enable
80 intreq : slbit; -- interrupt request
81 end record regs_type;
82
83 constant regs_init : regs_type := (
84 '0', -- ibsel
85 '1', -- err !! is set !!
86 "000", -- rlim
87 '1', -- done !! is set !!
88 '0', -- ie
89 '0' -- intreq
90 );
91
94
95 signal PBUF_CE : slbit := '0';
96 signal PBUF_WE : slbit := '0';
97 signal PBUF_DO : slv7 := (others=>'0');
98 signal PBUF_RESET : slbit := '0';
99 signal PBUF_EMPTY : slbit := '0';
100 signal PBUF_FULL : slbit := '0';
101 signal PBUF_FUSE : slv(AWIDTH-1 downto 0) := (others=>'0');
102
103 signal RLIM_START : slbit := '0';
104 signal RLIM_BUSY : slbit := '0';
105
106begin
107
108 assert AWIDTH>=4 and AWIDTH<=7
109 report "assert(AWIDTH>=4 and AWIDTH<=7): unsupported AWIDTH"
110 severity failure;
111
112 PBUF : fifo_simple_dram
113 generic map (
114 AWIDTH => AWIDTH,
115 DWIDTH => 7)
116 port map (
117 CLK => CLK,
118 RESET => PBUF_RESET,
119 CE => PBUF_CE,
120 WE => PBUF_WE,
121 DI => IB_MREQ.din(buf_ibf_data),
122 DO => PBUF_DO,
123 EMPTY => PBUF_EMPTY,
124 FULL => PBUF_FULL,
125 SIZE => PBUF_FUSE
126 );
127
128 RLIM : ib_rlim_slv
129 port map (
130 CLK => CLK,
131 RESET => RESET,
133 SEL => R_REGS.rlim,
134 START => RLIM_START,
135 STOP => BRESET,
136 DONE => open,
137 BUSY => RLIM_BUSY
138 );
139
140 proc_regs: process (CLK)
141 begin
142 if rising_edge(CLK) then
143 if BRESET = '1' then -- BRESET is 1 for system and ibus reset
144 R_REGS <= regs_init;
145 if RESET = '0' then -- if RESET=0 we do just an ibus reset
146 R_REGS.err <= N_REGS.err; -- keep ERR flag
147 R_REGS.rlim <= N_REGS.rlim; -- keep RLIM flag
148 end if;
149 else
150 R_REGS <= N_REGS;
151 end if;
152 end if;
153 end process proc_regs;
154
155 proc_next : process (R_REGS, IB_MREQ, EI_ACK, RESET, BRESET,
157 variable r : regs_type := regs_init;
158 variable n : regs_type := regs_init;
159 variable idout : slv16 := (others=>'0');
160 variable ibreq : slbit := '0';
161 variable iback : slbit := '0';
162 variable ibrd : slbit := '0';
163 variable ibw0 : slbit := '0';
164 variable ibw1 : slbit := '0';
165 variable ilam : slbit := '0';
166 variable ipbufce : slbit := '0';
167 variable ipbufwe : slbit := '0';
168 variable irlimsta : slbit := '0';
169 begin
170
171 r := R_REGS;
172 n := R_REGS;
173
174 idout := (others=>'0');
175 ibreq := IB_MREQ.re or IB_MREQ.we;
176 iback := r.ibsel and ibreq;
177 ibrd := IB_MREQ.re;
178 ibw0 := IB_MREQ.we and IB_MREQ.be0;
179 ibw1 := IB_MREQ.we and IB_MREQ.be1;
180 ilam := '0';
181 ipbufce := '0';
182 ipbufwe := '0';
183 irlimsta := '0';
184
185 -- ibus address decoder
186 n.ibsel := '0';
187 if IB_MREQ.aval='1' and
188 IB_MREQ.addr(12 downto 2)=ibaddr_lp11(12 downto 2) then
189 n.ibsel := '1';
190 end if;
191
192 -- ibus transactions
193 if r.ibsel = '1' then -- ibus selected ---------------------
194 case IB_MREQ.addr(1 downto 1) is
195
196 when ibaddr_csr => -- CSR -- control status -------------
197 idout(csr_ibf_err) := r.err;
198 idout(csr_ibf_done) := r.done;
199 idout(csr_ibf_ie) := r.ie;
200
201 if IB_MREQ.racc = '0' then -- cpu
202 if ibw0 = '1' then
203 n.ie := IB_MREQ.din(csr_ibf_ie);
204 if IB_MREQ.din(csr_ibf_ie) = '1' then
205 if r.done='1' and r.ie='0' then -- ie set while done=1
206 n.intreq := '1'; -- request interrupt
207 end if;
208 else
209 n.intreq := '0';
210 end if;
211 end if;
212
213 else -- rri
214 idout(csr_ibf_rlim) := r.rlim;
215 idout(csr_ibf_type) := slv(to_unsigned(AWIDTH,3));
216 idout(csr_ibf_ir) := r.intreq;
217 if ibw1 = '1' then
218 n.err := IB_MREQ.din(csr_ibf_err);
219 n.rlim := IB_MREQ.din(csr_ibf_rlim);
220 if IB_MREQ.din(csr_ibf_err) = '1' then
221 n.done := '1';
222 n.intreq := '0'; -- clear irupt (like simh!)
223 end if;
224 end if;
225 end if;
226
227 when ibaddr_buf => -- BUF -- data buffer ----------------
228
229 if IB_MREQ.racc = '0' then -- cpu
230 if ibw0 = '1' then
231 if r.done = '1' then -- ignore buf write when done=0
232 n.done := '0'; -- clear done
233 n.intreq := '0'; -- clear interrupt
234 if r.err = '0' then -- if online (handle via rbus)
235 if PBUF_FULL = '0' then -- fifo not full
236 ipbufce := '1'; -- write to fifo
237 ipbufwe := '1';
238 if PBUF_EMPTY = '1' then -- first write to empty fifo
239 ilam := '1'; -- request attention
240 end if;
241 end if; -- PBUF_FULL = '0'
242 else -- if offline (discard locally)
243 null;
244 end if; -- r.err = '0'
245 end if; -- r.done = '1'
246 end if; -- ibw0 = '1'
247
248 else -- rri
249 idout(buf_ibf_val) := not PBUF_EMPTY;
250 idout(buf_ibf_fuse) := PBUF_FUSE;
251 idout(buf_ibf_data) := PBUF_DO;
252 if ibrd = '1' then
253 if PBUF_EMPTY = '0' then -- fifo not empty
254 ipbufce := '1'; -- read from fifo
255 ipbufwe := '0';
256 else -- read from empty fifo
257 iback := '0'; -- signal nak
258 end if;
259 end if;
260 end if;
261
262 when others => null;
263 end case;
264
265 else -- ibus not selected -----------------
266 -- handle done, timer and interrupt
267 if PBUF_FULL='0' and RLIM_BUSY='0' then -- not full and not busy ?
268 if r.done = '0' then -- done not set ?
269 n.done := '1'; -- set done
270 irlimsta := '1'; -- start timer
271 if r.err='0' and r.ie='1' then -- err=0 and irupt enabled ?
272 n.intreq := '1'; -- request interrupt
273 end if;
274 end if;
275 end if;
276 end if; -- else r.ibsel='1'
277
278 -- other state changes
279 if EI_ACK = '1' then
280 n.intreq := '0';
281 end if;
282
283 N_REGS <= n;
284
285 PBUF_RESET <= RESET or r.err;
286 PBUF_CE <= ipbufce;
287 PBUF_WE <= ipbufwe;
288 RLIM_START <= irlimsta;
289
290 IB_SRES.dout <= idout;
291 IB_SRES.ack <= iback;
292 IB_SRES.busy <= '0';
293
294 RB_LAM <= ilam;
295 EI_REQ <= r.intreq;
296
297 end process proc_next;
298
299
300end syn;
out DO slv( DWIDTH- 1 downto 0)
in DI slv( DWIDTH- 1 downto 0)
AWIDTH positive := 6
out SIZE slv( AWIDTH- 1 downto 0)
DWIDTH positive := 16
in STOP slbit
Definition: ib_rlim_slv.vhd:46
in RESET slbit
Definition: ib_rlim_slv.vhd:42
out BUSY slbit
Definition: ib_rlim_slv.vhd:49
out DONE slbit
Definition: ib_rlim_slv.vhd:47
in CLK slbit
Definition: ib_rlim_slv.vhd:41
in SEL slv3
Definition: ib_rlim_slv.vhd:44
in RLIM_CEV slv8
Definition: ib_rlim_slv.vhd:43
in START slbit
Definition: ib_rlim_slv.vhd:45
integer range 6 downto 0 buf_ibf_data
integer := 6 csr_ibf_ie
slv1 := "1" ibaddr_buf
integer := 15 csr_ibf_err
regs_type := regs_init N_REGS
slv1 := "0" ibaddr_csr
integer := 7 csr_ibf_done
ib_rlim_slv rlimrlim
slv16 := slv( to_unsigned( 8#177514#, 16) ) ibaddr_lp11
regs_type :=( '0', '1', "000", '1', '0', '0') regs_init
slbit := '0' PBUF_RESET
slv7 :=( others => '0') PBUF_DO
slbit := '0' RLIM_BUSY
regs_type := regs_init R_REGS
integer range AWIDTH- 1+ 8 downto 8 buf_ibf_fuse
integer range 10 downto 8 csr_ibf_type
slbit := '0' RLIM_START
slbit := '0' PBUF_EMPTY
slbit := '0' PBUF_WE
integer := 15 buf_ibf_val
integer := 5 csr_ibf_ir
slbit := '0' PBUF_FULL
slbit := '0' PBUF_CE
integer range 14 downto 12 csr_ibf_rlim
slv( AWIDTH- 1 downto 0) :=( others => '0') PBUF_FUSE
out EI_REQ slbit
in RESET slbit
AWIDTH natural := 5
in BRESET slbit
out RB_LAM slbit
in CLK slbit
in IB_MREQ ib_mreq_type
out IB_SRES ib_sres_type
in EI_ACK slbit
in RLIM_CEV slv8
Definition: iblib.vhd:33
std_logic_vector( 6 downto 0) slv7
Definition: slvtypes.vhd:39
std_logic_vector( 2 downto 0) slv3
Definition: slvtypes.vhd:35
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( 7 downto 0) slv8
Definition: slvtypes.vhd:40
std_logic_vector slv
Definition: slvtypes.vhd:31