nexus: Refactor cell pin style db
Signed-off-by: David Shah <dave@ds0.me>
This commit is contained in:
parent
7f03f4d896
commit
0eb5c72cc5
@ -117,6 +117,7 @@ Arch::Arch(ArchArgs args) : args(args)
|
|||||||
for (size_t i = 0; i < chip_info->num_tiles; i++) {
|
for (size_t i = 0; i < chip_info->num_tiles; i++) {
|
||||||
tileStatus[i].boundcells.resize(db->loctypes[chip_info->grid[i].loc_type].num_bels);
|
tileStatus[i].boundcells.resize(db->loctypes[chip_info->grid[i].loc_type].num_bels);
|
||||||
}
|
}
|
||||||
|
init_cell_pin_data();
|
||||||
// Validate and set up package
|
// Validate and set up package
|
||||||
package_idx = -1;
|
package_idx = -1;
|
||||||
for (size_t i = 0; i < chip_info->num_packages; i++) {
|
for (size_t i = 0; i < chip_info->num_packages; i++) {
|
||||||
|
@ -1364,7 +1364,10 @@ struct Arch : BaseCtx
|
|||||||
|
|
||||||
typedef std::unordered_map<IdString, CellPinStyle> CellPinsData;
|
typedef std::unordered_map<IdString, CellPinStyle> CellPinsData;
|
||||||
|
|
||||||
void get_cell_pin_data(std::unordered_map<IdString, CellPinsData> &cell_pins) const;
|
std::unordered_map<IdString, CellPinsData> cell_pins_db;
|
||||||
|
CellPinStyle get_cell_pin_style(CellInfo *cell, IdString port) const;
|
||||||
|
|
||||||
|
void init_cell_pin_data();
|
||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
|
|
||||||
|
@ -30,8 +30,6 @@ struct NexusFasmWriter
|
|||||||
std::ostream &out;
|
std::ostream &out;
|
||||||
std::vector<std::string> fasm_ctx;
|
std::vector<std::string> fasm_ctx;
|
||||||
|
|
||||||
std::unordered_map<IdString, Arch::CellPinsData> cell_pins_db;
|
|
||||||
|
|
||||||
NexusFasmWriter(const Context *ctx, std::ostream &out) : ctx(ctx), out(out) {}
|
NexusFasmWriter(const Context *ctx, std::ostream &out) : ctx(ctx), out(out) {}
|
||||||
|
|
||||||
// Add a 'dot' prefix to the FASM context stack
|
// Add a 'dot' prefix to the FASM context stack
|
||||||
@ -285,8 +283,6 @@ struct NexusFasmWriter
|
|||||||
// Write out FASM for the whole design
|
// Write out FASM for the whole design
|
||||||
void operator()()
|
void operator()()
|
||||||
{
|
{
|
||||||
// Setup pin DB
|
|
||||||
ctx->get_cell_pin_data(cell_pins_db);
|
|
||||||
// Write routing
|
// Write routing
|
||||||
for (auto n : sorted(ctx->nets)) {
|
for (auto n : sorted(ctx->nets)) {
|
||||||
write_net(n.second);
|
write_net(n.second);
|
||||||
|
@ -99,8 +99,6 @@ struct NexusPacker
|
|||||||
{
|
{
|
||||||
Context *ctx;
|
Context *ctx;
|
||||||
|
|
||||||
std::unordered_map<IdString, Arch::CellPinsData> cell_db;
|
|
||||||
|
|
||||||
// Generic cell transformation
|
// Generic cell transformation
|
||||||
// Given cell name map and port map
|
// Given cell name map and port map
|
||||||
// If port name is not found in port map; it will be copied as-is but stripping []
|
// If port name is not found in port map; it will be copied as-is but stripping []
|
||||||
@ -319,30 +317,12 @@ struct NexusPacker
|
|||||||
return new_net;
|
return new_net;
|
||||||
}
|
}
|
||||||
|
|
||||||
CellPinStyle get_pin_style(CellInfo *cell, IdString port)
|
|
||||||
{
|
|
||||||
// Look up the pin style in the cell database
|
|
||||||
auto fnd_cell = cell_db.find(cell->type);
|
|
||||||
if (fnd_cell == cell_db.end())
|
|
||||||
return PINSTYLE_NONE;
|
|
||||||
auto fnd_port = fnd_cell->second.find(port);
|
|
||||||
if (fnd_port != fnd_cell->second.end())
|
|
||||||
return fnd_port->second;
|
|
||||||
// If there isn't an exact port match, then the empty IdString
|
|
||||||
// represents a wildcard default match
|
|
||||||
auto fnd_default = fnd_cell->second.find({});
|
|
||||||
if (fnd_default != fnd_cell->second.end())
|
|
||||||
return fnd_default->second;
|
|
||||||
|
|
||||||
return PINSTYLE_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
CellPinMux get_pin_needed_muxval(CellInfo *cell, IdString port)
|
CellPinMux get_pin_needed_muxval(CellInfo *cell, IdString port)
|
||||||
{
|
{
|
||||||
NetInfo *net = get_net_or_empty(cell, port);
|
NetInfo *net = get_net_or_empty(cell, port);
|
||||||
if (net == nullptr || net->driver.cell == nullptr) {
|
if (net == nullptr || net->driver.cell == nullptr) {
|
||||||
// Pin is disconnected, return its default value
|
// Pin is disconnected, return its default value
|
||||||
CellPinStyle pin_style = get_pin_style(cell, port);
|
CellPinStyle pin_style = ctx->get_cell_pin_style(cell, port);
|
||||||
if ((pin_style & PINDEF_MASK) == PINDEF_0)
|
if ((pin_style & PINDEF_MASK) == PINDEF_0)
|
||||||
return PINMUX_0;
|
return PINMUX_0;
|
||||||
else if ((pin_style & PINDEF_MASK) == PINDEF_1)
|
else if ((pin_style & PINDEF_MASK) == PINDEF_1)
|
||||||
@ -450,7 +430,7 @@ struct NexusPacker
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CellPinStyle pin_style = get_pin_style(cell, port_name);
|
CellPinStyle pin_style = ctx->get_cell_pin_style(cell, port_name);
|
||||||
|
|
||||||
if (req_mux == PINMUX_INV) {
|
if (req_mux == PINMUX_INV) {
|
||||||
// Pin is inverted. If there is a hard inverter; then use it
|
// Pin is inverted. If there is a hard inverter; then use it
|
||||||
@ -648,7 +628,6 @@ struct NexusPacker
|
|||||||
|
|
||||||
void operator()()
|
void operator()()
|
||||||
{
|
{
|
||||||
ctx->get_cell_pin_data(cell_db);
|
|
||||||
pack_ffs();
|
pack_ffs();
|
||||||
pack_luts();
|
pack_luts();
|
||||||
pack_io();
|
pack_io();
|
||||||
|
@ -74,9 +74,24 @@ static const std::unordered_map<IdString, Arch::CellPinsData> base_cell_pin_data
|
|||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void Arch::get_cell_pin_data(std::unordered_map<IdString, CellPinsData> &cell_pins) const
|
void Arch::init_cell_pin_data() { cell_pins_db = base_cell_pin_data; }
|
||||||
|
|
||||||
|
CellPinStyle Arch::get_cell_pin_style(CellInfo *cell, IdString port) const
|
||||||
{
|
{
|
||||||
cell_pins = base_cell_pin_data;
|
// Look up the pin style in the cell database
|
||||||
|
auto fnd_cell = cell_pins_db.find(cell->type);
|
||||||
|
if (fnd_cell == cell_pins_db.end())
|
||||||
|
return PINSTYLE_NONE;
|
||||||
|
auto fnd_port = fnd_cell->second.find(port);
|
||||||
|
if (fnd_port != fnd_cell->second.end())
|
||||||
|
return fnd_port->second;
|
||||||
|
// If there isn't an exact port match, then the empty IdString
|
||||||
|
// represents a wildcard default match
|
||||||
|
auto fnd_default = fnd_cell->second.find({});
|
||||||
|
if (fnd_default != fnd_cell->second.end())
|
||||||
|
return fnd_default->second;
|
||||||
|
|
||||||
|
return PINSTYLE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
Loading…
Reference in New Issue
Block a user