📄 icache_gti.vhd
字号:
--------------------------------------------------------------------------------- $Id: icache_gti.vhd,v 1.4 2007/12/13 13:56:42 stefana Exp $--------------------------------------------------------------------------------- icache_gti.vhd - Entity and architecture---- ***************************************************************************-- ** Copyright(C) 2005 by Xilinx, Inc. All rights reserved. **-- ** **-- ** This text contains proprietary, confidential **-- ** information of Xilinx, Inc. , is distributed by **-- ** under license from Xilinx, Inc., and may be used, **-- ** copied and/or disclosed only pursuant to the terms **-- ** of a valid license agreement with Xilinx, Inc. **-- ** **-- ** Unmodified source code is guaranteed to place and route, **-- ** function and run at speed according to the datasheet **-- ** specification. Source code is provided "as-is", with no **-- ** obligation on the part of Xilinx to provide support. **-- ** **-- ** Xilinx Hotline support of source code IP shall only include **-- ** standard level Xilinx Hotline support, and will only address **-- ** issues and questions related to the standard released Netlist **-- ** version of the core (and thus indirectly, the original core source). **-- ** **-- ** The Xilinx Support Hotline does not have access to source **-- ** code and therefore cannot answer specific questions related **-- ** to source HDL. The Xilinx Support Hotline will only be able **-- ** to confirm the problem in the Netlist version of the core. **-- ** **-- ** This copyright and support notice must be retained as part **-- ** of this text at all times. **-- ***************************************************************************----------------------------------------------------------------------------------- Filename: icache_gti.vhd---- Description: -- -- VHDL-Standard: VHDL'93--------------------------------------------------------------------------------- Structure: -- icache_gti.vhd----------------------------------------------------------------------------------- Author: goran-- Revision: $Revision: 1.4 $-- Date: $Date: 2007/12/13 13:56:42 $---- History:-- goran 2005-09-28 First Version----------------------------------------------------------------------------------- Naming Conventions:-- active low signals: "*_n"-- clock signals: "clk", "clk_div#", "clk_#x" -- reset signals: "rst", "rst_n" -- generics: "C_*" -- user defined types: "*_TYPE" -- state machine next state: "*_ns" -- state machine current state: "*_cs" -- combinatorial signals: "*_com" -- pipelined or register delay signals: "*_d#" -- counter signals: "*cnt*"-- clock enable signals: "*_ce" -- internal version of output port "*_i"-- device pins: "*_pin" -- ports: - Names begin with Uppercase -- processes: "*_PROCESS" -- component instantiations: "<ENTITY_>I_<#|FUNC>-------------------------------------------------------------------------------library ieee;use ieee.std_logic_1164.all;use ieee.numeric_std.all;library Microblaze_v7_10_a;use Microblaze_v7_10_a.MicroBlaze_Types.all;use Microblaze_v7_10_a.MicroBlaze_ISA.all;-- pragma xilinx_rtl_offlibrary unisim;use unisim.vcomponents.all;-- pragma xilinx_rtl_on--------------------------------------------------------------------------------- Port declarations-------------------------------------------------------------------------------entity ICache_gti is generic ( C_TARGET : TARGET_FAMILY_TYPE; C_DATA_SIZE : natural := 32; C_ICACHE_BASEADDR : std_logic_vector(0 to 31) := X"00000000"; C_ICACHE_HIGHADDR : std_logic_vector(0 to 31) := X"3FFFFFFF"; C_CACHELINE_SIZE : natural := 4; C_ALLOW_ICACHE_WR : integer := 0; C_ADDR_TAG_BITS : natural := 9; C_CACHE_BYTE_SIZE : natural := 8*1024; C_USE_MMU : integer := 0; C_ICACHE_ALWAYS_USED : integer := 0 ); port ( -- global signals Clk : in std_logic; Reset : in std_logic; -- Local Bus signals IB_Tag_Addr : in std_logic_vector(0 to C_DATA_SIZE-1); IB_Tag_Addr_Strobe : in std_logic; IB_Addr : in std_logic_vector(0 to C_DATA_SIZE-1); IB_Addr_Strobe : in std_logic; IB_TLB_Addr_MMU : in std_logic_vector(0 to C_DATA_SIZE-1); IB_TLB_Addr_Strobe : in std_logic; IB_Cache_Addr_MMU : in std_logic_vector(0 to C_DATA_SIZE-1); IB_Valid_TLB_Addr : in std_logic; IB_VMode : in std_logic; MEM_PID : in std_logic_vector(0 to 7); ICACHE_Data_Strobe : out std_logic; ICACHE_Drop_Request : out std_logic; ICACHE_Data : out std_logic_vector(0 to C_DATA_SIZE-1); ICACHE_Idle : out boolean; ICACHE_Valid_Req : out boolean; ICACHE_Req_Prev : out std_logic; ICACHE_Valid_Addr : out std_logic; -- Control signals ICache_Enabled : in std_logic; WB_fwd : in std_logic_vector(0 to C_DATA_SIZE-1); Write_ICache : in boolean; IF_ICache_Inhibit : in std_logic; IB_Block_Ready_MMU : in std_logic; -- Trace signals Trace_ICache_Req : out std_logic; Trace_ICache_Hit : out std_logic; -- FSL signals ICACHE_FSL_IN_Clk : out std_logic; ICACHE_FSL_IN_Read : out std_logic; ICACHE_FSL_IN_Data : in std_logic_vector(0 to 31); ICACHE_FSL_IN_Control : in std_logic; ICACHE_FSL_IN_Exists : in std_logic; ICACHE_FSL_OUT_Clk : out std_logic; ICACHE_FSL_OUT_Write : out std_logic; ICACHE_FSL_OUT_Data : out std_logic_vector(0 to 31); ICACHE_FSL_OUT_Control : out std_logic; ICACHE_FSL_OUT_Full : in std_logic );end entity ICache_gti;--------------------------------------------------------------------------------- Architecture section-------------------------------------------------------------------------------architecture IMP of ICache_gti is constant C_LUT6_OPTIMIZED : boolean := ( C_TARGET = VIRTEX5 ); component comparator is generic ( C_TARGET : TARGET_FAMILY_TYPE; C_IS_FIRST : boolean; C_SIZE : natural); port ( Carry_IN : in std_logic; DI : in std_logic; A : in std_logic_vector(0 to C_SIZE-1); B : in std_logic_vector(0 to C_SIZE-1); Carry_OUT : out std_logic); end component comparator; component carry_and is generic ( C_TARGET : TARGET_FAMILY_TYPE); port ( Carry_IN : in std_logic; A : in std_logic; Carry_OUT : out std_logic); end component carry_and; component carry_or is generic ( C_TARGET : TARGET_FAMILY_TYPE); port ( Carry_IN : in std_logic; A : in std_logic; Carry_OUT : out std_logic); end component carry_or; component RAM_Module is generic ( C_TARGET : TARGET_FAMILY_TYPE; C_DATA_WIDTH : natural range 1 to 36; C_ADDR_WIDTH : natural range 1 to 14; C_FORCE_BRAM : boolean); port ( -- PORT A CLKA : in std_logic; WEA : in std_logic_vector(0 to 3); -- Assume byte write handling ENA : in std_logic; ADDRA : in std_logic_vector(0 to C_ADDR_WIDTH-1); DATA_INA : in std_logic_vector(0 to C_DATA_WIDTH-1); DATA_OUTA : out std_logic_vector(0 to C_DATA_WIDTH-1); -- PORT B CLKB : in std_logic; WEB : in std_logic_vector(0 to 3); -- Assume byte write handling ENB : in std_logic; ADDRB : in std_logic_vector(0 to C_ADDR_WIDTH-1); DATA_INB : in std_logic_vector(0 to C_DATA_WIDTH-1); DATA_OUTB : out std_logic_vector(0 to C_DATA_WIDTH-1)); end component RAM_Module; function log2(x : natural) return integer is variable i : integer := 0; begin if x = 0 then return 0; else while 2**i < x loop i := i+1; end loop; return i; end if; end function log2; function Addr_Bits (x, y : std_logic_vector(0 to 31)) return integer is variable addr_nor : std_logic_vector(0 to 31); begin addr_nor := x xor y; for i in 0 to 31 loop if addr_nor(i) = '1' then return i; end if; end loop; return(32); end function Addr_Bits; constant C_VALID_ADDR_BITS : integer := Addr_Bits(C_ICACHE_HIGHADDR, C_ICACHE_BASEADDR); constant C_MMU_BITS : integer := 9; function calc_addr_tag_bits return natural is variable temp : integer; begin -- function calc_addr_tag_bits if (C_ADDR_TAG_BITS /= 0) and (C_USE_MMU /= C_MMU_VIRTUAL) then return C_ADDR_TAG_BITS; else if C_USE_MMU = C_MMU_VIRTUAL then -- The number of needed address tag bits is the full 32 bit address -- minus the number of bits of the cache size since it's direct mapped and -- plus the number of bits used for MMU bits temp := 32 - log2(C_CACHE_BYTE_SIZE) + C_MMU_BITS; else -- The number of needed address tag bits is the full 32 bit address -- minus the number of bits of the cache size since it's direct mapped and -- minus the number of bits outside the cacheable address range temp := 32 - log2(C_CACHE_BYTE_SIZE) - C_VALID_ADDR_BITS; end if; if (temp > 0) then return temp; elsif (temp = 0) then -- Enforce a tag size of at least 1, otherwise the code breaks return 1; else assert false report "Too large instruction cache for the selected cacheable address range" severity failure; return 1; end if; end if; end function calc_addr_tag_bits; constant NO_ADDR_TAG_BITS : natural := calc_addr_tag_bits;--------------------------------------------------------------------------------- Begin architecture------------------------------------------------------------------------------- -- Overall Cache constants constant CACHELINE_BITS : natural := log2(C_CACHELINE_SIZE); -- Calculate Tag types constant Tag_Word_Size : natural := C_CACHELINE_SIZE + 1 + NO_ADDR_TAG_BITS; constant Nr_Of_Tag_Words : natural := (C_CACHE_BYTE_SIZE)/(C_CACHELINE_SIZE*4); constant Tag_Addr_Size : natural := log2(Nr_Of_Tag_Words); subtype TAG_ADDR_TYPE is std_logic_vector(0 to Tag_Addr_Size-1); subtype TAG_WORD_TYPE is std_logic_vector(0 to Tag_Word_Size-1); constant null_tag_word : TAG_WORD_TYPE := (others => '0');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -