www.pudn.com > uart_v11.zip > filt_tpl.tdf


%////////////////////////////////////////////////////////////////////////////////////////////////////////// 
//                                                                                                       // 
//  PROJECT:      Parameterized Digital Filter.                                                          // 
//                Keith Willis                                                                           // 
//                Copyright © 1998. All Rights Reserved.                                                 // 
//                                                                                                       // 
//                You may use or distribute this module freely, provided you do not remove this          // 
//                copyright notice or modify the contents of this file.                                  // 
//                If you have questions or comments, feel free to contact me by email at                 // 
//                kcwillis@mech.eng.usyd.edu.au                                                          // 
//                                                                                                       // 
//  AUTHOR:       Keith Willis                                                                           // 
//                                                                                                       // 
//  MODULE:       Filt_Tpl.tdf                                                                           // 
//                                                                                                       // 
//  DESCRIPTION:  AHDL File for SISO Digital Filter Template.                                            // 
//                                                                                                       // 
//  VERSION:      1.0                                                                                    // 
//                                                                                                       // 
//////////////////////////////////////////////////////////////////////////////////////////////////////////% 
 
TITLE "SISO Digital Filter Template";  
 
 
%//////////////////////////// 
// USER-DEFINED PARAMETERS // 
////////////////////////////% 
 
PARAMETERS 
( 
 NUM_STAGES = 2 
); 
 
 
%///////////////////// 
// INPUTS & OUTPUTS // 
/////////////////////% 
 
SUBDESIGN filt_tpl 
( 
 CLK, F_IN	: INPUT; 
 RESET		: INPUT=GND; 
 PRESET		: INPUT=GND; 
 F_OUT		: OUTPUT; 
) 
 
 
%///////////////////////// 
// VARIABLE DEFINITIONS // 
/////////////////////////% 
 
VARIABLE 
 FF[(NUM_STAGES - 1)..0]	: DFF; 
 SYNC						: DFFE; 
 FAND[(NUM_STAGES-1)..0], FBAND[(NUM_STAGES-1)..0]	: NODE; 
 
 
%////////////////// 
// LOGIC SECTION // 
//////////////////% 
 
BEGIN 
 
 FF[].clk=CLK; 
 FF[].clrn=!RESET; 
 FF[].prn=!PRESET; 
 SYNC.clk=CLK; 
 SYNC.clrn=!RESET; 
 SYNC.prn=!PRESET; 
 
 FF[0].d=F_IN	; 
 FOR i IN 1 TO NUM_STAGES-1 GENERATE 
  FF[i].d=FF[i-1].q; 
 END GENERATE; 
 
 FAND[0] = FF[0].q; 
 FBAND[0] = FF[0].q; 
 FOR i IN 1 TO NUM_STAGES-1 GENERATE 
  FAND[i] = FAND[i-1] AND FF[i].q; 
  FBAND[i] = FBAND[i-1] OR FF[i].q; 
 END GENERATE; 
 
 SYNC.d=FF[(NUM_STAGES-1)].q; 
 SYNC.ena=FAND[(NUM_STAGES-1)] OR NOT FBAND[(NUM_STAGES-1)]; 
 
 F_OUT=SYNC.q;  
		 
END;