From f9bd66e7ac4d52ef4dfe96373450eb46aa195eab Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Wed, 6 Jun 2018 17:23:58 +0200 Subject: [PATCH] Add iCE40 device selection, improve iCE40 IO GraphicElements Signed-off-by: Clifford Wolf --- ice40/chip.cc | 40 ++++++++++++++++++++++++++++++++-------- ice40/main.cc | 34 +++++++++++++++++++++++++++++----- 2 files changed, 61 insertions(+), 13 deletions(-) diff --git a/ice40/chip.cc b/ice40/chip.cc index b349cf12..d1226b3a 100644 --- a/ice40/chip.cc +++ b/ice40/chip.cc @@ -401,14 +401,38 @@ vector Chip::getBelGraphics(BelId bel) const } if (bel_type == TYPE_SB_IO) { - GraphicElement el; - el.type = GraphicElement::G_BOX; - el.x1 = chip_info.bel_data[bel.index].x + 0.1; - el.x2 = chip_info.bel_data[bel.index].x + 0.9; - el.y1 = chip_info.bel_data[bel.index].y + 0.10 + (chip_info.bel_data[bel.index].z) * (0.8/2); - el.y2 = chip_info.bel_data[bel.index].y + 0.40 + (chip_info.bel_data[bel.index].z) * (0.8/2); - el.z = 0; - ret.push_back(el); + if (chip_info.bel_data[bel.index].x == 0 || chip_info.bel_data[bel.index].x == chip_info.width-1) + { + GraphicElement el; + el.type = GraphicElement::G_BOX; + el.x1 = chip_info.bel_data[bel.index].x + 0.1; + el.x2 = chip_info.bel_data[bel.index].x + 0.9; + if (chip_info.bel_data[bel.index].z == 0) { + el.y1 = chip_info.bel_data[bel.index].y + 0.10; + el.y2 = chip_info.bel_data[bel.index].y + 0.45; + } else { + el.y1 = chip_info.bel_data[bel.index].y + 0.55; + el.y2 = chip_info.bel_data[bel.index].y + 0.90; + } + el.z = 0; + ret.push_back(el); + } + else + { + GraphicElement el; + el.type = GraphicElement::G_BOX; + if (chip_info.bel_data[bel.index].z == 0) { + el.x1 = chip_info.bel_data[bel.index].x + 0.10; + el.x2 = chip_info.bel_data[bel.index].x + 0.45; + } else { + el.x1 = chip_info.bel_data[bel.index].x + 0.55; + el.x2 = chip_info.bel_data[bel.index].x + 0.90; + } + el.y1 = chip_info.bel_data[bel.index].y + 0.1; + el.y2 = chip_info.bel_data[bel.index].y + 0.9; + el.z = 0; + ret.push_back(el); + } } if (bel_type == TYPE_ICESTORM_RAM) { diff --git a/ice40/main.cc b/ice40/main.cc index a32aa2db..185c7f53 100644 --- a/ice40/main.cc +++ b/ice40/main.cc @@ -26,17 +26,17 @@ void svg_dump_el(const GraphicElement &el) { - float scale = 10.0; + float scale = 10.0, offset = 10.0; std::string style = "stroke=\"black\" stroke-width=\"0.1\" fill=\"none\""; if (el.type == GraphicElement::G_BOX) { - std::cout << "\n"; } if (el.type == GraphicElement::G_LINE) { - std::cout << "\n"; + std::cout << "\n"; } } @@ -53,6 +53,12 @@ int main(int argc, char *argv[]) options.add_options()("svg","dump SVG file"); options.add_options()("file", po::value(), "python file to execute"); options.add_options()("version,v","show version"); + options.add_options()("lp384","set device type to iCE40LP384"); + options.add_options()("lp1k","set device type to iCE40LP1K"); + options.add_options()("lp8k","set device type to iCE40LP8K"); + options.add_options()("hx1k","set device type to iCE40HX1K"); + options.add_options()("hx8k","set device type to iCE40HX8K"); + options.add_options()("up5k","set device type to iCE40UP5K"); po::positional_options_description pos; pos.add("file", -1); @@ -89,7 +95,25 @@ int main(int argc, char *argv[]) } ChipArgs chipArgs; - chipArgs.type = ChipArgs::LP384; + chipArgs.type = ChipArgs::HX1K; + + if (vm.count("lp384")) + chipArgs.type = ChipArgs::LP384; + + if (vm.count("lp1k")) + chipArgs.type = ChipArgs::LP1K; + + if (vm.count("lp8k")) + chipArgs.type = ChipArgs::LP8K; + + if (vm.count("hx1k")) + chipArgs.type = ChipArgs::HX1K; + + if (vm.count("hx8k")) + chipArgs.type = ChipArgs::HX8K; + + if (vm.count("up5k")) + chipArgs.type = ChipArgs::UP5K; Design design(chipArgs);