@@ -108,7 +108,8 @@ static void init_molecule_chain_info(const AtomBlockId blk_id,
108
108
109
109
static AtomBlockId get_sink_block (const AtomBlockId block_id,
110
110
const t_pack_pattern_connections& connections,
111
- const AtomNetlist& atom_nlist);
111
+ const AtomNetlist& atom_nlist,
112
+ bool is_chain_pattern);
112
113
113
114
static AtomBlockId get_driving_block (const AtomBlockId block_id,
114
115
const t_pack_pattern_connections& connections,
@@ -1045,7 +1046,7 @@ static bool try_expand_molecule(t_pack_molecule& molecule,
1045
1046
// this block is the driver of this connection
1046
1047
if (block_connection->from_block == pattern_block) {
1047
1048
// find the block this connection is driving and add it to the queue
1048
- auto sink_blk_id = get_sink_block (block_id, *block_connection, atom_nlist);
1049
+ auto sink_blk_id = get_sink_block (block_id, *block_connection, atom_nlist, molecule. is_chain () );
1049
1050
// add this sink block id with its corresponding pattern block to the queue
1050
1051
pattern_block_queue.push (std::make_pair (block_connection->to_block , sink_blk_id));
1051
1052
// this block is being driven by this connection
@@ -1075,7 +1076,8 @@ static bool try_expand_molecule(t_pack_molecule& molecule,
1075
1076
*/
1076
1077
static AtomBlockId get_sink_block (const AtomBlockId block_id,
1077
1078
const t_pack_pattern_connections& connections,
1078
- const AtomNetlist& atom_nlist) {
1079
+ const AtomNetlist& atom_nlist,
1080
+ bool is_chain_pattern) {
1079
1081
const t_model_ports* from_port_model = connections.from_pin ->port ->model_port ;
1080
1082
const int from_pin_number = connections.from_pin ->pin_number ;
1081
1083
auto from_port_id = atom_nlist.find_atom_port (block_id, from_port_model);
@@ -1086,19 +1088,24 @@ static AtomBlockId get_sink_block(const AtomBlockId block_id,
1086
1088
1087
1089
if (from_port_id) {
1088
1090
auto net_id = atom_nlist.port_net (from_port_id, from_pin_number);
1089
- // Iterate over all net sinks and find the one corresponding
1090
- // to the to_pin specified in the pack pattern connection
1091
1091
if (net_id.is_valid ()) {
1092
1092
const auto & net_sinks = atom_nlist.net_sinks (net_id);
1093
- for (const auto & sink_pin_id : net_sinks) {
1094
- auto sink_block_id = atom_nlist.pin_block (sink_pin_id);
1095
- if (primitive_type_feasible (sink_block_id, to_pb_type)) {
1096
- auto to_port_id = atom_nlist.find_atom_port (sink_block_id, to_port_model);
1097
- auto to_pin_id = atom_nlist.find_pin (to_port_id, BitIndex (to_pin_number));
1098
- if (to_pin_id == sink_pin_id) {
1099
- return sink_block_id;
1093
+ if (is_chain_pattern) {
1094
+ for (const auto & sink_pin_id : net_sinks) {
1095
+ auto sink_block_id = atom_nlist.pin_block (sink_pin_id);
1096
+ if (primitive_type_feasible (sink_block_id, to_pb_type)) {
1097
+ auto to_port_id = atom_nlist.find_atom_port (sink_block_id, to_port_model);
1098
+ auto to_pin_id = atom_nlist.find_pin (to_port_id, BitIndex (to_pin_number));
1099
+ if (to_pin_id == sink_pin_id) {
1100
+ return sink_block_id;
1101
+ }
1100
1102
}
1101
1103
}
1104
+ } else {
1105
+ if (net_sinks.size () == 1 ) {
1106
+ auto sink_pin_id = *(net_sinks.begin ());
1107
+ return atom_nlist.pin_block (sink_pin_id);
1108
+ }
1102
1109
}
1103
1110
}
1104
1111
}
@@ -1122,7 +1129,7 @@ static AtomBlockId get_driving_block(const AtomBlockId block_id,
1122
1129
1123
1130
if (to_port_id) {
1124
1131
auto net_id = atom_nlist.port_net (to_port_id, to_pin_number);
1125
- if (net_id) {
1132
+ if (net_id && atom_nlist. net_sinks (net_id). size () == 1 ) { /* Single fanout assumption */
1126
1133
auto driver_blk_id = atom_nlist.net_driver_block (net_id);
1127
1134
1128
1135
if (to_port_model->is_clock ) {
0 commit comments