diff options
author | Clifford Wolf <clifford@clifford.at> | 2018-06-06 17:08:58 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2018-06-06 17:08:58 +0200 |
commit | afbae1bb99f6a8cd13dbe96da89bb28a4c9aa3c1 (patch) | |
tree | 1d76901b87081a8e6ced886f985e5e4479b61df8 /ice40/main.cc | |
parent | a04436e19b80bc3d7e308cae2134c98b7a7d6473 (diff) | |
parent | 28e22769068fc41f8c87349a180e76565a2c297b (diff) | |
download | nextpnr-afbae1bb99f6a8cd13dbe96da89bb28a4c9aa3c1.tar.gz nextpnr-afbae1bb99f6a8cd13dbe96da89bb28a4c9aa3c1.tar.bz2 nextpnr-afbae1bb99f6a8cd13dbe96da89bb28a4c9aa3c1.zip |
Merge branch 'ice40-xy'
Diffstat (limited to 'ice40/main.cc')
-rw-r--r-- | ice40/main.cc | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/ice40/main.cc b/ice40/main.cc index afdd1a4a..a32aa2db 100644 --- a/ice40/main.cc +++ b/ice40/main.cc @@ -24,6 +24,22 @@ #include <boost/program_options.hpp> #include "pybindings.h" +void svg_dump_el(const GraphicElement &el) +{ + float scale = 10.0; + std::string style = "stroke=\"black\" stroke-width=\"0.1\" fill=\"none\""; + + if (el.type == GraphicElement::G_BOX) { + std::cout << "<rect x=\"" << (scale*el.x1) << "\" y=\"" << (scale*el.y1) << + "\" height=\"" << (scale*(el.y2-el.y1)) << "\" width=\"" << (scale*(el.x2-el.x1)) << "\" " << style << "/>\n"; + } + + if (el.type == GraphicElement::G_LINE) { + std::cout << "<line x1=\"" << (scale*el.x1) << "\" y1=\"" << (scale*el.y1) << + "\" x2=\"" << (scale*el.x2) << "\" y2=\"" << (scale*el.y2) << "\" " << style << "/>\n"; + } +} + int main(int argc, char *argv[]) { namespace po = boost::program_options; @@ -34,6 +50,7 @@ int main(int argc, char *argv[]) options.add_options()("help,h","show help"); options.add_options()("test","just a check"); options.add_options()("gui","start gui"); + options.add_options()("svg","dump SVG file"); options.add_options()("file", po::value<std::string>(), "python file to execute"); options.add_options()("version,v","show version"); @@ -71,6 +88,11 @@ int main(int argc, char *argv[]) return 1; } + ChipArgs chipArgs; + chipArgs.type = ChipArgs::LP384; + + Design design(chipArgs); + if (vm.count("gui")) { QApplication a(argc, argv); @@ -82,10 +104,6 @@ int main(int argc, char *argv[]) if (vm.count("test")) { - ChipArgs chipArgs; - chipArgs.type = ChipArgs::LP384; - - Design design(chipArgs); int bel_count = 0, wire_count = 0, pip_count = 0; std::cout << "Checking bel names.\n"; @@ -143,6 +161,20 @@ int main(int argc, char *argv[]) return 0; } + if (vm.count("svg")) + { + std::cout << "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n"; + for (auto bel : design.chip.getBels()) { + std::cout << "<!-- " << design.chip.getBelName(bel) << " -->\n"; + for (auto &el : design.chip.getBelGraphics(bel)) + svg_dump_el(el); + } + std::cout << "<!-- Frame -->\n"; + for (auto &el : design.chip.getFrameGraphics()) + svg_dump_el(el); + std::cout << "</svg>\n"; + } + if (vm.count("file")) { std::string filename = vm["file"].as<std::string>(); |