partially support verilog

This commit is contained in:
liulixinkerry 2024-04-29 11:09:45 +08:00
parent 21209686c5
commit 50897f14dc
4 changed files with 19 additions and 12 deletions

View File

@ -110,12 +110,11 @@ Suppose there is a LEF/DEF benchmark named `toy` in `data/raw`, you can use the
python main.py --custom_path lef:data/raw/toy_input.lef,def:data/raw/toy_input.def,design_name:toy,benchmark:test --load_from_raw True --detail_placement True python main.py --custom_path lef:data/raw/toy_input.lef,def:data/raw/toy_input.def,design_name:toy,benchmark:test --load_from_raw True --detail_placement True
``` ```
You can also use the argument `--custom_json` to run multiple LEFs + DEF: You can also use the argument `--custom_json` to run multiple LEFs + DEF + Verilog:
``` ```
python main.py --custom_json examples/examples.json --load_from_raw True --target_density 0.9 python main.py --custom_json examples/examples.json --load_from_raw True --target_density 0.9
``` ```
Please provide your LEFs/DEF in the input `json` file. An example of [ASAP7](https://github.com/The-OpenROAD-Project/asap7) input is given in `./examples/examples.json`. Please provide your LEFs/DEF in the input `json` file. An example of [ASAP7](https://github.com/The-OpenROAD-Project/asap7) input is given in `./examples/examples.json`. Note that the `verilog` format is only partially supported.
## Load design from preprocessed `pt` file (Optional) ## Load design from preprocessed `pt` file (Optional)
The following script will dump the parsed design into a single torch `pt` file so Xplace can load the design from the `pt` file instead of parsing the input file from scratch. The following script will dump the parsed design into a single torch `pt` file so Xplace can load the design from the `pt` file instead of parsing the input file from scratch.

View File

@ -53,10 +53,10 @@ void Database::load() {
readConstraints(setting.Constraints); readConstraints(setting.Constraints);
} }
// verilog is unused now if (setting.Verilog != "") {
// if (setting.Verilog != "") { readVerilog(setting.Verilog);
// readVerilog(setting.Verilog); }
// }
logger.info("Finish loading rawdb"); logger.info("Finish loading rawdb");
} }

View File

@ -72,6 +72,7 @@ bool readVerilogLine(istream &is, vector<string> &tokens) {
} }
bool Database::readVerilog(const std::string &file) { bool Database::readVerilog(const std::string &file) {
logger.info("Reading verilog...");
ifstream fs(file.c_str()); ifstream fs(file.c_str());
if (!fs.good()) { if (!fs.good()) {
logger.error("cannot open verilog file: %s", file.c_str()); logger.error("cannot open verilog file: %s", file.c_str());
@ -120,7 +121,7 @@ bool Database::readVerilog(const std::string &file) {
} }
} }
if (tokens.back() == ";") { if (!tokens.empty() && tokens.back() == ";") {
tokens.pop_back(); tokens.pop_back();
finished = true; finished = true;
} }
@ -134,7 +135,12 @@ bool Database::readVerilog(const std::string &file) {
if (!iopin) { if (!iopin) {
logger.error("io pin not found: %s", pinName.c_str()); logger.error("io pin not found: %s", pinName.c_str());
} }
Pin* pin = iopin->pin;
iopin->is_connected = true;
Net *net = addNet(pinName); Net *net = addNet(pinName);
pin->net = net;
pin->is_connected = true;
net->addPin(iopin->pin); net->addPin(iopin->pin);
} }
} else if (status == StatusWire) { } else if (status == StatusWire) {
@ -151,8 +157,11 @@ bool Database::readVerilog(const std::string &file) {
string netName(tokens[3 + i * 2]); string netName(tokens[3 + i * 2]);
Pin *pin = cell->pin(pinName); Pin *pin = cell->pin(pinName);
Net *net = this->getNet(netName); Net *net = this->getNet(netName);
pin->net = net;
net->addPin(pin); net->addPin(pin);
pin->is_connected = true;
} }
cell->is_connected = true;
} }
} }

View File

@ -47,10 +47,9 @@ bool loadParams(const py::dict& kwargs) {
return false; return false;
} }
// verilog is unused now if (kwargs.contains("verilog")) {
// if (kwargs.contains("verilog")) { db::setting.Verilog = kwargs["verilog"].cast<std::string>();
// db::setting.Verilog = kwargs["verilog"].cast<std::string>(); }
// }
// ----- other options ----- // ----- other options -----