⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tech_generic.vhd

📁 ARM7的源代码
💻 VHD
📖 第 1 页 / 共 2 页
字号:
-- pragma translate_off  comb : process(rdaddress, rfd)  begin    if not (is_x(rdaddress) or (conv_integer(unsigned(rdaddress)) >= words))    then-- pragma translate_on      q <= rfd(conv_integer(unsigned(rdaddress)));-- pragma translate_off    else      q <= (others => 'X');    end if;  end process;-- pragma translate_onend;-- Bypass logic for async regfiles with delayed (synchronous) write-- Bypass written data to read port if write enabled-- and read and write address are equal.library IEEE;use IEEE.std_logic_1164.all;use work.leon_iface.all;entity rfbypass is  generic (    abits : integer := 8;    dbits : integer := 32  );  port (    clk   : in clk_type;    write : in std_logic;    datain: in std_logic_vector (dbits -1 downto 0);    raddr1: in std_logic_vector (abits -1 downto 0);    raddr2: in std_logic_vector (abits -1 downto 0);    waddr : in std_logic_vector (abits -1 downto 0);    q1    : in std_logic_vector (dbits -1 downto 0);    q2    : in std_logic_vector (dbits -1 downto 0);    dataout1 : out std_logic_vector (dbits -1 downto 0);    dataout2 : out std_logic_vector (dbits -1 downto 0)  );end;architecture rtl of rfbypass is type wbypass_type is record  wraddr  : std_logic_vector(abits-1 downto 0);  wrdata  : std_logic_vector(dbits-1 downto 0);  wren    : std_logic;end record;signal wbpr : wbypass_type;begin     wbp_comb : process(q1, q2, wbpr, raddr1, raddr2)    begin      if (wbpr.wren = '1') and (wbpr.wraddr = raddr1)   then 	dataout1 <= wbpr.wrdata;      else dataout1 <= q1(dbits-1 downto 0); end if;      if (wbpr.wren = '1') and (wbpr.wraddr = raddr2)   then 	dataout2 <= wbpr.wrdata;      else dataout2 <= q2(dbits-1 downto 0); end if;    end process;    wbp_reg : process(clk)    begin      if rising_edge(clk) then 	wbpr.wraddr <= waddr; 	wbpr.wrdata <= datain; 	wbpr.wren <= write;       end if;    end process;end;---------------------------------------------------------------------- regfile generators---------------------------------------------------------------------- integer unit regfileLIBRARY ieee;use IEEE.std_logic_1164.all;use work.leon_config.all;use work.leon_iface.all;entity generic_regfile_iu is  generic (     rftype : integer := 1;    abits : integer := 8; dbits : integer := 32; words : integer := 128  );  port (    rst      : in std_logic;    clk      : in std_logic;    clkn     : in std_logic;    rfi      : in rf_in_type;    rfo      : out rf_out_type);end;architecture rtl of generic_regfile_iu is  component generic_dpram_ss  generic (    abits : integer := 8;    dbits : integer := 32;    words : integer := 256  );  port (    clk : in std_logic;    rdaddress: in std_logic_vector (abits -1 downto 0);    wraddress: in std_logic_vector (abits -1 downto 0);    data: in std_logic_vector (dbits -1 downto 0);    wren : in std_logic;    q: out std_logic_vector (dbits -1 downto 0)  );  end component;  component generic_dpram_as  generic (    abits : integer := 8;    dbits : integer := 32;    words : integer := 256  );  port (    clk : in std_logic;    rdaddress: in std_logic_vector (abits -1 downto 0);    wraddress: in std_logic_vector (abits -1 downto 0);    data: in std_logic_vector (dbits -1 downto 0);    wren : in std_logic;    q: out std_logic_vector (dbits -1 downto 0)  );  end component;  component rfbypass  generic (    abits : integer := 8;    dbits : integer := 32  );  port (    clk   : in clk_type;    write : in std_logic;    datain: in std_logic_vector (dbits -1 downto 0);    raddr1: in std_logic_vector (abits -1 downto 0);    raddr2: in std_logic_vector (abits -1 downto 0);    waddr : in std_logic_vector (abits -1 downto 0);    q1    : in std_logic_vector (dbits -1 downto 0);    q2    : in std_logic_vector (dbits -1 downto 0);    dataout1 : out std_logic_vector (dbits -1 downto 0);    dataout2 : out std_logic_vector (dbits -1 downto 0)  );  end component;signal qq1, qq2  : std_logic_vector (dbits -1 downto 0);begin  rfss : if rftype = 1 generate    u0 : generic_dpram_ss        generic map (abits => abits, dbits => dbits, words => words)       port map (clk => clkn, rdaddress => rfi.rd1addr, wraddress => rfi.wraddr,	         data => rfi.wrdata, wren => rfi.wren, q => rfo.data1);    u1 : generic_dpram_ss        generic map (abits => abits, dbits => dbits, words => words)       port map (clk => clkn, rdaddress => rfi.rd2addr, wraddress => rfi.wraddr,	         data => rfi.wrdata, wren => rfi.wren, q => rfo.data2);  end generate;  rfas : if rftype = 2 generate    u0 : generic_dpram_as        generic map (abits => abits, dbits => dbits, words => words)       port map (clk => clk, rdaddress => rfi.rd1addr, wraddress => rfi.wraddr,	         data => rfi.wrdata, wren => rfi.wren, q => rfo.data1);    u1 : generic_dpram_as        generic map (abits => abits, dbits => dbits, words => words)       port map (clk => clk, rdaddress => rfi.rd2addr, wraddress => rfi.wraddr,	         data => rfi.wrdata, wren => rfi.wren, q => rfo.data2);  end generate;end;-- co-processor regfile-- synchronous operation without write-through supportLIBRARY ieee;use IEEE.std_logic_1164.all;use work.leon_config.all;use work.leon_iface.all;entity generic_regfile_cp is  generic (     abits : integer := 4; dbits : integer := 32; words : integer := 16  );  port (    rst      : in std_logic;    clk      : in std_logic;    rfi      : in rf_cp_in_type;    rfo      : out rf_cp_out_type);end;architecture rtl of generic_regfile_cp is  component generic_dpram_ss  generic (    abits : integer := 8;    dbits : integer := 32;    words : integer := 256  );  port (    clk : in std_logic;    rdaddress: in std_logic_vector (abits -1 downto 0);    wraddress: in std_logic_vector (abits -1 downto 0);    data: in std_logic_vector (dbits -1 downto 0);    wren : in std_logic;    q: out std_logic_vector (dbits -1 downto 0)  );  end component;begin    u0 : generic_dpram_ss        generic map (abits => abits, dbits => dbits, words => words)       port map (clk => clk, rdaddress => rfi.rd1addr, wraddress => rfi.wraddr,	         data => rfi.wrdata, wren => rfi.wren, q => rfo.data1);    u1 : generic_dpram_ss        generic map (abits => abits, dbits => dbits, words => words)       port map (clk => clk, rdaddress => rfi.rd2addr, wraddress => rfi.wraddr,	         data => rfi.wrdata, wren => rfi.wren, q => rfo.data2);end;-------------------------------------------------------------------- multiplier ----------------------------------------------------------------------------------------------------------------------library IEEE;use IEEE.std_logic_1164.all;use IEEE.std_logic_arith.all;entity generic_smult is  generic ( abits : integer := 10; bbits : integer := 8 );  port (    a    : in  std_logic_vector(abits-1 downto 0);    b    : in  std_logic_vector(bbits-1 downto 0);    c    : out std_logic_vector(abits+bbits-1 downto 0)  ); end; architecture rtl of generic_smult isbegin   m: process(a, b)  variable w : std_logic_vector(abits+bbits-1 downto 0);  begin-- pragma translate_off    if is_x(a) or is_x(b) then      w := (others => 'X');    else-- pragma translate_on      w := std_logic_vector'(signed(a) * signed(b));  --'-- pragma translate_off    end if;-- pragma translate_on    c <= w;  end process;end;-------------------------------------------------------------------- generic clock generator ---------------------------------------------------------------------------------------------------------library IEEE;use IEEE.std_logic_1164.all;use work.leon_target.all;use work.leon_iface.all;use work.leon_config.all;entity generic_clkgen isport (    clkin   : in  std_logic;    pciclkin: in  std_logic;    clk     : out std_logic;			-- main clock    clkn    : out std_logic;			-- inverted main clock    sdclk   : out std_logic;			-- SDRAM clock    pciclk  : out std_logic;			-- PCI clock    cgi     : in clkgen_in_type;    cgo     : out clkgen_out_type);end;architecture rtl of generic_clkgen issignal pciclk_actel : clk_type;begin  pciclk_actel <= pciclkin after 1 ns; -- need this to stay synced with Actel core  cgo.clklock <= '1'; cgo.pcilock <= '1';  cp : process (pciclk_actel, clkin, pciclkin)  begin    if PCI_SYSCLK then      clk <= pciclk_actel; clkn <= not pciclk_actel; pciclk <= pciclk_actel;      if SDINVCLK then sdclk <= not pciclk_actel; else sdclk <= pciclk_actel; end if;    else      clk <= clkin; clkn <= not clkin; pciclk <= pciclkin;      if SDINVCLK then sdclk <= not clkin; else sdclk <= clkin; end if;    end if;  end process;end;-------------------------------------------------------------------- behavioural pad models ---------------------------------------------------------------------------------------------------------------- input padlibrary IEEE;use IEEE.std_logic_1164.all;entity geninpad is port (pad : in std_logic; q : out std_logic); end; architecture rtl of geninpad is begin q <= to_x01(pad); end;-- input schmitt padlibrary IEEE;use IEEE.std_logic_1164.all;entity gensmpad is port (pad : in std_logic; q : out std_logic); end; architecture rtl of gensmpad is begin q <= to_x01(pad); end;-- output padlibrary IEEE;use IEEE.std_logic_1164.all;entity genoutpad is port (d : in  std_logic; pad : out  std_logic); end; architecture rtl of genoutpad is begin pad <= to_x01(d) after 2 ns; end;-- tri-state outpad with pull-up padlibrary IEEE;use IEEE.std_logic_1164.all;entity gentoutpadu is port (d, en : in std_logic; pad : out std_logic); end; architecture rtl of gentoutpadu isbegin pad <= to_x01(d) after 2 ns when en = '0' else 'H' after 2 ns; end;-- bidirectional padlibrary IEEE;use IEEE.std_logic_1164.all;entity geniopad is  port ( d, en : in std_logic; q : out std_logic; pad : inout std_logic);end; architecture rtl of geniopad isbegin pad <= to_x01(d) after 2 ns when en = '0' else 'Z' after 2 ns; q <= to_x01(pad); end;-- bidirectional open-drain padlibrary IEEE;use IEEE.std_logic_1164.all;entity geniodpad is  port ( d : in std_logic; q : out std_logic; pad : inout std_logic);end; architecture rtl of geniodpad isbegin pad <= '0' after 2 ns when d = '0' else 'Z' after 2 ns; q <= to_x01(pad); end;-- open-drain padlibrary IEEE;use IEEE.std_logic_1164.all;entity genodpad is port ( d : in std_logic; pad : out std_logic); end; architecture rtl of genodpad is begin pad <= '0' after 2 ns when d = '0' else 'Z'; end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -