本帖最后由 scan0123 于 2012-8-18 13:55 编辑
如图,为什么该编译图标是灰 {MOD}的?
如何把vhdl代码转换成图形文件?
该文件为何无法编译成功?
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
en
tity Multiplier is
generic (
DATA_WIDTH : natural := 4
);
port (
reset_n : in std_logic;
clk : in std_logic;
InputX : in std_logic_vector(DATA_WIDTH-1 downto 0);
InputY : in std_logic_vector(DATA_WIDTH-1 downto 0);
Cal : in std_logic;
Result : out std_logic_vector(DATA_WIDTH*2-1 downto 0)
);
end Multiplier;
architecture Multiplier_arch of Multiplier is
type MUL_DATA_ARRAY_TYPE is array (DATA_WIDTH-1 downto 0) of std_logic_vector(DATA_WIDTH*2-1 downto 0);
signal mulDataArray : MUL_DATA_ARRAY_TYPE;
begin
mulDataArray_gen : for I in 0 to DATA_WIDTH-1 generate
mulDataArray(I)(DATA_WIDTH*2-1 downto DATA_WIDTH+I) <= (others => '0');
mulDataArray(I)(DATA_WIDTH+I-1 downto I) <= InputX when InputY(I) = '1' else (others => '0');
mulDataArray(I)(I-1 downto 0) <= (others => '0');
end generate;
process(reset_n, clk)
variable resultTmp : std_logic_vector(DATA_WIDTH*2-1 downto 0);
begin
if reset_n = '0' then
Result <= (others => '0');
elsif rising_edge(clk) then
resultTmp := mulDataArray(0);
for I in 1 to DATA_WIDTH-1 loop
resultTmp := resultTmp + mulDataArray(I);
end loop;
if Cal='1' then
Result <= resultTmp;
end if;
end if;
end process;
end Multiplier_arch;
-
一周热门 更多>