我在VHDL中很新,我有一个简单的问题。我有一个MAC (乘法和累积)实体,其中包含两个组件:‘乘子’和'add_sub_n‘。我希望MAC得到两个输入a,b,乘以它们,并将它们添加到以前使用Mac时的旧结果中。这是我的代码:
-- libraries decleration
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity MAC is
port (a : in std_logic_vector(N-1 downto 0);
b : in std_logic_vector(N-1 downto 0);
mac : in std_logic_vector(N-1 downto 0);
s : out std_logic_vector(N-1 downto 0);
end MAC;
architecture MAC_Logic of MAC is
component Multiplier is
port(
a,b : in std_logic_vector(N-1 downto 0);
c : out std_logic_vector(N-1 downto 0));
end component;
component Add_Sub_N is
port(
a,b : in std_logic_vector(N-1 downto 0);
sub : in std_logic;
cout : out std_logic;
s : out std_logic_vector(N-1 downto 0));
end component;
signal temp1 : std_logic;
begin
mul : Multiplier
port map(a=>a, b=>b, c=>temp1);
addsub : Add_Sub_N
port map(a=>temp1, b=>mac, sub=>0, cout=>cout, s=>s);
end MAC_Logic;我被困住了。如果有人能帮忙,我会很感激的。谢谢!
发布于 2014-04-25 15:34:08
您有以下操作要执行:
m = a * b
acc' = m + acc
acc = acc'其中acc‘是要存储在累加器中的新值。您的代码有用于乘法和添加的实体,但没有描述实现累加器的寄存器。累加器寄存器向加法器提供第二输入。只有在新产品可用时,才需要一个控制输入来启用对累加器的写入。
https://stackoverflow.com/questions/23296418
复制相似问题