0

我正在尝试使用 Xilinx 中的 Core Gen实现签名累加器。根据我的理解,累加器执行普通寄存器的功能,它只是将输入路由到输出,但我想澄清一下。

我将 Accumulator IPcore (.xco) 模块添加到项目中,并且我有一个主要包含组件声明和端口映射的主文件。我也有一个单步过程。一切都编译了,我可以在板上看到结果,但不太明白发生了什么......

当我输入1000LED 上的 8 位输出时11111000。的另一个输入1111给了我11110111。我在此处为调用的主 vhd 文件Accm.vho文件附加了代码。

----------------------------------------------------------------------------------

----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;

-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity Accm is
port( b: in std_logic_vector(3 downto 0);
        sclr, clk, b1, b2 : in std_logic;
        q : out std_logic_vector(7 downto 0)
);      

end Accm;

architecture Behavioral of Accm is

-- signal declaration
type tell is (rdy,pulse,not_rdy);
signal d_n_s: tell; 
signal en: std_logic;

-- component declaration
COMPONENT my_accm
  PORT (
    b : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
    clk : IN STD_LOGIC;
    sclr : IN STD_LOGIC;
    q : OUT STD_LOGIC_VECTOR(7 DOWNTO 0)
  );
END COMPONENT;

-- port map
begin

A1 : my_accm
  PORT MAP (
    b => b,
    clk => en,
    sclr => sclr,
    q => q
  );

process(clk)
begin
if clk'event and clk='1' then
case d_n_s is
when rdy => en <= '0';
if b1='1' then d_n_s <= pulse; end if;
when pulse => en <= '1';
d_n_s <= not_rdy;
when not_rdy => en <='0';
if b2='1' then d_n_s <= rdy; end if;
end case;
end if;
end process;

-- .VHO CODE

------------- Begin Cut here for COMPONENT Declaration ------ COMP_TAG
COMPONENT my_accm
  PORT (
    b : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
    clk : IN STD_LOGIC;
    sclr : IN STD_LOGIC;
    q : OUT STD_LOGIC_VECTOR(7 DOWNTO 0)
  );
END COMPONENT;
-- COMP_TAG_END ------ End COMPONENT Declaration ------------

-- The following code must appear in the VHDL architecture
-- body. Substitute your own instance name and net names.

------------- Begin Cut here for INSTANTIATION Template ----- INST_TAG
your_instance_name : my_accm
  PORT MAP (
    b => b,
    clk => clk,
    sclr => sclr,
    q => q
  );

end Behavioral;

我还粘贴了我在 CoreGen 中生成的累加器的图像。在此处输入图像描述

如果有人能向我解释这个程序中发生了什么,我将不胜感激。谢谢!

4

2 回答 2

3

“累加器”可能意味着很多东西。在硬件 Xilinx 库中,您实例化的组件是寄存器前面的加法器。加法器将累加器寄存器的当前值与输入项相加。累加器寄存器比输入宽,因此您可以累加(相加)许多输入项而不会溢出输出。

当您的电路启动时,累加器包含零。您输入 1000 (-8) ,当添加到零时,输出将变为 11111000(-8 符号扩展)。然后添加 1111 (-1),输出变为 11110111(-9 符号扩展)。

完成“累加”后,断言 SCLR 以将累加器寄存器清零(或根据您的逻辑使用 SSET 或 SINIT)。

Xilinx 库的文档应涵盖所有这些内容(尝试单击 corgen 对话框中的“数据表”按钮)。

于 2011-12-03T21:08:58.483 回答
0

Actually, I think I get it now. It's just acting like an Adder with signed inputs. I think I am correct on this but would appreciate any clarification!

于 2011-12-03T20:04:56.937 回答