MCPcopy Create free account
hub / github.com/PKU-IDEA/OpenPARF / readXML

Method readXML

openparf/database/database.cpp:670–815  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

668};
669
670void Database::readXML(std::string const &xml_file) {
671 pugi::xml_document doc;
672 pugi::xml_parse_result result = doc.load_file(xml_file.c_str());
673 pugi::xml_node arch = doc.document_element();
674 pugi::xml_node core = arch.child("core");
675 auto StrBeginWith = [](const std::string &a, const std::string &b) { return a.rfind(b, 0) == 0; };
676 // We use the bookshelf parsers's callbacks
677 BookshelfDatabaseCallbacks cbk(*this);
678 // Add cells/models/primitives
679 openparfPrint(kDebug, "XML Parser: Adding primitives:\n");
680 int32_t num_primitive = 0;
681 for (pugi::xml_node primitive : arch.child("primitives").children("primitive")) {
682 num_primitive++;
683 std::string primitive_name = primitive.attribute("name").as_string();
684 cbk.addCellCbk(primitive_name);
685 openparfPrint(kDebug, " Model %s added.\n", primitive.attribute("name").value());
686 for (pugi::xml_node pin : primitive.children()) {
687 for (int cnt = 0; cnt < pin.attribute("width").as_int(); cnt++) {
688 std::string pin_name = pin.attribute("name").as_string();
689 if (pin.attribute("width").as_int() > 1) {
690 pin_name += "[" + std::to_string(cnt) + "]";
691 }
692 std::string pin_type = pin.name();
693 std::string pin_attr = pin.attribute("attr").value();
694 if (pin_type == "input" && pin_attr == "enable") {
695 cbk.addCellCtrlCEPinCbk(pin_name);
696 } else if (pin_type == "input" && pin_attr == "clock") {
697 cbk.addCellClockPinCbk(pin_name);
698 } else if (pin_type == "input" && pin_attr == "reset") {
699 cbk.addCellCtrlSRPinCbk(pin_name);
700 } else if (primitive_name == "CLA4" && StrBeginWith(pin_name, "CAS_IN")) {
701 cbk.addCellInputCasPinCbk(pin_name);
702 } else if (primitive_name == "CLA4" && StrBeginWith(pin_name, "CAS_OUT")) {
703 cbk.addCellOutputCasPinCbk(pin_name);
704 } else if (primitive_name == "DSP0" && StrBeginWith(pin_name, "PCIN")) {
705 cbk.addCellInputCasPinCbk(pin_name);
706 } else if (primitive_name == "DSP0" && StrBeginWith(pin_name, "PCOUT")) {
707 cbk.addCellOutputCasPinCbk(pin_name);
708 } else if (pin_type == "input") {
709 cbk.addCellInputPinCbk(pin_name);
710 } else if (pin_type == "output") {
711 cbk.addCellOutputPinCbk(pin_name);
712 } else {
713 openparfAssertMsg(false, "Unknown pin type %s\n", pin_type);
714 }
715 }
716 }
717 }
718 openparfPrint(kDebug, "Added %i primitives \n", num_primitive);
719
720 // Add sites types and resources
721 std::unordered_map<std::string, std::pair<int32_t, int32_t>> tile_size;
722 for (pugi::xml_node tile : arch.child("tile_blocks").children("tile")) {
723 int32_t width = tile.attribute("width").as_int();
724 int32_t height = tile.attribute("height").as_int();
725 std::string type = tile.attribute("type").value();
726 tile_size.emplace(type, std::make_pair(width, height));
727 openparfPrint(kDebug, "Tile %s has a size (%i, %i)\n", type.c_str(), width, height);

Callers 1

placeFunction · 0.95

Calls 15

openparfPrintFunction · 0.85
load_fileMethod · 0.80
document_elementMethod · 0.80
childMethod · 0.80
childrenMethod · 0.80
as_stringMethod · 0.80
attributeMethod · 0.80
as_intMethod · 0.80
setSiteResourcesMethod · 0.80
next_siblingMethod · 0.80
overlapAtMethod · 0.80

Tested by

no test coverage detected