OpenCores
URL https://opencores.org/ocsvn/multiply-accumulate/multiply-accumulate/trunk

Subversion Repositories multiply-accumulate

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /multiply-accumulate
    from Rev 3 to Rev 4
    Reverse comparison

Rev 3 → Rev 4

/trunk/mac.vhd
0,0 → 1,33
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
 
ENTITY mac IS
GENERIC (n : INTEGER := 4); --define X and Y size
PORT (
ck : IN STD_LOGIC;
rst : IN STD_LOGIC;
X : IN SIGNED (n-1 DOWNTO 0); --n
Y : IN SIGNED (n-1 DOWNTO 0); --n
A : OUT SIGNED ((2+2*n)-1 DOWNTO 0) --2+2n (include two leading bits for overflow)
);
END mac;
 
ARCHITECTURE hdl OF mac IS
SIGNAL acc : SIGNED ((2+2*n)-1 DOWNTO 0) := (OTHERS => '0'); --2+2n
 
BEGIN
 
PROCESS (ck)
BEGIN
IF rising_edge(ck) THEN
IF rst ='0' THEN --reset accumulator at low
acc <= (OTHERS => '0');
ELSE
acc <= acc + shift_left(X * Y, 1);
END IF;
END IF;
END PROCESS;
 
A <= acc;
END hdl;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.