OpenCores
URL https://opencores.org/ocsvn/firgen/firgen/trunk

Subversion Repositories firgen

[/] [firgen/] [trunk/] [firgen/] [RedFIR/] [firgen/] [test_area/] [redFir_engine/] [example.m] - Rev 8

Compare with Previous | Blame | View Log

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This sourcecode was automaticaly generated by wizard redFIR(TM)
% optmizer version : 2.030908ALPHA_FHF
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% redFIR constraints: 
%	date : 04/07/09
%	username xyz ,	userID  : Mustermann
%	project : TestFIR
%	version : 1,	revision: 0
%	revision: 0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% disclaimer:
%	redFir in a registered trademark of 
%	Fraunhofer Institute for Integrated Circuits
%	Am Wolfsmantel 13 / 91058 Erlangen / Germany
% http://www.iis.fraunhofer.de 	 redfir@iis.fhg.de
% look an http://www.redfir.de for further information and updates 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [fir_out,float_out,deviation] = TestFIR(in_data);
 
 
 in_width=14;
 chain_cut= 5;
 l=length(in_data);
 in_data=in_data/max(abs(in_data));
 if (l<37)
 	error ('error ... not enought input values in vector in_data');
 end;
  rnd_in_data=round(in_data*2^(in_width-1));
 
Íå·Íå·eger := 1; 	-- this flag is to enable async reset in modules
	flag_en  : integer := 1); 	-- this flag is to enable the 'en' signale for data enable
port (
	rst      : in std_logic;  	-- asynchronous reset signal
	en       : in std_logic;  	-- data enable signal
	clk      : in std_logic;  	-- clock signal
	in_data  : in std_logic_vector  (13 downto 0);   	-- incomming data
	out_data : out std_logic_vector (27 downto 0) ); 	-- outgoing data
end  TestFIR;
--------------------------------------------------------------------------------
% Signal declaration for coefficient structure 
% structure will contain 3 lines and 27 coefficients
 
 
coef_float=zeros(27,1);
 
	 coef_float(1)=0.0015196151700239760029553792719525517895817756652832031250000000;
	 coef_float(2)=-0.0022794227550359640044330689079288276843726634979248046875000000;
	 coef_float(3)=-0.0007598075850119880014776896359762758947908878326416015625000000;
	 coef_float(4)=0.0030392303400479520059107585439051035791635513305664062500000000;
	 coef_float(5)=-0.0091371735962318956225658439507242292165756225585937500000000000;
	 coef_float(6)=0.0091371735962318956225658439507242292165756225585937500000000000;
	 coef_float(7)=0.0068577506597533744586714377078351390082389116287231445312500000;
	 coef_float(8)=-0.0197939619996026529291643925034804851748049259185791015625000000;
	 coef_float(9)=0.0289116522939762768396043668417405569925904273986816406250000000;
	 coef_float(10)=-0.0182743471924637912451316879014484584331512451171875000000000000;
	 coef_float(11)=-0.0380488266159784080389094640395342139527201652526855468750000000;
	 coef_float(12)=0.1027298847667652559323414607206359505653381347656250000000000000;
	 coef_float(13)=-0.1620922925441065642893079257191857323050498962402343750000000000;
	 coef_float(14)=0.1948224629804775620556256399140693247318267822265625000000000000;
	 coef_float(15)=-0.1620922925441065642893079257191857323050498962402343750000000000;
	 coef_float(16)=0.1027298847667652559323414607206359505653381347656250000000000000;
	 coef_float(17)=-0.0380488266159784080389094640395342139527201652526855468750000000;
	 coef_float(18)=-0.0182743471924637912451316879014484584331512451171875000000000000;
	 coef_float(19)=0.0289116522939762768396043668417405569925904273986816406250000000;
	 coef_float(20)=-0.0197939619996026529291643925034804851748049259185791015625000000;
	 coef_float(21)=0.0068577506597533744586714377078351390082389116287231445312500000;
	 coef_float(22)=0.0091371735962318956225658439507242292165756225585937500000000000;
	 coef_float(23)=-0.0091371735962318956225658439507242292165756225585937500000000000;
	 coef_float(24)=0.0030392303400479520059107585439051035791635513305664062500000000;
	 coef_float(25)=-0.0007598075850119880014776896359762758947908878326416015625000000;
	 coef_float(26)=-0.0022794227550359640044330689079288276843726634979248046875000000;
	 coef_float(27)=0.0015196151700239760029553792719525517895817756652832031250000000;
% maximum precision floating point filter estimation
 
 float_out=conv(in_data,coef_float);
 float_out=float_out(1:l)*2^27;
 
 
% real filter estimation
 
 
 
	sg_0_1_module = rnd_in_data;	% i_0_node: entity work.DELAY level: 0 result: 1 
 	sg_0_3_module = rnd_in_data * (2^1+1);	% i_1_node: entity work.P_MULT level: 0 result: 3 
 	sg_0_5_module = rnd_in_data * (2^2+1);	% i_2_node: entity work.P_MULT level: 0 result: 5 
 	sg_0_7_module = rnd_in_data * (2^3-1);	% i_3_node: entity work.S_MULT level: 0 result: 7 
 	sg_0_9_module = rnd_in_data * (2^3+1);	% i_4_node: entity work.P_MULT level: 0 result: 9 
 	sg_0_127_module = rnd_in_data * (2^7-1);	% i_5_node: entity work.S_MULT level: 0 result: 127 
 	sg_1_7_module = sg_0_7_module;	% i_6_node: entity work.DELAY level: 1 result: 7 
 	sg_1_11_module = sg_0_7_module + sg_0_1_module* 2^2 ;	% i_7_node: entity work.ADDER level: 1 result: 11 
 	sg_1_13_module = sg_0_5_module + sg_0_1_module* 2^3 ;	% i_8_node: entity work.ADDER level: 1 result: 13 
 	sg_1_29_module = sg_0_9_module + sg_0_5_module* 2^2 ;	% i_9_node: entity work.ADDER level: 1 result: 29 
 	sg_1_45_module = sg_0_3_module* (2^4-1);	% i_10_node: entity work.S_MULT level: 1 result: 45 
 	sg_1_103_module = sg_0_7_module + sg_0_3_module* 2^5 ;	% i_11_node: entity work.ADDER level: 1 result: 103 
 	sg_1_105_module = sg_0_9_module + sg_0_3_module* 2^5 ;	% i_12_node: entity work.ADDER level: 1 result: 105 
 	sg_1_169_module = sg_0_9_module + sg_0_5_module* 2^5 ;	% i_13_node: entity work.ADDER level: 1 result: 169 
 	sg_1_351_module = sg_0_127_module + sg_0_7_module* 2^5 ;	% i_14_node: entity work.ADDER level: 1 result: 351 
 	sg_1_2561_module = sg_0_1_module + sg_0_5_module* 2^9 ;	% i_15_node: entity work.ADDER level: 1 result: 2561 
 	sg_2_25_module = sg_1_11_module + sg_1_7_module* 2^1 ;	% i_16_node: entity work.ADDER level: 2 result: 25 
 	sg_2_149_module = sg_1_45_module + sg_1_13_module* 2^3 ;	% i_17_node: entity work.ADDER level: 2 result: 149 
 	sg_2_199_module = sg_1_103_module* 2^1 - sg_1_7_module;	% i_18_node: entity work.A_SUB level: 2 result: 199 
 	sg_2_399_module = sg_1_103_module* 2^2 - sg_1_13_module;	% i_19_node: entity work.A_SUB level: 2 result: 399 
 	sg_2_449_module = sg_1_29_module + sg_1_105_module* 2^2 ;	% i_20_node: entity work.ADDER level: 2 result: 449 
 	sg_2_599_module = sg_1_11_module* 2^6 - sg_1_105_module;	% i_21_node: entity work.A_SUB level: 2 result: 599 
 	sg_2_1247_module = sg_1_169_module* 2^3 - sg_1_105_module;	% i_22_node: entity work.A_SUB level: 2 result: 1247 
 	sg_2_1297_module = sg_1_103_module* 2^4 - sg_1_351_module;	% i_23_node: entity work.A_SUB level: 2 result: 1297 
 	sg_2_1895_module = sg_1_103_module + sg_1_7_module* 2^8 ;	% i_24_node: entity work.ADDER level: 2 result: 1895 
 	sg_2_6733_module = sg_1_13_module + sg_1_105_module* 2^6 ;	% i_25_node: entity work.ADDER level: 2 result: 6733 
 	sg_2_10623_module = sg_1_103_module* 2^7 - sg_1_2561_module;	% i_26_node: entity work.A_SUB level: 2 result: 10623 
 
% remapping to coefficient values
	sg_0_coef = sg_2_25_module*2^2;
	sg_1_coef = sg_2_149_module*2^0;
	sg_2_coef = sg_2_25_module*2^1;
	sg_3_coef = sg_2_199_module*2^0;
	sg_4_coef = sg_2_599_module*2^0;
	sg_5_coef = sg_2_599_module*2^0;
	sg_6_coef = sg_2_449_module*2^0;
	sg_7_coef = sg_2_1297_module*2^0;
	sg_8_coef = sg_2_1895_module*2^0;
	sg_9_coef = sg_2_599_module*2^1;
	sg_10_coef = sg_2_1247_module*2^1;
	sg_11_coef = sg_2_6733_module*2^0;
	sg_12_coef = sg_2_10623_module*2^0;
	sg_13_coef = sg_2_399_module*2^5;
	sg_14_coef = sg_2_10623_module*2^0;
	sg_15_coef = sg_2_6733_module*2^0;
	sg_16_coef = sg_2_1247_module*2^1;
	sg_17_coef = sg_2_599_module*2^1;
	sg_18_coef = sg_2_1895_module*2^0;
	sg_19_coef = sg_2_1297_module*2^0;
	sg_20_coef = sg_2_449_module*2^0;
	sg_21_coef = sg_2_599_module*2^0;
	sg_22_coef = sg_2_599_module*2^0;
	sg_23_coef = sg_2_199_module*2^0;
	sg_24_coef = sg_2_25_module*2^1;
	sg_25_coef = sg_2_149_module*2^0;
	sg_26_coef = sg_2_25_module*2^2;
 
 
% adderchain instantiation
	fir_out = zeros(l,1);
	sg_0_chain = 0;
	sg_1_chain = 0;
	sg_2_chain = 0;
	sg_3_chain = 0;
	sg_4_chain = 0;
	sg_5_chain = 0;
	sg_6_chain = 0;
	sg_7_chain = 0;
	sg_8_chain = 0;
	sg_9_chain = 0;
	sg_10_chain = 0;
	sg_11_chain = 0;
	sg_12_chain = 0;
	sg_13_chain = 0;
	sg_14_chain = 0;
	sg_15_chain = 0;
	sg_16_chain = 0;
	sg_17_chain = 0;
	sg_18_chain = 0;
	sg_19_chain = 0;
	sg_20_chain = 0;
	sg_21_chain = 0;
	sg_22_chain = 0;
	sg_23_chain = 0;
	sg_24_chain = 0;
	sg_25_chain = 0;
	sg_26_chain = 0;
 
 for k=1:l
	if (mod(k,1000)==0) 
		fprintf('.');
	end;
	sg_26_chain = sg_25_chain+sg_26_coef(k);
	sg_25_chain = sg_24_chain-sg_25_coef(k);
	sg_24_chain = sg_23_chain-sg_24_coef(k);
	sg_23_chain = sg_22_chain+sg_23_coef(k);
	sg_22_chain = sg_21_chain-sg_22_coef(k);
	sg_21_chain = sg_20_chain+sg_21_coef(k);
	sg_20_chain = sg_19_chain+sg_20_coef(k);
	sg_19_chain = sg_18_chain-sg_19_coef(k);
	sg_18_chain = sg_17_chain+sg_18_coef(k);
	sg_17_chain = sg_16_chain-sg_17_coef(k);
	sg_16_chain = sg_15_chain-sg_16_coef(k);
	sg_15_chain = sg_14_chain+sg_15_coef(k);
	sg_14_chain = sg_13_chain-sg_14_coef(k);
	sg_13_chain = sg_12_chain+sg_13_coef(k);
	sg_12_chain = sg_11_chain-sg_12_coef(k);
	sg_11_chain = sg_10_chain+sg_11_coef(k);
	sg_10_chain = sg_9_chain-sg_10_coef(k);
	sg_9_chain = sg_8_chain-sg_9_coef(k);
	sg_8_chain = sg_7_chain+sg_8_coef(k);
	sg_7_chain = sg_6_chain-sg_7_coef(k);
	sg_6_chain = sg_5_chain+sg_6_coef(k);
	sg_5_chain = sg_4_chain+sg_5_coef(k);
	sg_4_chain = sg_3_chain-sg_4_coef(k);
	sg_3_chain = sg_2_chain+sg_3_coef(k);
	sg_2_chain = sg_1_chain-sg_2_coef(k);
	sg_1_chain = sg_0_chain-sg_1_coef(k);
	sg_0_chain = +sg_0_coef(k);
 fir_out(k)=floor(sg_26_chain/(2^chain_cut));
end;
 deviation=fir_out./float_out;
 

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

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