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

📄 alt_cusp72_muxhot32.vhd

📁 nios里面用自定义指令集来实现三角函数
💻 VHD
字号:
-- alt_cusp72_muxhot32.vhd

library ieee, altera;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use std.textio.all;
use altera.alt_cusp72_package.all;

entity alt_cusp72_muxhot32 is
    generic (
        NAME    : string := "";
        PORTS   : integer := 32;
        WIDTH   : integer := 16
    );
    port (
        sel     : in  std_logic_vector(PORTS-1 downto 0) := (others => '0');
        data0   : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data1   : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data2   : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data3   : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data4   : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data5   : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data6   : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data7   : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data8   : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data9   : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data10  : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data11  : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data12  : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data13  : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data14  : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data15  : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data16  : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data17  : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data18  : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data19  : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data20  : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data21  : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data22  : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data23  : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data24  : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data25  : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data26  : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data27  : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data28  : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data29  : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data30  : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        data31  : in  std_logic_vector(WIDTH-1 downto 0) := (others => '0');
        q       : out std_logic_vector(WIDTH-1 downto 0)
    );
end entity;


architecture rtl of alt_cusp72_muxhot32 is
    signal masks : STD_LOGIC_VECTOR(32 downto 0);
begin
    assert PORTS <= 32
        report "PORTS generic must be 32 or less"
        severity ERROR;

    unused_mask_gen: masks(32 downto PORTS) <= (others=>'0');
	used_mask_gen:   masks(PORTS-1 downto 0) <= sel;

with masks select
    q <= data0   when "000000000000000000000000000000001",
         data1   when "000000000000000000000000000000010",
         data2   when "000000000000000000000000000000100",
         data3   when "000000000000000000000000000001000",
         data4   when "000000000000000000000000000010000",
         data5   when "000000000000000000000000000100000",
         data6   when "000000000000000000000000001000000",
         data7   when "000000000000000000000000010000000",
         data8   when "000000000000000000000000100000000",
         data9   when "000000000000000000000001000000000",
         data10  when "000000000000000000000010000000000",
         data11  when "000000000000000000000100000000000",
         data12  when "000000000000000000001000000000000",
         data13  when "000000000000000000010000000000000",
         data14  when "000000000000000000100000000000000",
         data15  when "000000000000000001000000000000000",
         data16  when "000000000000000010000000000000000",
         data17  when "000000000000000100000000000000000",
         data18  when "000000000000001000000000000000000",
         data19  when "000000000000010000000000000000000",
         data20  when "000000000000100000000000000000000",
         data21  when "000000000001000000000000000000000",
         data22  when "000000000010000000000000000000000",
         data23  when "000000000100000000000000000000000",
         data24  when "000000001000000000000000000000000",
         data25  when "000000010000000000000000000000000",
         data26  when "000000100000000000000000000000000",
         data27  when "000001000000000000000000000000000",
         data28  when "000010000000000000000000000000000",
         data29  when "000100000000000000000000000000000",
         data30  when "001000000000000000000000000000000",
         data31  when "010000000000000000000000000000000",
         (others => '0') when "000000000000000000000000000000000",
         (others => 'X') when others;

end architecture;

⌨️ 快捷键说明

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