www.pudn.com > x86.rar > bitScanFwd.v, change:2007-12-05,size:2178b


/*********************************************************************************************** 
 
Module Name 	: bitScanFwd 
Purpose		: This module is used scan the given input from left to right 
		  and finds the position where the first 1 is present 
 
Instantiated modules: 
	 
***********************************************************************************************/ 
 
	 
 
module bitScanFwd(indexOutFwd, scanInFwd); 
input [31:0]scanInFwd;			// 32-bit input number  
output [4:0]indexOutFwd;		// Position from right where first 1 present 
 
assign	indexOutFwd = scanInFwd[0] ? 5'd0 : 
                    ((scanInFwd[1])? (5'd1) : 
                    ((scanInFwd[2])? (5'd2) : 
                    ((scanInFwd[3])? (5'd3) : 
                    ((scanInFwd[4])? (5'd4) : 
                    ((scanInFwd[5])? (5'd5) : 
                    ((scanInFwd[6])? (5'd6) : 
                    ((scanInFwd[7])? (5'd7) : 
                    ((scanInFwd[8])? (5'd8) : 
                    ((scanInFwd[9])? (5'd9) : 
                    ((scanInFwd[10])? (5'd10) : 
                    ((scanInFwd[11])? (5'd11) : 
                    ((scanInFwd[12])? (5'd12) : 
                    ((scanInFwd[13])? (5'd13) : 
                    ((scanInFwd[14])? (5'd14) : 
                    ((scanInFwd[15])? (5'd15) : 
                    ((scanInFwd[16])? (5'd16) : 
                    ((scanInFwd[17])? (5'd17) : 
                    ((scanInFwd[18])? (5'd18) : 
                    ((scanInFwd[19])? (5'd19) : 
                    ((scanInFwd[20])? (5'd20) : 
                    ((scanInFwd[21])? (5'd21) : 
                    ((scanInFwd[22])? (5'd22) : 
                    ((scanInFwd[23])? (5'd23) : 
                    ((scanInFwd[24])? (5'd24) : 
                    ((scanInFwd[25])? (5'd25) : 
                    ((scanInFwd[26])? (5'd26) : 
                    ((scanInFwd[27])? (5'd27) : 
                    ((scanInFwd[28])? (5'd28) : 
                    ((scanInFwd[29])? (5'd29) : 
                    ((scanInFwd[30])? (5'd30) : 
                    ((scanInFwd[31])? (5'd31) : 
                    (5'bz)))))))))))))))))))))))))))))))); 
endmodule