@@ -3,57 +3,52 @@ module spi_engine_execution_shiftreg_data_assemble #(
3
3
parameter DATA_WIDTH = 8 ,
4
4
parameter NUM_OF_SDI = 1 ,
5
5
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
8
7
) (
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
24
23
);
25
24
26
25
// 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
28
27
// if not, non activated serial lines have their data fulfilled with idle_state and buffer the remaining activated lines
29
28
// also, in this mode it is not possible to prefetch data
30
29
30
+ reg last_handshake_int;
31
31
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 ;
34
34
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));
43
39
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 ] ;
49
45
50
46
assign data_assembled = aligned_data;
51
47
assign last_handshake = last_handshake_int;
52
48
53
49
// register data
54
50
always @(posedge clk) begin
55
51
if (resetn == 1'b0 ) begin
56
- // data_reg <= {(NUM_OF_SDI * DATA_WIDTH){idle_state}};
57
52
data_reg <= {DATA_WIDTH{idle_state}};
58
53
end else begin
59
54
if (data_ready && data_valid) begin
@@ -84,7 +79,6 @@ always @(posedge clk) begin
84
79
j <= 0 ;
85
80
end else begin
86
81
if (exec_lane_config_cmd) begin
87
- spi_lane_config_mask <= current_cmd[7 :0 ];
88
82
count_active_lanes = 0 ;
89
83
i = 0 ;
90
84
j <= 0 ;
@@ -94,7 +88,7 @@ always @(posedge clk) begin
94
88
num_active_lanes <= count_active_lanes;
95
89
end else begin
96
90
if (j < NUM_OF_SDI) begin
97
- if (spi_lane_config_mask [j]) begin
91
+ if (lane_mask [j]) begin
98
92
valid_indices[mask_index] <= j;
99
93
mask_index <= mask_index + 1 ;
100
94
end
@@ -123,11 +117,11 @@ always @(posedge clk) begin
123
117
lane_index <= 0 ;
124
118
end
125
119
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];
127
121
end else if (sdo_toshiftreg) begin
128
122
last_handshake_int <= 1'b0 ;
129
123
end
130
124
end
131
125
end
132
126
133
- endmodule
127
+ endmodule
0 commit comments