@@ -510,7 +510,8 @@ struct DesignEditRapidSilicon : public ScriptPass {
510510 if (in_bit.wire != nullptr )
511511 {
512512 remove_fab_prims.push_back (cell);
513- if (fab_ins.count (in_bit) && fab_outs.count (out_bit))
513+ if (new_ins.find (in_bit.wire ->name .str ()) != new_ins.end () &&
514+ new_outs.find (out_bit.wire ->name .str ()) != new_outs.end ())
514515 {
515516 RTLIL::SigSig new_conn;
516517 new_conn.first = out_bit;
@@ -541,7 +542,8 @@ struct DesignEditRapidSilicon : public ScriptPass {
541542 if (in_bit.wire != nullptr )
542543 {
543544 remove_fab_prims.push_back (cell);
544- if (fab_ins.count (in_bit) && fab_outs.count (out_bit))
545+ if (new_ins.find (in_bit.wire ->name .str ()) != new_ins.end () &&
546+ new_outs.find (out_bit.wire ->name .str ()) != new_outs.end ())
545547 {
546548 RTLIL::SigSig new_conn;
547549 new_conn.first = out_bit;
@@ -575,6 +577,7 @@ struct DesignEditRapidSilicon : public ScriptPass {
575577 if (cell->type == RTLIL::escape_id (" O_FAB" ) ||
576578 cell->type == RTLIL::escape_id (" I_FAB" )) continue ;
577579
580+ string module_name = remove_backslashes (cell->type .str ());
578581 for (auto conn : cell->connections ())
579582 {
580583 IdString portName = conn.first ;
@@ -584,22 +587,44 @@ struct DesignEditRapidSilicon : public ScriptPass {
584587 {
585588 if (ofab_sig_map.count (bit))
586589 {
587- const std::vector<RTLIL::SigBit> outbits = ofab_sig_map[bit];
588- if (outbits. size () < 1 ) sigspec. append (bit);
589- if (outbits. size () == 1 )
590+
591+ if (( std::find (primitives. begin (), primitives. end (), module_name) !=
592+ primitives. end ()) && cell-> input (portName) )
590593 {
594+ const std::vector<RTLIL::SigBit> outbits = ofab_sig_map[bit];
595+ RTLIL::SigSig new_conn;
596+ RTLIL::Wire *new_wire = mod->addWire (NEW_ID, 1 );
597+ new_outs.erase (bit.wire ->name .str ());
598+ new_outs.insert (new_wire->name .str ());
599+ new_conn.first = new_wire;
600+ new_conn.second = outbits[0 ];
601+ mod->connect (new_conn);
591602 if (unset_port)
592- {
593- cell->unsetPort (portName);
594- unset_port = false ;
595- }
596- sigspec.append (outbits[0 ]);
597- } else if (outbits.size () > 1 )
603+ {
604+ cell->unsetPort (portName);
605+ unset_port = false ;
606+ }
607+ sigspec.append (new_wire);
608+ }
609+ else
598610 {
599- sigspec.append (bit);
600- if (ofab_conns.find (bit) == ofab_conns.end ())
611+ const std::vector<RTLIL::SigBit> outbits = ofab_sig_map[bit];
612+ if (outbits.size () < 1 ) sigspec.append (bit);
613+ if (outbits.size () == 1 )
614+ {
615+ if (unset_port)
616+ {
617+ cell->unsetPort (portName);
618+ unset_port = false ;
619+ }
620+ sigspec.append (outbits[0 ]);
621+ } else if (outbits.size () > 1 )
601622 {
602- ofab_conns.insert ({bit, outbits});
623+ sigspec.append (bit);
624+ if (ofab_conns.find (bit) == ofab_conns.end ())
625+ {
626+ ofab_conns.insert ({bit, outbits});
627+ }
603628 }
604629 }
605630 } else {
@@ -1683,6 +1708,7 @@ struct DesignEditRapidSilicon : public ScriptPass {
16831708 elapsed_time (start, end);
16841709 intersection_copy_remove (new_ins, new_outs, interface_wires);
16851710 intersect (interface_wires, keep_wires);
1711+ remove_io_fab_prim (original_mod);
16861712 }
16871713
16881714 Module *interface_mod = _design->top_module ()->clone ();
@@ -1844,8 +1870,6 @@ struct DesignEditRapidSilicon : public ScriptPass {
18441870
18451871 get_fabric_ios (original_mod);
18461872
1847- remove_io_fab_prim (original_mod);
1848-
18491873 start = high_resolution_clock::now ();
18501874 log (" Deleting non-primitive cells and upgrading wires to ports in interface module\n " );
18511875 for (auto cell : interface_mod->cells ()) {
0 commit comments