diff options
Diffstat (limited to 'mistral/arch.h')
-rw-r--r-- | mistral/arch.h | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/mistral/arch.h b/mistral/arch.h index 9c38d5d2..98340d4e 100644 --- a/mistral/arch.h +++ b/mistral/arch.h @@ -461,9 +461,41 @@ struct Arch : BaseArch<ArchRanges> void add_bel_pin(BelId bel, IdString pin, PortType dir, WireId wire); + CycloneV::rnode_t find_rnode(CycloneV::block_type_t bt, int x, int y, CycloneV::port_type_t port, int bi = -1, int pi = -1) const + { + auto pn1 = CycloneV::pnode(bt, x, y, port, bi, pi); + auto rn1 = cyclonev->pnode_to_rnode(pn1); + if(rn1) + return rn1; + + if(bt == CycloneV::GPIO) { + auto pn2 = cyclonev->p2p_to(pn1); + if(!pn2) { + auto pnv = cyclonev->p2p_from(pn1); + if(!pnv.empty()) + pn2 = pnv[0]; + } + auto pn3 = cyclonev->hmc_get_bypass(pn2); + auto rn2 = cyclonev->pnode_to_rnode(pn3); + return rn2; + } + + return 0; + } + WireId get_port(CycloneV::block_type_t bt, int x, int y, int bi, CycloneV::port_type_t port, int pi = -1) const { - return WireId(cyclonev->pnode_to_rnode(CycloneV::pnode(bt, x, y, port, bi, pi))); + auto rn = find_rnode(bt, x, y, port, bi, pi); + if(rn) + return WireId(rn); + + fprintf(stderr, "Trying to connect unknown node %s\n", CycloneV::pn2s(CycloneV::pnode(bt, x, y, port, bi, pi)).c_str()); + exit(1); + } + + bool has_port(CycloneV::block_type_t bt, int x, int y, int bi, CycloneV::port_type_t port, int pi = -1) const + { + return find_rnode(bt, x, y, port, bi, pi) != 0; } void create_lab(int x, int y, bool is_mlab); // lab.cc |