URL
https://opencores.org/ocsvn/xucpu/xucpu/trunk
[/] [xucpu/] [trunk/] [src/] [components/] [BRAM/] [cache_block.vhdl] - Blame information for rev 30
Details |
Compare with Previous |
View Log
Line No. |
Rev |
Author |
Line |
1 |
30 |
lcdsgmtr |
LIBRARY ieee;
|
2 |
|
|
USE ieee.std_logic_1164.ALL;
|
3 |
|
|
USE ieee.numeric_std.ALL;
|
4 |
|
|
|
5 |
|
|
ENTITY cache_block IS
|
6 |
|
|
|
7 |
|
|
-- Cache memory block of 512x16
|
8 |
|
|
GENERIC (
|
9 |
|
|
w_data : NATURAL RANGE 1 TO 32 := 16;
|
10 |
|
|
w_addr : NATURAL RANGE 8 TO 14 := 9);
|
11 |
|
|
PORT (
|
12 |
|
|
clk : IN STD_LOGIC;
|
13 |
|
|
we : IN STD_LOGIC;
|
14 |
|
|
a1 : IN STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0); -- Data port address
|
15 |
|
|
a2 : IN STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0); -- Instruction port address
|
16 |
|
|
d1 : IN STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0); -- Data port input
|
17 |
|
|
q1 : OUT STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0); -- Data port output
|
18 |
|
|
q2 : OUT STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0)); -- Instruction port output
|
19 |
|
|
|
20 |
|
|
END cache_block;
|
21 |
|
|
|
22 |
|
|
ARCHITECTURE Behavioral OF cache_block IS
|
23 |
|
|
|
24 |
|
|
SIGNAL address_reg_1 : STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0);
|
25 |
|
|
SIGNAL address_reg_2 : STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0);
|
26 |
|
|
|
27 |
|
|
BEGIN -- Behavioral
|
28 |
|
|
|
29 |
|
|
-- purpose: Try to describe a proper block ram without needing to instantiate a BRAM
|
30 |
|
|
-- type : sequential
|
31 |
|
|
-- inputs : clk, we, a1, a2, d1
|
32 |
|
|
-- outputs: q1, q2
|
33 |
|
|
MP1 : PROCESS (clk, address_reg_1, address_reg_2, mem)
|
34 |
|
|
BEGIN -- PROCESS MP1
|
35 |
|
|
|
36 |
|
|
-- Reading
|
37 |
|
|
q1 <= STD_LOGIC_VECTOR(to_unsigned(mem(to_integer(UNSIGNED(address_reg_1))), w_data));
|
38 |
|
|
q2 <= STD_LOGIC_VECTOR(to_unsigned(mem(to_integer(UNSIGNED(address_reg_2))), w_data));
|
39 |
|
|
IF rising_edge(clk) THEN -- rising clock edge
|
40 |
|
|
|
41 |
|
|
-- These work like the block RAM registers
|
42 |
|
|
address_reg_1 <= a1;
|
43 |
|
|
address_reg_2 <= a2;
|
44 |
|
|
|
45 |
|
|
-- Writing
|
46 |
|
|
IF we = '1' THEN
|
47 |
|
|
mem(to_integer(UNSIGNED(a1))) <= to_integer(UNSIGNED(d1));
|
48 |
|
|
END IF;
|
49 |
|
|
|
50 |
|
|
END IF;
|
51 |
|
|
|
52 |
|
|
END PROCESS MP1;
|
53 |
|
|
|
54 |
|
|
END Behavioral;
|
© copyright 1999-2025
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.