data/full_repos/permissive/19591557/modules/status_led_generator/spio_status_led_generator.v
1: b'%Warning-WIDTH: data/full_repos/permissive/19591557/modules/status_led_generator/spio_status_led_generator.v:67: Operator LT expects 8 bits on the LHS, but LHS\'s VARREF \'pwm_counter_i\' generates 7 bits.\n                                                                                                               : ... In instance spio_status_led_generator\n   LED_OUT[i] <= pwm_counter_i < pwm_value_i[i];\n                               ^\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Error: Exiting due to 1 warning(s)\n'
module spio_status_led_generator #(
                                    parameter NUM_DEVICES = 1

                                  , parameter ANIMATION_PERIOD_BITS = 27

                                  , parameter PULSE_DURATION = 7500000


                                  , parameter ACTIVITY_BLINK_BIT =  22

                                  , parameter PWM_BITS = 7


                                  , parameter ACTIVITY_TIMEOUT = 18750000
                                  , parameter ACTIVITY_TIMEOUT_BITS = 25
                                  )
                                  ( input wire CLK_IN
                                  , input wire RESET_IN

                                  , input wire [NUM_DEVICES-1:0] ERROR_IN

                                  , input wire [NUM_DEVICES-1:0] CONNECTED_IN

                                  , input wire [NUM_DEVICES-1:0] ACTIVITY_IN

                                  , output reg [NUM_DEVICES-1:0] LED_OUT


                                  , output reg ANIMATION_REPEAT_OUT
                                  );
genvar i;


reg [PWM_BITS:0] pwm_value_i [NUM_DEVICES-1:0];



wire activity_i [NUM_DEVICES-1:0];


reg [PWM_BITS-1:0] animation_pulse_i;
reg [PWM_BITS-1:0] animation_blink_i;
reg [PWM_BITS-1:0] animation_throb_i;






reg [PWM_BITS-1:0] pwm_counter_i;
always @ (posedge CLK_IN, posedge RESET_IN)
	if (RESET_IN)
		pwm_counter_i <= 0;
	else
		pwm_counter_i <= pwm_counter_i + 1;



generate for (i = 0; i < NUM_DEVICES; i = i + 1)
	begin : pwm_comparator
		always @ (posedge CLK_IN)
			LED_OUT[i] <= pwm_counter_i < pwm_value_i[i];
	end
endgenerate







reg [ANIMATION_PERIOD_BITS-1:0] period_i;
always @ (posedge CLK_IN, posedge RESET_IN)
	if (RESET_IN)
		period_i <= 0;
	else
		period_i <= period_i + 1;




always @ (posedge CLK_IN)
	ANIMATION_REPEAT_OUT <= period_i == 0;



always @ (posedge CLK_IN)
	animation_pulse_i <= {PWM_BITS { (period_i-{1'b1, {ANIMATION_PERIOD_BITS-1{1'b0}}})
	                                 < PULSE_DURATION
	                               }
	                     };


always @ (posedge CLK_IN)
	animation_blink_i <= {PWM_BITS{period_i[ACTIVITY_BLINK_BIT]}};


always @ (posedge CLK_IN)
	if (period_i[ANIMATION_PERIOD_BITS-1] == 1'b0)

		animation_throb_i <= period_i[ ANIMATION_PERIOD_BITS-2
		                             : ANIMATION_PERIOD_BITS-PWM_BITS-1
		                             ];
	else

		animation_throb_i <= {PWM_BITS{1'b1}} - period_i[ ANIMATION_PERIOD_BITS-2
		                                                : ANIMATION_PERIOD_BITS-PWM_BITS-1
		                                                ];






generate for (i = 0; i < NUM_DEVICES; i = i + 1)
	begin : activity_timeouts
		reg [ACTIVITY_TIMEOUT_BITS-1:0] timeout_i;
		
		always @ (posedge CLK_IN, posedge RESET_IN)
			if (RESET_IN)
				timeout_i <= 0;
			else
				if (ACTIVITY_IN[i])
					timeout_i <= ACTIVITY_TIMEOUT;
				else if (timeout_i != 0)
					timeout_i <= timeout_i - 1;
		
		assign activity_i[i] = timeout_i != 0;
	end
endgenerate






generate for (i = 0; i < NUM_DEVICES; i = i + 1)
	begin : animation_selection
		always @ (posedge CLK_IN)
			casex ({ERROR_IN[i], CONNECTED_IN[i], activity_i[i]})
				3'b1xx:  pwm_value_i[i] <= {1'b0, ~animation_pulse_i};
				3'b011:  pwm_value_i[i] <= {1'b0, animation_blink_i};
				3'b010:  pwm_value_i[i] <= {1'b0, animation_throb_i};
				default: pwm_value_i[i] <= {1'b0, animation_pulse_i};
			endcase
	end
endgenerate

endmodule
module spio_status_led_generator #(
                                    parameter NUM_DEVICES = 1

                                  , parameter ANIMATION_PERIOD_BITS = 27

                                  , parameter PULSE_DURATION = 7500000


                                  , parameter ACTIVITY_BLINK_BIT =  22

                                  , parameter PWM_BITS = 7


                                  , parameter ACTIVITY_TIMEOUT = 18750000
                                  , parameter ACTIVITY_TIMEOUT_BITS = 25
                                  )
                                  ( input wire CLK_IN
                                  , input wire RESET_IN

                                  , input wire [NUM_DEVICES-1:0] ERROR_IN

                                  , input wire [NUM_DEVICES-1:0] CONNECTED_IN

                                  , input wire [NUM_DEVICES-1:0] ACTIVITY_IN

                                  , output reg [NUM_DEVICES-1:0] LED_OUT


                                  , output reg ANIMATION_REPEAT_OUT
                                  );

genvar i;


reg [PWM_BITS:0] pwm_value_i [NUM_DEVICES-1:0];



wire activity_i [NUM_DEVICES-1:0];


reg [PWM_BITS-1:0] animation_pulse_i;
reg [PWM_BITS-1:0] animation_blink_i;
reg [PWM_BITS-1:0] animation_throb_i;






reg [PWM_BITS-1:0] pwm_counter_i;
always @ (posedge CLK_IN, posedge RESET_IN)
	if (RESET_IN)
		pwm_counter_i <= 0;
	else
		pwm_counter_i <= pwm_counter_i + 1;



generate for (i = 0; i < NUM_DEVICES; i = i + 1)
	begin : pwm_comparator
		always @ (posedge CLK_IN)
			LED_OUT[i] <= pwm_counter_i < pwm_value_i[i];
	end
endgenerate







reg [ANIMATION_PERIOD_BITS-1:0] period_i;
always @ (posedge CLK_IN, posedge RESET_IN)
	if (RESET_IN)
		period_i <= 0;
	else
		period_i <= period_i + 1;




always @ (posedge CLK_IN)
	ANIMATION_REPEAT_OUT <= period_i == 0;



always @ (posedge CLK_IN)
	animation_pulse_i <= {PWM_BITS { (period_i-{1'b1, {ANIMATION_PERIOD_BITS-1{1'b0}}})
	                                 < PULSE_DURATION
	                               }
	                     };


always @ (posedge CLK_IN)
	animation_blink_i <= {PWM_BITS{period_i[ACTIVITY_BLINK_BIT]}};


always @ (posedge CLK_IN)
	if (period_i[ANIMATION_PERIOD_BITS-1] == 1'b0)

		animation_throb_i <= period_i[ ANIMATION_PERIOD_BITS-2
		                             : ANIMATION_PERIOD_BITS-PWM_BITS-1
		                             ];
	else

		animation_throb_i <= {PWM_BITS{1'b1}} - period_i[ ANIMATION_PERIOD_BITS-2
		                                                : ANIMATION_PERIOD_BITS-PWM_BITS-1
		                                                ];






generate for (i = 0; i < NUM_DEVICES; i = i + 1)
	begin : activity_timeouts
		reg [ACTIVITY_TIMEOUT_BITS-1:0] timeout_i;
		
		always @ (posedge CLK_IN, posedge RESET_IN)
			if (RESET_IN)
				timeout_i <= 0;
			else
				if (ACTIVITY_IN[i])
					timeout_i <= ACTIVITY_TIMEOUT;
				else if (timeout_i != 0)
					timeout_i <= timeout_i - 1;
		
		assign activity_i[i] = timeout_i != 0;
	end
endgenerate






generate for (i = 0; i < NUM_DEVICES; i = i + 1)
	begin : animation_selection
		always @ (posedge CLK_IN)
			casex ({ERROR_IN[i], CONNECTED_IN[i], activity_i[i]})
				3'b1xx:  pwm_value_i[i] <= {1'b0, ~animation_pulse_i};
				3'b011:  pwm_value_i[i] <= {1'b0, animation_blink_i};
				3'b010:  pwm_value_i[i] <= {1'b0, animation_throb_i};
				default: pwm_value_i[i] <= {1'b0, animation_pulse_i};
			endcase
	end
endgenerate

endmodule