From 2eaedab71cc797e39eeee954bb77e0ad198c24af Mon Sep 17 00:00:00 2001 From: faramire Date: Wed, 4 Sep 2024 13:58:07 +0200 Subject: [PATCH] addressing various linter warnings and errors --- src/controller.v | 12 ++++++------ src/led_ring_driver.v | 12 ++++++------ src/rotary_decoder.v | 4 ++-- src/rotary_ring_wrapper.v | 6 ++++-- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/controller.v b/src/controller.v index fe0e7c3..094a07a 100644 --- a/src/controller.v +++ b/src/controller.v @@ -37,10 +37,10 @@ module controller ( // Intensity always @(posedge clk) begin case(intensity_in[1:0]) - 2'b00: intensity_out = 8'b0000_0001; - 2'b01: intensity_out = 8'b0000_0010; - 2'b10: intensity_out = 8'b0000_1000; - 2'b11: intensity_out = 8'b0010_0000; + 2'b00: intensity_out <= 8'b0000_0001; + 2'b01: intensity_out <= 8'b0000_0010; + 2'b10: intensity_out <= 8'b0000_1000; + 2'b11: intensity_out <= 8'b0010_0000; endcase end @@ -55,9 +55,9 @@ module controller ( // Counting if (rot_up) begin - led_mask_i = (led_mask_i << 1) | (led_mask_i >> 11); // shift with rotate + led_mask_i <= (led_mask_i << 1) | (led_mask_i >> 11); // shift with rotate end else if (rot_dn) begin - led_mask_i = (led_mask_i >> 1) | (led_mask_i >> 11); + led_mask_i <= (led_mask_i >> 1) | (led_mask_i >> 11); end case(led_mask_i) diff --git a/src/led_ring_driver.v b/src/led_ring_driver.v index c145c2c..f1d0d76 100644 --- a/src/led_ring_driver.v +++ b/src/led_ring_driver.v @@ -25,7 +25,7 @@ module led_ring_driver ( reg [7:0] reg_intensity; // FSM states - reg [3:0] state; + reg [1:0] state; localparam IDLE = 2'b00; // idle, wait for refresh localparam CALC = 2'b01; // calc next timings localparam OUTP = 2'b10; // send data to LEDs, retun to CALC @@ -36,10 +36,10 @@ module led_ring_driver ( reg [5:0] tl_max; reg [5:0] th_counter; // counter for high time (16/32 clk cycles) reg [5:0] th_max; - reg [11:0] rs_counter; // counter for reset time (4000 clk cycles) + reg [10:0] rs_counter; // counter for reset time (4000 clk cycles) reg [3:0] led_pos; // led position counter (0..11) reg [1:0] grb_pos; // green, red, blue counter (0..2) - reg [3:0] byte_pos; // grb byte counter (0..7) + reg [2:0] byte_pos; // grb byte counter (0..7) always @(posedge clk) begin @@ -78,7 +78,7 @@ module led_ring_driver ( end if (byte_pos < 7) begin // advance to next bit - byte_pos = byte_pos + 1; + byte_pos <= byte_pos + 1; end else begin // end of colour byte, advance to next colour byte if (grb_pos < 2) begin byte_pos <= 0; @@ -101,7 +101,7 @@ module led_ring_driver ( OUTP: begin // output one bit according to the WS281B if (tl_counter < tl_max) begin // hold low, count cycles led_dout <= 0; - tl_counter = tl_counter + 6'b1; + tl_counter <= tl_counter + 6'b1; end else begin // hold high, count cycles if(th_counter < th_max) begin led_dout <= 1; @@ -118,7 +118,7 @@ module led_ring_driver ( TRES: begin // wait for the minimum reset time (t_res), then advance to IDLE led_dout <= 0; - if (rs_counter == 11'b111_1101_0000) begin + if (rs_counter >= 11'b111_1101_0000) begin state <= IDLE; end else begin rs_counter <= rs_counter + 11'b1; diff --git a/src/rotary_decoder.v b/src/rotary_decoder.v index 17329ac..1f54da0 100644 --- a/src/rotary_decoder.v +++ b/src/rotary_decoder.v @@ -62,7 +62,7 @@ module rotary_decoder ( OUTPUT: begin // copy the detected state to the outputs and go to next state where they will be set to 0 again => on for one clock rotation_up <= up_detected; rotation_dn <= dn_detected; - pause_counter = 16'b0; + pause_counter <= 15'b0; state <= PAUSE; end //OUTPUT @@ -72,7 +72,7 @@ module rotary_decoder ( if (pause_counter == 15'b100_1110_0001_1111) begin state <= WAIT; end else begin - pause_counter <= pause_counter + 16'b1; + pause_counter <= pause_counter + 15'b1; end end // PAUSE diff --git a/src/rotary_ring_wrapper.v b/src/rotary_ring_wrapper.v index 54451d6..76387f3 100644 --- a/src/rotary_ring_wrapper.v +++ b/src/rotary_ring_wrapper.v @@ -35,6 +35,7 @@ module tt_um_faramire_rotary_ring_wrapper ( .rot_up(rot_up), .rot_dn(rot_dn), .push(ui_in[2]), + .led_mask(led_mask), .intensity_in(ui_in[7:6]), .refresh(refresh), .intensity_out(intensity), @@ -57,7 +58,8 @@ module tt_um_faramire_rotary_ring_wrapper ( .led_mask(led_mask), .colour(ui_in[5:3]), .intensity(intensity), - .led_dout(uo_out[0]) + .led_dout(uo_out[0]), + .busy(driver_busy) ); // All output pins must be assigned. If not used, assign to 0. @@ -66,6 +68,6 @@ module tt_um_faramire_rotary_ring_wrapper ( assign uio_oe = 0; // List all unused inputs to prevent warnings - wire _unused = &{ena, uio_in[7:0], 1'b0}; + wire _unused = &{ena, uio_in[7:0], driver_busy, 1'b0}; endmodule