Skip to content

Commit

Permalink
Legalizer: Num bytes possible simplified
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMightyDuckOfDoom committed Sep 1, 2023
1 parent 603af6f commit 70a00c7
Showing 1 changed file with 93 additions and 144 deletions.
237 changes: 93 additions & 144 deletions src/backend/src/idma_legalizer.sv.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -391,84 +391,119 @@ w_tf_q.length[PageAddrWidth:0] ),
//--------------------------------------
// Synchronized R/W process
//--------------------------------------
% if one_read_port and one_write_port:
% if (no_read_bursting or no_write_bursting) or ('tilelink' in used_protocols):
assign r_num_bytes_possible = r_num_bytes_to_pb;
assign w_num_bytes_possible = w_num_bytes_to_pb;
% else:
assign r_num_bytes_possible = opt_tf_q.decouple_rw ?
r_num_bytes_to_pb : c_num_bytes_to_pb;
assign w_num_bytes_possible = opt_tf_q.decouple_rw ?
w_num_bytes_to_pb : c_num_bytes_to_pb;
% endif
% else:
% if no_read_bursting and no_write_bursting:
// No Bursting at all
assign r_num_bytes_possible = opt_tf_q.decouple_rw ?
r_num_bytes_to_pb : c_num_bytes_to_pb;
assign w_num_bytes_possible = opt_tf_q.decouple_rw ?
w_num_bytes_to_pb : c_num_bytes_to_pb;
% elif no_read_bursting and (not no_write_bursting):
// Only write bursts possible
assign r_num_bytes_possible = r_num_bytes_to_pb;
assign w_num_bytes_possible = (opt_tf_q.decouple_rw || (opt_tf_q.dst_protocol inside {\
% for index, protocol in enumerate(used_non_bursting_write_protocols):
idma_pkg::${database[protocol]['protocol_enum']}\
% if index != len(used_non_bursting_write_protocols)-1:
,\
% endif
% endfor
})) ?
w_num_bytes_to_pb : c_num_bytes_to_pb;
% elif (not no_read_bursting) and no_write_bursting:
// Only read bursts possible
assign w_num_bytes_possible = w_num_bytes_to_pb;
assign r_num_bytes_possible = (opt_tf_q.decouple_rw || (opt_tf_q.src_protocol inside {\
% for index, protocol in enumerate(used_non_bursting_read_protocols):
idma_pkg::${database[protocol]['protocol_enum']}\
% if index != len(used_non_bursting_read_protocols)-1:
,\
% endif
% endfor
})) ?
r_num_bytes_to_pb : c_num_bytes_to_pb;
% else:
// Both read and write bursts possible
always_comb begin
##% if one_read_port and one_write_port:
## % if (no_read_bursting or no_write_bursting) or ('tilelink' in used_protocols):
## assign r_num_bytes_possible = r_num_bytes_to_pb;
## assign w_num_bytes_possible = w_num_bytes_to_pb;
## % else:
## assign r_num_bytes_possible = opt_tf_q.decouple_rw ?
## r_num_bytes_to_pb : c_num_bytes_to_pb;
## assign w_num_bytes_possible = opt_tf_q.decouple_rw ?
## w_num_bytes_to_pb : c_num_bytes_to_pb;
## % endif
##% else:
## % if no_read_bursting and no_write_bursting:
## // No Bursting at all
## assign r_num_bytes_possible = opt_tf_q.decouple_rw ?
## r_num_bytes_to_pb : c_num_bytes_to_pb;
## assign w_num_bytes_possible = opt_tf_q.decouple_rw ?
## w_num_bytes_to_pb : c_num_bytes_to_pb;
## % elif no_read_bursting and (not no_write_bursting):
## // Only write bursts possible
## assign r_num_bytes_possible = r_num_bytes_to_pb;
## assign w_num_bytes_possible = (opt_tf_q.decouple_rw || (opt_tf_q.dst_protocol inside {\
## % for index, protocol in enumerate(used_non_bursting_write_protocols):
## idma_pkg::${database[protocol]['protocol_enum']}\
## % if index != len(used_non_bursting_write_protocols)-1:
##,\
## % endif
## % endfor
## })) ?
## w_num_bytes_to_pb : c_num_bytes_to_pb;
## % elif (not no_read_bursting) and no_write_bursting:
## // Only read bursts possible
## assign w_num_bytes_possible = w_num_bytes_to_pb;
## assign r_num_bytes_possible = (opt_tf_q.decouple_rw || (opt_tf_q.src_protocol inside {\
## % for index, protocol in enumerate(used_non_bursting_read_protocols):
## idma_pkg::${database[protocol]['protocol_enum']}\
## % if index != len(used_non_bursting_read_protocols)-1:
##,\
## % endif
## % endfor
## })) ?
## r_num_bytes_to_pb : c_num_bytes_to_pb;
## % else:
## // Both read and write bursts possible
## always_comb begin
## r_num_bytes_possible = c_num_bytes_to_pb;
## w_num_bytes_possible = c_num_bytes_to_pb;

## if ( opt_tf_q.decouple_rw\
## % if len(used_non_bursting_read_protocols) != 0:

## || (opt_tf_q.src_protocol inside {\
## % for index, protocol in enumerate(used_non_bursting_read_protocols):
## idma_pkg::${database[protocol]['protocol_enum']}\
## % if index != len(used_non_bursting_read_protocols)-1:
##,\
## % endif
## % endfor
## })\
## % endif
## % if len(used_non_bursting_write_protocols) != 0:

## || (opt_tf_q.dst_protocol inside {\
## % for index, protocol in enumerate(used_non_bursting_write_protocols):
## idma_pkg::${database[protocol]['protocol_enum']}\
## % if index != len(used_non_bursting_write_protocols)-1:
##,\
## % endif
## % endfor
## })\
## % endif

## ) begin
## r_num_bytes_possible = r_num_bytes_to_pb;
## w_num_bytes_possible = w_num_bytes_to_pb;
## end
## end
## % endif
##% endif
always_comb begin : proc_num_bytes_possible
// Default: Coupled
r_num_bytes_possible = c_num_bytes_to_pb;
w_num_bytes_possible = c_num_bytes_to_pb;

if ( opt_tf_q.decouple_rw\
% if len(used_non_bursting_read_protocols) != 0:
if (opt_tf_q.decouple_rw\
% if len(used_non_bursting_or_force_decouple_read_protocols) != 0:

|| (opt_tf_q.src_protocol inside {\
% for index, protocol in enumerate(used_non_bursting_read_protocols):
% for index, protocol in enumerate(used_non_bursting_or_force_decouple_read_protocols):
idma_pkg::${database[protocol]['protocol_enum']}\
% if index != len(used_non_bursting_read_protocols)-1:
% if index != len(used_non_bursting_or_force_decouple_read_protocols)-1:
,\
% endif
% endfor
})\
% endif
% if len(used_non_bursting_write_protocols) != 0:
)
r_num_bytes_possible = r_num_bytes_to_pb;

if (opt_tf_q.decouple_rw\
% if len(used_non_bursting_or_force_decouple_write_protocols) != 0:

|| (opt_tf_q.dst_protocol inside {\
% for index, protocol in enumerate(used_non_bursting_write_protocols):
% for index, protocol in enumerate(used_non_bursting_or_force_decouple_write_protocols):
idma_pkg::${database[protocol]['protocol_enum']}\
% if index != len(used_non_bursting_write_protocols)-1:
% if index != len(used_non_bursting_or_force_decouple_write_protocols)-1:
,\
% endif
% endfor
})\
% endif

) begin
r_num_bytes_possible = r_num_bytes_to_pb;
)
w_num_bytes_possible = w_num_bytes_to_pb;
end
end
% endif
% endif

assign r_addr_offset = r_tf_q.addr[OffsetWidth-1:0];
assign w_addr_offset = w_tf_q.addr[OffsetWidth-1:0];
Expand Down Expand Up @@ -692,93 +727,7 @@ ${database[protocol]['legalizer_write_data_path']}
// only advance to next state if:
// * rw_coupled: both machines advance
// * rw_decoupled: either machine advances
## // Decouple Logic
## // if 1R1W:
## // if onesided_bursting OR tilelink:
## // -> force decouple
## // else:
## // -> optional decouple
## // else: // Multiport DMA
## // -> optional decouple
## //
## // if protocol IS nonbursting:
## // -> force decouple
## // Single Read / Single Write Port DMA
##% if one_read_port and one_write_port:
## // Check if onesided bursting
## % if (no_read_bursting != no_write_bursting) or 'tilelink' in used_protocols:
## // Onesided bursting -> force decouple
## always_comb begin : proc_legalizer_flow_control
## // Onesided bursting -> decouple
## r_tf_ena = (r_ready_i & !flush_i) | kill_i;
## w_tf_ena = (w_ready_i & !flush_i) | kill_i;
## r_valid_o = r_tf_q.valid & r_ready_i & !flush_i;
## w_valid_o = w_tf_q.valid & w_ready_i & !flush_i;
## end
## % else:
## // Read and Write Port have same bursting behaviour -> Optional decouple
## always_comb begin : proc_legalizer_flow_control
## // Both Protocols have same bursting behaviour -> Optional decouple
## if ( opt_tf_q.decouple_rw ) begin
## r_tf_ena = (r_ready_i & !flush_i) | kill_i;
## w_tf_ena = (w_ready_i & !flush_i) | kill_i;
## r_valid_o = r_tf_q.valid & r_ready_i & !flush_i;
## w_valid_o = w_tf_q.valid & w_ready_i & !flush_i;
## end else begin
## r_tf_ena = (r_ready_i & w_ready_i & !flush_i) | kill_i;
## w_tf_ena = (r_ready_i & w_ready_i & !flush_i) | kill_i;
## r_valid_o = r_tf_q.valid & w_ready_i & r_ready_i & !flush_i;
## w_valid_o = w_tf_q.valid & r_ready_i & w_ready_i & !flush_i;
## end
## end
## % endif
##% else:
## always_comb begin : proc_legalizer_flow_control
## if ( opt_tf_q.decouple_rw\
## % if (not one_read_port) or (not one_write_port):
## % if len(used_non_bursting_read_protocols) != 0:
## || (opt_tf_q.src_protocol inside {\
## % for index, protocol in enumerate(used_non_bursting_read_protocols):
## idma_pkg::${database[protocol]['protocol_enum']}\
## % if index != len(used_non_bursting_read_protocols)-1:
##,\
## % endif
## % endfor
## })\
## % endif
## % if len(used_non_bursting_write_protocols) != 0:
## || (opt_tf_q.dst_protocol inside {\
## % for index, protocol in enumerate(used_non_bursting_write_protocols):
## idma_pkg::${database[protocol]['protocol_enum']}\
## % if index != len(used_non_bursting_write_protocols)-1:
##,\
## % endif
## % endfor
## })\
## % endif
## % endif
## ) begin
## r_tf_ena = (r_ready_i & !flush_i) | kill_i;
## w_tf_ena = (w_ready_i & !flush_i) | kill_i;
## r_valid_o = r_tf_q.valid & r_ready_i & !flush_i;
## w_valid_o = w_tf_q.valid & w_ready_i & !flush_i;
## end else begin
## r_tf_ena = (r_ready_i & w_ready_i & !flush_i) | kill_i;
## w_tf_ena = (r_ready_i & w_ready_i & !flush_i) | kill_i;
## r_valid_o = r_tf_q.valid & w_ready_i & r_ready_i & !flush_i;
## w_valid_o = w_tf_q.valid & r_ready_i & w_ready_i & !flush_i;
## end
## end
##% endif
always_comb begin : proc_legalizer_flow_control
if ( opt_tf_q.decouple_rw\
% if len(used_non_bursting_or_force_decouple_read_protocols) != 0:
Expand Down

0 comments on commit 70a00c7

Please sign in to comment.