Skip to content

Commit

Permalink
addressing various linter warnings and errors
Browse files Browse the repository at this point in the history
  • Loading branch information
faramire committed Sep 4, 2024
1 parent b440145 commit 2eaedab
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
12 changes: 6 additions & 6 deletions src/controller.v
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions src/led_ring_driver.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/rotary_decoder.v
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
6 changes: 4 additions & 2 deletions src/rotary_ring_wrapper.v
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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.
Expand All @@ -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

0 comments on commit 2eaedab

Please sign in to comment.