@@ -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;
3131reg [(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
5046assign data_assembled = aligned_data;
5147assign last_handshake = last_handshake_int;
5248
5349// register data
5450always @(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
131125end
132126
133- endmodule
127+ endmodule
0 commit comments