w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
nx_cram_memctl_as.vhd
Go to the documentation of this file.
1-- $Id: nx_cram_memctl_as.vhd 1203 2019-08-19 21:41:03Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2010-2019 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: nx_cram_memctl_as - syn
7-- Description: nexys2/3/4: CRAM controller - async and page mode
8--
9-- Dependencies: vlib/xlib/iob_reg_o
10-- vlib/xlib/iob_reg_o_gen
11-- vlib/xlib/iob_reg_io_gen
12-- Test bench: tb/tb_nx_cram_memctl_as
13-- sys_gen/tst_sram/nexys2/tb/tb_tst_sram_n2
14-- sys_gen/tst_sram/nexys3/tb/tb_tst_sram_n3
15-- sys_gen/tst_sram/nexys4/tb/tb_tst_sram_n4
16-- Target Devices: generic
17-- Tool versions: ise 11.4-14.7; viv 2014.4-2019.1; ghdl 0.26-0.36
18--
19-- Synthesized (viv):
20-- Date Rev viv Target flop lutl lutm bram slic
21-- 2016-07-03 783 2016.3 xc7a100t-1 91 87 0 0 43
22--
23-- Synthesized (xst):
24-- Date Rev ise Target flop lutl lutm slic t peri
25-- Date Rev ise Target flop lutl lutm slic t peri
26-- 2016-07-03 767 14.7 131013 xc6slx16-2 100 134 0 60 s 4.2
27-- 2010-06-03 299 11.4 L68 xc3s1200e-4 91 100 0 96 s 6.7
28-- 2010-05-24 294 11.4 L68 xc3s1200e-4 91 99 0 95 s 6.7
29-- 2010-05-23 293 11.4 L68 xc3s1200e-4 91 139 0 99 s 6.7
30--
31-- Revision History:
32-- Date Rev Version Comment
33-- 2019-08-17 1203 2.1.1 fix for ghdl V0.36 -Whide warnings
34-- 2016-07-16 788 2.1 change *DELAY generics, now absolute delay cycles
35-- add s_init1; drop "KEEP" for data (better for dbg)
36-- 2016-07-10 786 2.0 add page mode support
37-- 2016-05-22 767 1.2.2 don't init N_REGS (vivado fix for fsm inference)
38-- 2015-12-26 718 1.2.1 BUGFIX: do_dispatch(): always define imem_oe
39-- 2011-11-26 433 1.2 renamed from n2_cram_memctl_as
40-- 2011-11-19 432 1.1 remove O_FLA_CE_N port
41-- 2011-11-19 427 1.0.5 now numeric_std clean
42-- 2010-11-22 339 1.0.4 cntdly now 3 bit; add assert for DELAY generics
43-- 2010-06-03 299 1.0.3 add "KEEP" for data iob; MEM_OE='1' on first read
44-- cycle;
45-- 2010-05-30 297 1.0.2 use READ(0|1)DELAY generic
46-- 2010-05-24 294 1.0.1 more compact n.memdi logic; extra wait in s_rdwait1
47-- 2010-05-23 293 1.0 Initial version
48--
49-- Notes:
50-- 1. There is no 'bus-turn-around' cycle needed for a write->read change
51-- FPGA_OE goes 1->0 and MEM_OE goes 0->1 on the s_wrput1->s_rdinit
52-- transition simultaneously. The FPGA will go high-Z quickly, the memory
53-- low-Z delay by the IOB and internal memory delays. No clash.
54-- 2. There is a hidden 'bus-turn-around' cycle for a read->write change.
55-- MEM_OE goes 1->0 on s_rdget1->s_wrinit and the memory will go high-z with
56-- some delay. FPGA_OE goes 0->1 in the next cycle at s_wrinit->s_wrwait0.
57-- Again no clash due to the 1 cycle delay.
58--
59-- Nominal timings:
60-- READ0 = (T_aa + ext_read_delay) in cycles
61-- READ1 = (T_pa + ext_read_delay) in cycles
62-- WRITE = (T_aa + ext_write_delay) in cycles
63-- with
64-- ext_read_delay: output_IOB + 2*PCB_delay + input_IOB + skew
65-- ext_write_delay: skew
66--
67--
68-- Timing of some signals:
69--
70-- single read request:
71--
72-- state |_idle |_rdinit|_rdwt0 |_rdwt0 |_rdget0|_rdwt1 |_rdget1|
73-- 0 20 40 60 80 100 120
74-- CLK __|^^^|___|^^^|___|^^^|___|^^^|___|^^^|___|^^^|___|^^^|___|^^^|___|
75--
76-- REQ _______|^^^^^|_____________________________________________
77-- WE ___________________________________________________________
78--
79-- IOB_CE __________|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^|_
80-- IOB_OE _________|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^|_
81--
82-- DO oooooooooooooooooooooooooooooooooooooooooo|lllllll|lllllll|h
83-- BUSY __________|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^|________________
84-- ACK_R ___________________________________________________________|^^^^^^^|_
85--
86-- single write request:
87--
88-- state |_idle |_wrinit|_wrwt0 |_wrwt0 |_wrwt0 |_wrput0|_idle |
89-- 0 20 40 60 80 100 120
90-- CLK __|^^^|___|^^^|___|^^^|___|^^^|___|^^^|___|^^^|___|^^^|___|^^^|___|
91--
92-- REQ _______|^^^^^|______________________________________
93-- WE _______|^^^^^|______________________________________
94--
95-- IOB_CE __________|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^|_
96-- IOB_BE __________|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^|_
97-- IOB_OE ____________________________________________________
98-- IOB_WE ______________|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^|_____
99--
100-- BUSY __________|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^|_________
101-- ACK_W __________________________________________|^^^^^^^|_
102--
103------------------------------------------------------------------------------
104
105library ieee;
106use ieee.std_logic_1164.all;
107use ieee.numeric_std.all;
108
109use work.slvtypes.all;
110use work.xlib.all;
111
112entity nx_cram_memctl_as is -- CRAM controller (async+page mode)
113 generic (
114 READ0DELAY : positive := 4; -- read word 0 delay in clock cycles
115 READ1DELAY : positive := 2; -- read word 1 delay in clock cycles
116 WRITEDELAY : positive := 4); -- write delay in clock cycles
117 port (
118 CLK : in slbit; -- clock
119 RESET : in slbit; -- reset
120 REQ : in slbit; -- request
121 WE : in slbit; -- write enable
122 BUSY : out slbit; -- controller busy
123 ACK_R : out slbit; -- acknowledge read
124 ACK_W : out slbit; -- acknowledge write
125 ACT_R : out slbit; -- signal active read
126 ACT_W : out slbit; -- signal active write
127 ADDR : in slv22; -- address (32 bit word address)
128 BE : in slv4; -- byte enable
129 DI : in slv32; -- data in (memory view)
130 DO : out slv32; -- data out (memory view)
131 O_MEM_CE_N : out slbit; -- cram: chip enable (act.low)
132 O_MEM_BE_N : out slv2; -- cram: byte enables (act.low)
133 O_MEM_WE_N : out slbit; -- cram: write enable (act.low)
134 O_MEM_OE_N : out slbit; -- cram: output enable (act.low)
135 O_MEM_ADV_N : out slbit; -- cram: address valid (act.low)
136 O_MEM_CLK : out slbit; -- cram: clock
137 O_MEM_CRE : out slbit; -- cram: command register enable
138 I_MEM_WAIT : in slbit; -- cram: mem wait
139 O_MEM_ADDR : out slv23; -- cram: address lines
140 IO_MEM_DATA : inout slv16 -- cram: data lines
141 );
143
144
145architecture syn of nx_cram_memctl_as is
146
147 type state_type is (
148 s_init, -- s_init: startup state
149 s_init1, -- s_init1: reset released
150 s_wcinit, -- s_wcinit: write rcr init
151 s_wcwait, -- s_wcwait: write rcr wait
152 s_wcput, -- s_wcput: write rcr done
153 s_rainit, -- s_rainit: read array init
154 s_rawait, -- s_rawait: wait read array
155 s_idle, -- s_idle: wait for req
156 s_rdinit, -- s_rdinit: read init cycle
157 s_rdwait0, -- s_rdwait0: read wait low word
158 s_rdget0, -- s_rdget0: read get low word
159 s_rdwait1, -- s_rdwait1: read wait high word
160 s_rdget1, -- s_rdget1: read get high word
161 s_wrinit, -- s_wrinit: write init cycle
162 s_wrwait0, -- s_rdwait0: write wait 1st word
163 s_wrput0, -- s_rdput0: write put 1st word
164 s_wrini1, -- s_wrini1: write init 2nd word
165 s_wrwait1, -- s_wrwait1: write wait 2nd word
166 s_wrput1 -- s_wrput1: write put 2nd word
167 );
168
169 type regs_type is record
170 state : state_type; -- state
171 ackr : slbit; -- signal ack_r
172 addr0 : slbit; -- current addr0
173 be2nd : slv2; -- be's of 2nd write cycle
174 cntdly : slv3; -- wait delay counter
175 cntce : slv7; -- ce counter
176 fidle : slbit; -- force idle flag
177 memdo0 : slv16; -- mem data out, low word
178 memdi : slv32; -- mem data in
179 end record regs_type;
180
181 constant regs_init : regs_type := (
182 s_init, -- state
183 '0', -- ackr
184 '0', -- addr0
185 "00", -- be2nd
186 (others=>'0'), -- cntdly
187 (others=>'0'), -- cntce
188 '0', -- fidle
189 (others=>'0'), -- memdo0
190 (others=>'0') -- memdi
191 );
192
194 "000" & -- 22:20 reserved MBZ
195 "00" & -- 19:18 reg sel 00=RCR
196 "0000000000" & -- 17: 8 reserved MBZ
197 '1' & -- 7 page mode enable (1=enable)
198 "00" & -- 6: 5 reserved MBZ
199 '1' & -- 4 dpd disaable (1=disable)
200 "000"; -- 3: 1 rest is reserved or PAR, which should be 0
201
203 signal N_REGS : regs_type; -- don't init (vivado fix for fsm infer)
204
205 signal CLK_180 : slbit := '0';
206 signal MEM_CE_N : slbit := '1';
207 signal MEM_BE_N : slv2 := "11";
208 signal MEM_WE_N : slbit := '1';
209 signal MEM_OE_N : slbit := '1';
210 signal MEM_CRE : slbit := '0';
211 signal BE_CE : slbit := '0';
212 signal ADDRH_CE : slbit := '0';
213 signal ADDR0_CE : slbit := '0';
214 signal ADDRH : slv22 := (others=>'0');
215 signal ADDR0 : slbit := '0';
216 signal DATA_CEI : slbit := '0';
217 signal DATA_CEO : slbit := '0';
218 signal DATA_OE : slbit := '0';
219 signal MEM_DO : slv16 := (others=>'0');
220 signal MEM_DI : slv16 := (others=>'0');
221
222begin
223
224 -- Notes:
225 -- used READ0DELAY-2 and READ0DELAY-3
226 -- used READ1DELAY-2
227 -- used WRITEDELAY-2
228
229 assert READ0DELAY-2 < 2**R_REGS.cntdly'length and
230 READ1DELAY-2 < 2**R_REGS.cntdly'length and
231 WRITEDELAY-2 < 2**R_REGS.cntdly'length
232 report "assert( (READ0,READ1,WRITE)DELAY-2 < 2**cntdly'length)"
233 severity failure;
234 assert READ0DELAY >= 3 and
235 READ1DELAY >= 2 and
236 WRITEDELAY >= 2
237 report "assert( (READ0,READ1,WRITE)DELAY-2 >= 2 or 3)"
238 severity failure;
239
240 CLK_180 <= not CLK;
241
242 IOB_MEM_CE : iob_reg_o
243 generic map (
244 INIT => '1')
245 port map (
246 CLK => CLK,
247 CE => '1',
248 DO => MEM_CE_N,
249 PAD => O_MEM_CE_N
250 );
251
252 IOB_MEM_BE : iob_reg_o_gen
253 generic map (
254 DWIDTH => 2,
255 INIT => '1')
256 port map (
257 CLK => CLK,
258 CE => BE_CE,
259 DO => MEM_BE_N,
260 PAD => O_MEM_BE_N
261 );
262
263 IOB_MEM_WE : iob_reg_o
264 generic map (
265 INIT => '1')
266 port map (
267 CLK => CLK_180,
268 CE => '1',
269 DO => MEM_WE_N,
270 PAD => O_MEM_WE_N
271 );
272
273 IOB_MEM_OE : iob_reg_o
274 generic map (
275 INIT => '1')
276 port map (
277 CLK => CLK,
278 CE => '1',
279 DO => MEM_OE_N,
280 PAD => O_MEM_OE_N
281 );
282
283 IOB_MEM_CRE : iob_reg_o
284 generic map (
285 INIT => '0')
286 port map (
287 CLK => CLK,
288 CE => '1',
289 DO => MEM_CRE,
290 PAD => O_MEM_CRE
291 );
292
293 IOB_MEM_ADDRH : iob_reg_o_gen
294 generic map (
295 DWIDTH => 22)
296 port map (
297 CLK => CLK,
298 CE => ADDRH_CE,
299 DO => ADDRH,
300 PAD => O_MEM_ADDR(22 downto 1)
301 );
302
303 IOB_MEM_ADDR0 : iob_reg_o
304 port map (
305 CLK => CLK,
306 CE => ADDR0_CE,
307 DO => ADDR0,
308 PAD => O_MEM_ADDR(0)
309 );
310
311 IOB_MEM_DATA : iob_reg_io_gen
312 generic map (
313 DWIDTH => 16,
314 PULL => "NONE")
315 port map (
316 CLK => CLK,
317 CEI => DATA_CEI,
318 CEO => DATA_CEO,
319 OE => DATA_OE,
320 DI => MEM_DO,
321 DO => MEM_DI,
323 );
324
325 O_MEM_ADV_N <= '0';
326 O_MEM_CLK <= '0';
327
328 proc_regs: process (CLK)
329 begin
330
331 if rising_edge(CLK) then
332 if RESET = '1' then
333 R_REGS <= regs_init;
334 else
335 R_REGS <= N_REGS;
336 end if;
337 end if;
338
339 end process proc_regs;
340
341 proc_next: process (R_REGS, REQ, WE, BE, DI, ADDR, MEM_DO)
342
343 variable r : regs_type := regs_init;
344 variable n : regs_type := regs_init;
345 variable ibusy : slbit := '0';
346 variable iackw : slbit := '0';
347 variable iactr : slbit := '0';
348 variable iactw : slbit := '0';
349 variable imem_ce : slbit := '0';
350 variable imem_be : slv2 := "00";
351 variable imem_we : slbit := '0';
352 variable imem_oe : slbit := '0';
353 variable imem_cre : slbit := '0';
354 variable ibe_ce : slbit := '0';
355 variable iaddrh_ce : slbit := '0';
356 variable iaddr0_ce : slbit := '0';
357 variable iaddrh : slv22 := (others=>'0');
358 variable iaddr0 : slbit := '0';
359 variable idata_cei : slbit := '0';
360 variable idata_ceo : slbit := '0';
361 variable idata_oe : slbit := '0';
362
363 procedure do_dispatch(pnstate : out state_type;
364 piaddrh_ce : out slbit;
365 piaddr0_ce : out slbit;
366 piaddr0 : out slbit;
367 pibe_ce : out slbit;
368 pimem_be : out slv2;
369 pimem_ce : out slbit;
370 pimem_oe : out slbit;
371 pnbe2nd : out slv2) is
372 begin
373 piaddrh_ce := '1'; -- latch address (high part)
374 piaddr0_ce := '1'; -- latch address 0 bit
375 pibe_ce := '1'; -- latch be's
376 pimem_ce := '1'; -- ce CRAM next cycle
377 pnbe2nd := "00"; -- assume no 2nd write cycle
378 if WE = '0' then -- if READ requested
379 piaddr0 := '0'; -- go first for low word
380 pimem_be := "11"; -- on read always on
381 pimem_oe := '1'; -- oe CRAM next cycle
382 pnstate := s_rdinit; -- next: read init part
383 else -- if WRITE requested
384 if BE(1 downto 0) /= "00" then -- low word write
385 piaddr0 := '0'; -- access word 0
386 pimem_be := BE(1 downto 0); -- set be's for 1st cycle
387 pnbe2nd := BE(3 downto 2); -- keep be's for 2nd cycle
388 else -- high word write
389 piaddr0 := '1'; -- access word 1
390 pimem_be := BE(3 downto 2); -- set be's for 1st cycle
391 end if;
392 pimem_oe := '0'; -- oe=0
393 pnstate := s_wrinit; -- next: write init part
394 end if;
395 end procedure do_dispatch;
396
397 begin
398
399 r := R_REGS;
400 n := R_REGS;
401 n.ackr := '0';
402
403 ibusy := '0';
404 iackw := '0';
405 iactr := '0';
406 iactw := '0';
407
408 imem_ce := '0';
409 imem_be := "11";
410 imem_we := '0';
411 imem_oe := '0';
412 imem_cre := '0';
413 ibe_ce := '0';
414 iaddrh_ce := '0';
415 iaddr0_ce := '0';
416 iaddrh := ADDR;
417 iaddr0 := '0';
418 idata_cei := '0';
419 idata_ceo := '0';
420 idata_oe := '0';
421
422 if unsigned(r.cntdly) /= 0 then
423 n.cntdly := slv(unsigned(r.cntdly) - 1);
424 end if;
425
426 case r.state is
427 when s_init => -- s_init: startup state
428 ibusy := '1'; -- signal busy, unable to handle req
429 n.state := s_init1;
430
431 when s_init1 => -- s_init1: reset released
432 ibusy := '1'; -- signal busy, unable to handle req
433 iaddrh := c_addrh_rcr_setup;
434 iaddr0 := '0';
435 iaddrh_ce := '1';
436 iaddr0_ce := '1';
437 imem_ce := '1'; -- ce CRAM next cycle
438 imem_cre := '1'; -- cre CRAM next cycle
439 n.state := s_wcinit;
440
441 when s_wcinit => -- s_wcinit: write rcr init
442 ibusy := '1'; -- signal busy, unable to handle req
443 imem_ce := '1'; -- ce CRAM next cycle
444 imem_cre := '1'; -- cre CRAM next cycle
445 imem_we := '1'; -- we CRAM next cycle
446 n.cntdly := slv(to_unsigned(WRITEDELAY-2, n.cntdly'length));
447 n.state := s_wcwait;
448
449 when s_wcwait => -- s_wcinit: write rcr wait
450 ibusy := '1'; -- signal busy, unable to handle req
451 imem_ce := '1'; -- ce CRAM next cycle
452 imem_we := '1'; -- we CRAM next cycle
453 imem_cre := '1'; -- cre CRAM next cycle
454 if unsigned(r.cntdly) = 0 then -- wait expired ?
455 n.state := s_wcput; -- next: write rcr done
456 end if;
457
458 when s_wcput => -- s_wcput: write rcr done
459 ibusy := '1'; -- signal busy, unable to handle req
460 n.state := s_rainit; -- next: read array init
461
462 when s_rainit => -- s_rainit: read array init
463 ibusy := '1'; -- signal busy, unable to handle req
464 imem_ce := '1'; -- ce CRAM next cycle
465 n.cntdly:= slv(to_unsigned(READ0DELAY-2, n.cntdly'length));
466 n.state := s_rawait ; -- next: wait read array
467
468 when s_rawait => -- s_rawait: wait read array
469 ibusy := '1'; -- signal busy, unable to handle req
470 imem_ce := '1'; -- ce CRAM next cycle
471 if unsigned(r.cntdly) = 0 then -- wait expired ?
472 n.state := s_idle; -- next: wait for req
473 end if;
474
475 when s_idle => -- s_idle: wait for req
476 if REQ = '1' then -- if IO requested
477 do_dispatch(n.state, iaddrh_ce, iaddr0_ce, iaddr0,
478 ibe_ce, imem_be, imem_ce, imem_oe, n.be2nd);
479 end if;
480
481 when s_rdinit => -- s_rdinit: read init cycle
482 ibusy := '1'; -- signal busy, unable to handle req
483 iactr := '1'; -- signal mem read
484 imem_ce := '1'; -- ce CRAM next cycle
485 imem_oe := '1'; -- oe CRAM next cycle
486 n.cntdly:= slv(to_unsigned(READ0DELAY-3, n.cntdly'length));
487 n.state := s_rdwait0; -- next: wait low word
488
489 when s_rdwait0 => -- s_rdwait0: read wait low word
490 ibusy := '1'; -- signal busy, unable to handle req
491 iactr := '1'; -- signal mem read
492 imem_ce := '1'; -- ce CRAM next cycle
493 imem_oe := '1'; -- oe CRAM next cycle
494 if unsigned(r.cntdly) = 0 then -- wait expired ?
495 n.state := s_rdget0; -- next: get low word
496 end if;
497
498 when s_rdget0 => -- s_rdget0: read get low word
499 ibusy := '1'; -- signal busy, unable to handle req
500 iactr := '1'; -- signal mem read
501 imem_ce := '1'; -- ce CRAM next cycle
502 imem_oe := '1'; -- oe CRAM next cycle
503 idata_cei := '1'; -- latch input data
504 iaddr0_ce := '1'; -- latch address 0 bit
505 iaddr0 := '1'; -- now go for high word
506 n.cntdly:= slv(to_unsigned(READ1DELAY-2, n.cntdly'length));
507 n.state := s_rdwait1; -- next: wait high word
508
509 when s_rdwait1 => -- s_rdwait1: read wait high word
510 ibusy := '1'; -- signal busy, unable to handle req
511 iactr := '1'; -- signal mem read
512 imem_ce := '1'; -- ce CRAM next cycle
513 imem_oe := '1'; -- oe CRAM next cycle
514 if unsigned(r.cntdly) = 0 then -- wait expired ?
515 n.state := s_rdget1; -- next: get high word
516 end if; --
517
518 when s_rdget1 => -- s_rdget1: read get high word
519 iactr := '1'; -- signal mem read
520 n.memdo0:= MEM_DO; -- save low word data
521 idata_cei := '1'; -- latch input data
522 n.ackr := '1'; -- ACK_R next cycle
523 n.state := s_idle; -- next: wait next request
524 if r.fidle = '1' then -- forced idle cycle
525 ibusy := '1'; -- signal busy, unable to handle req
526 else
527 if REQ = '1' then -- if IO requested
528 do_dispatch(n.state, iaddrh_ce, iaddr0_ce, iaddr0,
529 ibe_ce, imem_be, imem_ce, imem_oe, n.be2nd);
530 end if;
531 end if;
532
533 when s_wrinit => -- s_wrinit: write init cycle
534 ibusy := '1'; -- signal busy, unable to handle req
535 iactw := '1'; -- signal mem write
536 iackw := '1'; -- signal write done (all latched)
537 idata_ceo:= '1'; -- latch output data
538 idata_oe := '1'; -- oe FPGA next cycle
539 imem_ce := '1'; -- ce CRAM next cycle
540 imem_we := '1'; -- we CRAM in half cycle
541 n.cntdly:= slv(to_unsigned(WRITEDELAY-2, n.cntdly'length));
542 n.state := s_wrwait0; -- next: wait
543
544 when s_wrwait0 => -- s_rdput0: write wait 1st word
545 ibusy := '1'; -- signal busy, unable to handle req
546 iactw := '1'; -- signal mem write
547 idata_oe := '1'; -- oe FPGA next cycle
548 imem_ce := '1'; -- ce CRAM next cycle
549 imem_we := '1'; -- we CRAM next cycle
550 if unsigned(r.cntdly) = 0 then -- wait expired ?
551 n.state := s_wrput0; -- next: put 1st word
552 end if;
553
554 when s_wrput0 => -- s_rdput0: write put 1st word
555 iactw := '1'; -- signal mem write
556 imem_we := '0'; -- deassert we CRAM in half cycle
557 if r.be2nd /= "00" then
558 ibusy := '1'; -- signal busy, unable to handle req
559 imem_ce := '1'; -- ce CRAM next cycle
560 iaddr0_ce := '1'; -- latch address 0 bit
561 iaddr0 := '1'; -- now go for high word
562 ibe_ce := '1'; -- latch be's
563 imem_be := r.be2nd; -- now be's of high word
564 n.state := s_wrini1; -- next: start 2nd write
565 else
566 n.state := s_idle; -- next: wait next request
567 if r.fidle = '1' then -- forced idle cycle
568 ibusy := '1'; -- signal busy
569 else
570 if REQ = '1' then -- if IO requested
571 do_dispatch(n.state, iaddrh_ce, iaddr0_ce, iaddr0,
572 ibe_ce, imem_be, imem_ce, imem_oe, n.be2nd);
573 end if;
574 end if;
575 end if;
576
577 when s_wrini1 => -- s_wrini1: write init 2nd word
578 ibusy := '1'; -- signal busy, unable to handle req
579 iactw := '1'; -- signal mem write
580 idata_ceo:= '1'; -- latch output data
581 idata_oe := '1'; -- oe FPGA next cycle
582 imem_ce := '1'; -- ce CRAM next cycle
583 imem_we := '1'; -- we CRAM in half cycle
584 n.cntdly:= slv(to_unsigned(WRITEDELAY-2, n.cntdly'length));
585 n.state := s_wrwait1; -- next: wait
586
587 when s_wrwait1 => -- s_wrwait1: write wait 2nd word
588 ibusy := '1'; -- signal busy, unable to handle req
589 iactw := '1'; -- signal mem write
590 idata_oe := '1'; -- oe FPGA next cycle
591 imem_ce := '1'; -- ce CRAM next cycle
592 imem_we := '1'; -- we CRAM next cycle
593 if unsigned(r.cntdly) = 0 then -- wait expired ?
594 n.state := s_wrput1; -- next: put 2nd word
595 end if;
596
597 when s_wrput1 => -- s_wrput1: write put 2nd word
598 iactw := '1'; -- signal mem write
599 imem_we := '0'; -- deassert we CRAM in half cycle
600 n.state := s_idle; -- next: wait next request
601 if r.fidle = '1' then -- forced idle cycle
602 ibusy := '1'; -- signal busy, unable to handle req
603 else
604 if REQ = '1' then -- if IO requested
605 do_dispatch(n.state, iaddrh_ce, iaddr0_ce, iaddr0,
606 ibe_ce, imem_be, imem_ce, imem_oe, n.be2nd);
607 end if;
608 end if;
609
610 when others => null;
611 end case;
612
613 if imem_ce = '0' then -- if cmem not active
614 n.cntce := (others=>'0'); -- clear counter
615 n.fidle := '0'; -- clear force idle flag
616 else -- if cmem active
617 if unsigned(r.cntce) >= 127 then -- if max ce count expired
618 n.fidle := '1'; -- set forced idle flag
619 else -- if max ce count not yet reached
620 n.cntce := slv(unsigned(r.cntce) + 1); -- increment counter
621 end if;
622 end if;
623
624 if iaddrh_ce = '1' then -- if addresses are latched
625 n.memdi := DI; -- latch data too...
626 end if;
627
628 if iaddr0_ce = '1' then -- if address bit 0 changed
629 n.addr0 := iaddr0; -- mirror it in state regs
630 end if;
631
632 N_REGS <= n;
633
634 MEM_CE_N <= not imem_ce;
635 MEM_WE_N <= not imem_we;
636 MEM_BE_N <= not imem_be;
637 MEM_OE_N <= not imem_oe;
638 MEM_CRE <= imem_cre;
639
640 if r.addr0 = '0' then
641 MEM_DI <= r.memdi(15 downto 0);
642 else
643 MEM_DI <= r.memdi(31 downto 16);
644 end if;
645
646 BE_CE <= ibe_ce;
647 ADDRH_CE <= iaddrh_ce;
648 ADDR0_CE <= iaddr0_ce;
649 ADDRH <= iaddrh;
650 ADDR0 <= iaddr0;
651 DATA_CEI <= idata_cei;
652 DATA_CEO <= idata_ceo;
653 DATA_OE <= idata_oe;
654
655 BUSY <= ibusy;
656 ACK_R <= r.ackr;
657 ACK_W <= iackw;
658 ACT_R <= iactr;
659 ACT_W <= iactw;
660
661 DO <= MEM_DO & r.memdo0;
662
663 end process proc_next;
664
665end syn;
in CEO slbit := '1'
in CEI slbit := '1'
PULL string := "NONE"
inout PAD slv( DWIDTH- 1 downto 0)
in DO slv( DWIDTH- 1 downto 0)
out DI slv( DWIDTH- 1 downto 0)
DWIDTH positive := 16
in CE slbit := '1'
out PAD slv( DWIDTH- 1 downto 0)
INIT slbit := '0'
in CLK slbit
in DO slv( DWIDTH- 1 downto 0)
DWIDTH positive := 16
in CE slbit := '1'
Definition: iob_reg_o.vhd:30
out PAD slbit
Definition: iob_reg_o.vhd:33
INIT slbit := '0'
Definition: iob_reg_o.vhd:27
in CLK slbit
Definition: iob_reg_o.vhd:29
in DO slbit
Definition: iob_reg_o.vhd:31
regs_type :=( s_init, '0', '0', "00",( others => '0'),( others => '0'), '0',( others => '0'),( others => '0')) regs_init
do_dispatchpnstate,piaddrh_ce,piaddr0_ce,piaddr0,pibe_ce,pimem_be,pimem_ce,pimem_oe,pnbe2nd,
slv22 := "000"& "00"& "0000000000"& '1'& "00"& '1'& "000" c_addrh_rcr_setup
slv16 :=( others => '0') MEM_DO
slv22 :=( others => '0') ADDRH
regs_type := regs_init R_REGS
(s_init,s_init1,s_wcinit,s_wcwait,s_wcput,s_rainit,s_rawait,s_idle,s_rdinit,s_rdwait0,s_rdget0,s_rdwait1,s_rdget1,s_wrinit,s_wrwait0,s_wrput0,s_wrini1,s_wrwait1,s_wrput1) state_type
slv16 :=( others => '0') MEM_DI
READ0DELAY positive := 4
WRITEDELAY positive := 4
inout IO_MEM_DATA slv16
READ1DELAY positive := 2
std_logic_vector( 22 downto 0) slv23
Definition: slvtypes.vhd:56
std_logic_vector( 3 downto 0) slv4
Definition: slvtypes.vhd:36
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( 31 downto 0) slv32
Definition: slvtypes.vhd:59
std_logic_vector( 15 downto 0) slv16
Definition: slvtypes.vhd:48
std_logic_vector( 21 downto 0) slv22
Definition: slvtypes.vhd:55
std_logic slbit
Definition: slvtypes.vhd:30
std_logic_vector( 1 downto 0) slv2
Definition: slvtypes.vhd:34
std_logic_vector slv
Definition: slvtypes.vhd:31
Definition: xlib.vhd:35