Question

I am trying to implement a signed accumulator using Core Gen in Xilinx. According to my understanding an accumulator performs the function of a normal register which is just routing the input to the output, but I wanted clarification on that.

I added the Accumulator IPcore (.xco) module to the project and I have a main file which basically contains the component declaration and the port map. I have a single step process too. Everything compiles and I can see the result on the board but don't quite understand what's going on...

When I input 1000 the 8 bit output on the LEDs is 11111000. Another input of 1111 gives me 11110111. I am attaching the code here for the main vhd file called Accm and the .vho file.

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

----------------------------------------------------------------------------------
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;

I am also pasting an image of the accumualtor I generated in CoreGen. enter image description here

I'D appreciate it if someone could explain me what is going on in this program. Thanks!

Was it helpful?

Solution

"Accumulator" can mean many things. In the hardware Xilinx library, the component you instantiated is an adder in front of a register. The adder is adding the current value of the accumulator register with the input term. The accumulator register is wider than the input so you can accumulate (add together) many input terms without overflowing the output.

When your circuit starts, the accumulator contains zero. You input 1000 (-8) which when added to zero becomes 11111000 (-8 sign extended) on the output. You then add 1111 (-1), and the output becomes 11110111 (-9 sign extended).

Once you are done "accumulating", assert SCLR to clear the accumulator register back to zero (or use SSET or SINIT, as appropriate for your logic).

This should all be covered by the documentation for the Xilinx library (try clicking the "datasheet" button in the corgen dialog).

OTHER TIPS

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!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top