`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: Churbanov S. // // Create Date: 15:24:31 08/20/2019 // Design Name: // Module Name: // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Revision: // Revision 0.02 - File Modified // Additional Comments: 16.09.2019 file modified in assotiate with task. // ////////////////////////////////////////////////////////////////////////////////// module OverloadDetect #( parameter ThresholdWidth = 24, parameter AdcDataWidth = 14, parameter MeasPeriod = 32 ) ( input Rst_i, input Clk_i, input [AdcDataWidth-1:0] AdcData_i, input [ThresholdWidth-1:0] OverThreshold_i, output Overload_o ); //================================================================================ // LOG2 FUNCTION function integer Log2; input integer value; begin Log2 = 0; while (value > 1) begin value = value >> 1; Log2 = Log2 + 1; end if ((2**Log2)>CntWidth) > OverThreshold_i) begin overloadReg <= 1'b1; end else begin overloadReg <= 1'b0; end end end endmodule