Skip to content

Commit 8a2552e

Browse files
committed
library/spi_engine: cosmetic changes
Signed-off-by: Carlos Souza <carlos.souza@analog.com>
1 parent b41a05f commit 8a2552e

File tree

3 files changed

+35
-44
lines changed

3 files changed

+35
-44
lines changed

library/spi_engine/spi_engine_execution/spi_engine_execution.v

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ module spi_engine_execution #(
188188
.ECHO_SCLK(ECHO_SCLK),
189189
.CMD_TRANSFER(CMD_TRANSFER),
190190
.CMD_WRITE(CMD_WRITE),
191-
.REG_SPI_LANE_CONFIG(REG_SPI_LANE_CONFIG),
192-
.REG_CONFIG(REG_CONFIG)
191+
.REG_SPI_LANE_CONFIG(REG_SPI_LANE_CONFIG)
193192
) shiftreg (
194193
.clk(clk),
195194
.resetn(resetn),

library/spi_engine/spi_engine_execution/spi_engine_execution_shiftreg.v

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ module spi_engine_execution_shiftreg #(
4545
parameter ECHO_SCLK = 0,
4646
parameter [2:0] CMD_TRANSFER = 3'b000,
4747
parameter [2:0] CMD_WRITE = 3'b010,
48-
parameter [1:0] REG_SPI_LANE_CONFIG = 2'b11,
49-
parameter [1:0] REG_CONFIG = 2'b01
48+
parameter [1:0] REG_SPI_LANE_CONFIG = 2'b11
5049
) (
5150
input clk,
5251
input resetn,
@@ -113,8 +112,7 @@ module spi_engine_execution_shiftreg #(
113112
.DATA_WIDTH(DATA_WIDTH),
114113
.NUM_OF_SDI(NUM_OF_SDI),
115114
.CMD_WRITE(CMD_WRITE),
116-
.REG_SPI_LANE_CONFIG(REG_SPI_LANE_CONFIG),
117-
.REG_CONFIG (REG_CONFIG)
115+
.REG_SPI_LANE_CONFIG(REG_SPI_LANE_CONFIG)
118116
) sdo_data_assemble (
119117
.clk (clk),
120118
.resetn (resetn),

library/spi_engine/spi_engine_execution/spi_engine_execution_shiftreg_data_assemble.v

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,52 @@ module spi_engine_execution_shiftreg_data_assemble #(
33
parameter DATA_WIDTH = 8,
44
parameter NUM_OF_SDI = 1,
55
parameter [2:0] CMD_WRITE = 3'b010,
6-
parameter [1:0] REG_SPI_LANE_CONFIG = 2'b11,
7-
parameter [1:0] REG_CONFIG = 2'b01
6+
parameter [1:0] REG_SPI_LANE_CONFIG = 2'b11
87
) (
9-
input clk,
10-
input resetn,
11-
input [(DATA_WIDTH)-1:0] data,
12-
input data_ready,
13-
input data_valid,
14-
input [15:0] current_cmd,
15-
input [7:0] lane_mask,
16-
input idle_state,
17-
input [7:0] left_aligned,
18-
input transfer_active,
19-
input trigger_tx,
20-
input first_bit,
21-
input sdo_enabled,
22-
output [(NUM_OF_SDI * DATA_WIDTH)-1:0] data_assembled,
23-
output last_handshake
8+
input clk,
9+
input resetn,
10+
input [(DATA_WIDTH)-1:0] data,
11+
input data_ready,
12+
input data_valid,
13+
input [15:0] current_cmd,
14+
input [7:0] lane_mask,
15+
input idle_state,
16+
input [7:0] left_aligned,
17+
input transfer_active,
18+
input trigger_tx,
19+
input first_bit,
20+
input sdo_enabled,
21+
output [(NUM_OF_SDI * DATA_WIDTH)-1:0] data_assembled,
22+
output last_handshake
2423
);
2524

2625
// This module is responsible to align data for different lane masks
27-
// if spi_lane_mask has all of its SDOs activated, then it allows prefetch data
26+
// if lane_mask has all of its SDOs activated, then it allows prefetch data
2827
// if not, non activated serial lines have their data fulfilled with idle_state and buffer the remaining activated lines
2928
// also, in this mode it is not possible to prefetch data
3029

30+
reg last_handshake_int;
3131
reg [(NUM_OF_SDI * DATA_WIDTH)-1:0] aligned_data;
32-
reg [(DATA_WIDTH)-1:0] data_reg;
33-
reg [DATA_WIDTH-1:0] data_reg_d;
32+
reg [ (DATA_WIDTH)-1:0] data_reg;
33+
reg [ 3:0] count_active_lanes = 0;
3434

35-
integer num_active_lanes = NUM_OF_SDI;
36-
reg [3:0] count_active_lanes = 0;
37-
reg last_handshake_int;
38-
reg [7:0] spi_lane_config_mask = ALL_ACTIVE_LANE_MASK;
39-
integer lane_index = 0;
40-
integer lane_index_d = 0;
41-
integer valid_indices [0:7];
42-
integer valid_index = 0;
35+
wire sdo_toshiftreg = (transfer_active && trigger_tx && first_bit && sdo_enabled);
36+
wire [2:0] current_instr = current_cmd[14:12];
37+
wire [1:0] configuration_register = current_cmd[9:8];
38+
wire exec_lane_config_cmd = ((current_instr == CMD_WRITE) && (configuration_register == REG_SPI_LANE_CONFIG));
4339

44-
wire sdo_toshiftreg = (transfer_active && trigger_tx && first_bit && sdo_enabled);
45-
wire [2:0] current_instr = current_cmd[14:12];
46-
wire [1:0] configuration_register = current_cmd[9:8];
47-
wire exec_lane_config_cmd = ((current_instr == CMD_WRITE) && (configuration_register == REG_SPI_LANE_CONFIG));
48-
wire exec_spi_cfg = ((current_instr == CMD_WRITE) && (configuration_register == REG_CONFIG));
40+
integer num_active_lanes = NUM_OF_SDI;
41+
integer lane_index = 0;
42+
integer lane_index_d = 0;
43+
integer valid_index = 0;
44+
integer valid_indices [0:7];
4945

5046
assign data_assembled = aligned_data;
5147
assign last_handshake = last_handshake_int;
5248

5349
// register data
5450
always @(posedge clk) begin
5551
if (resetn == 1'b0) begin
56-
// data_reg <= {(NUM_OF_SDI * DATA_WIDTH){idle_state}};
5752
data_reg <= {DATA_WIDTH{idle_state}};
5853
end else begin
5954
if (data_ready && data_valid) begin
@@ -84,7 +79,6 @@ always @(posedge clk) begin
8479
j <= 0;
8580
end else begin
8681
if (exec_lane_config_cmd) begin
87-
spi_lane_config_mask <= current_cmd[7:0];
8882
count_active_lanes = 0;
8983
i = 0;
9084
j <= 0;
@@ -94,7 +88,7 @@ always @(posedge clk) begin
9488
num_active_lanes <= count_active_lanes;
9589
end else begin
9690
if (j < NUM_OF_SDI) begin
97-
if (spi_lane_config_mask[j]) begin
91+
if (lane_mask[j]) begin
9892
valid_indices[mask_index] <= j;
9993
mask_index <= mask_index + 1;
10094
end
@@ -123,11 +117,11 @@ always @(posedge clk) begin
123117
lane_index <= 0;
124118
end
125119
lane_index_d <= lane_index;
126-
valid_index <= (spi_lane_config_mask == ALL_ACTIVE_LANE_MASK) ? lane_index : valid_indices[lane_index_d];
120+
valid_index <= (lane_mask == ALL_ACTIVE_LANE_MASK) ? lane_index : valid_indices[lane_index_d];
127121
end else if (sdo_toshiftreg) begin
128122
last_handshake_int <= 1'b0;
129123
end
130124
end
131125
end
132126

133-
endmodule
127+
endmodule

0 commit comments

Comments
 (0)