Add IO_PORT parsing

Signed-off-by: YRabbit <rabbit@yrabbit.cyou>
This commit is contained in:
YRabbit 2021-07-02 14:00:20 +10:00
parent fe38e70dc1
commit a65f0e57b9

View File

@ -483,37 +483,50 @@ DelayQuad Arch::getWireTypeDelay(IdString wire)
void Arch::read_cst(std::istream &in) void Arch::read_cst(std::istream &in)
{ {
std::regex iobre = std::regex("IO_LOC +\"([^\"]+)\" +([^ ;]+);"); std::regex iobre = std::regex("IO_LOC +\"([^\"]+)\" +([^ ;]+) *;.*");
std::regex portre = std::regex("IO_PORT +\"([^\"]+)\" +([^ =;]+)=([^ =;]+) *;.*");
std::smatch match; std::smatch match;
std::string line; std::string line;
boolean io_loc;
while (!in.eof()) { while (!in.eof()) {
std::getline(in, line); std::getline(in, line);
io_loc = true;
if (!std::regex_match(line, match, iobre)) { if (!std::regex_match(line, match, iobre)) {
// empty line or comment // empty line or comment
if (line.empty() || line.rfind("//", 0) == 0) { if (line.empty()) == 0) {
continue; continue;
} else { } else {
log_warning("Invalid constraint: %s\n", line.c_str()); if (!std::regex_match(line, match, portre)) {
continue; io_loc = false;
} else if (line.rfind("//", 0) == 0) {
log_warning("Invalid constraint: %s\n", line.c_str());
continue;
}
} }
} }
// std::cout << match[1] << " " << match[2] << std::endl; // std::cout << match[1] << " " << match[2] << std::endl;
IdString net = id(match[1]); IdString net = id(match[1]);
IdString pinname = id(match[2]);
const PairPOD *belname = pairLookup(package->pins.get(), package->num_pins, pinname.index);
if (belname == nullptr)
log_error("Pin %s not found\n", pinname.c_str(this));
// BelId bel = getBelByName(belname->src_id);
// for (auto cell : sorted(cells)) {
// std::cout << cell.first.str(this) << std::endl;
// }
auto it = cells.find(net); auto it = cells.find(net);
if (it == cells.end()) { if (it == cells.end()) {
log_info("Cell %s not found\n", net.c_str(this)); log_info("Cell %s not found\n", net.c_str(this));
continue; continue;
} }
std::string bel = IdString(belname->src_id).str(this); if (io_loc) { // IO_LOC name pin
it->second->attrs[IdString(ID_BEL)] = bel; IdString pinname = id(match[2]);
const PairPOD *belname = pairLookup(package->pins.get(), package->num_pins, pinname.index);
if (belname == nullptr)
log_error("Pin %s not found\n", pinname.c_str(this));
// BelId bel = getBelByName(belname->src_id);
// for (auto cell : sorted(cells)) {
// std::cout << cell.first.str(this) << std::endl;
// }
std::string bel = IdString(belname->src_id).str(this);
it->second->attrs[IdString(ID_BEL)] = bel;
} else { // IO_PORT attr=value
// XXX
log_info("XXX port attr found %s=%s\n", match[2], match[3]);
}
} }
} }