--========================================================== -- Design units : FILTERbehave -- (entity, architecture and configuration) -- -- File name : FILTERbehave.vhd -- -- Purpose : behavioral description of the systolic -- filter arry -- -- Limitations : None -- -- Library : WORK -- -- Dependencies : FILTERpack -- -- Author : Hans-Peter Eich, REFT -- -- Simulator : Synopsys V3.1a on Sun SPARCstation 10 -- ----------------------------------------------------------- -- Revision list -- Version Author Date Changes -- -- V1.0 hpe 18.01.95 ESA Standard -- V1.1 cjt 03.07.95 --========================================================= -- NOTE : The output of the behavioral description produces -- the result stream 59 52 45 in decimal. The structural -- description results are 3B 34 2D in hexadecimal. -- One Problem to solve are the different values in -- structure and behavior before the first correct -- result is computed, therefore a comparison should -- start at the first wanted result. LIBRARY IEEE; USE IEEE.std_logic_1164.ALL; USE work.FILTERpack.ALL; ENTITY FILTERbehave IS GENERIC (N: Positive := 12; -- n bit output stream M: Positive := 4; -- m bit input stream K: Positive := 3); -- number of weight data PORT (StreamIn: IN Integer RANGE (2**M)-1 DOWNTO 0; -- stream in CLK: IN std_logic; -- clock in SelWgtStr: IN std_logic; -- select weight or stream StoreWgt : IN std_logic; -- store weigth StoreStr : IN std_logic; -- store stream Reset_N : IN std_logic; -- asynchronous reset active low ResultOut: OUT Integer RANGE (2**N)-1 DOWNTO 0); -- result out END FILTERbehave; --============================ARCHITECTURE================== ARCHITECTURE Behavior OF FILTERbehave IS SUBTYPE Short IS Integer RANGE (2**M)-1 DOWNTO 0; TYPE Data_Buffer IS ARRAY (Natural RANGE <>) OF Short; BEGIN main: PROCESS (CLK,SelWgtStr,StoreWgt,StoreStr,Reset_N,StreamIn) VARIABLE Stream_Data : Data_Buffer(K-1 DOWNTO 0); VARIABLE Weight_Data : Data_Buffer(K-1 DOWNTO 0); VARIABLE Temp_Result, Temp_Stage : Integer RANGE (2**N)-1 DOWNTO 0; BEGIN IF Reset_N = '0' THEN init : FOR i IN K-1 DOWNTO 0 LOOP Stream_Data(i) := 0; Weight_Data(i) := 0; Temp_Result := 0; END LOOP init; ELSE IF (CLK'EVENT AND CLK = '1') THEN IF SelWgtStr = '0' AND StoreWgt = '1' THEN IF K>1 THEN FOR i IN K-1 DOWNTO 1 LOOP Weight_Data(i) := Stream_Data(i-1); END LOOP; END IF; Weight_Data(0) := StreamIn; END IF; IF SelWgtStr = '1' AND StoreStr = '1' THEN IF K=1 THEN Stream_Data(0) := StreamIn; Temp_Result := Weight_Data(0) * Stream_Data(0); ELSE FOR i IN K-2 DOWNTO 0 LOOP Stream_Data(i+1) := Stream_Data(i); END LOOP; Stream_Data(0) := StreamIn; Temp_Result := 0; FOR i IN K-1 DOWNTO 0 LOOP Temp_Stage := Weight_Data(i) * Stream_Data(i); Temp_Result := (Temp_Result + Temp_Stage) MOD 2**N; END LOOP; ResultOut <= Temp_Result; END IF; END IF; END IF; END IF; END PROCESS; END Behavior; --============================CONFIGURATION================= CONFIGURATION FILTERbehave_DefaultConfig OF FILTERbehave IS FOR Behavior END FOR; END FILTERbehave_DefaultConfig;