AMARANTH_verbose=1 glasgow build ... from [[Glasgow board definition in Amaranth]] [[2023-05-18]] Attempting to troubleshoot with [[nextPNR]] ```bash |🍓 …/glasgow/build arm64 └─x nextpnr-ice40 --json top.json --pcf top.pcf --asc top.asc Warning: Use of default value for --package is deprecated. Please add '--package ' to arguments. ERROR: package does not have a pin named 'B2' (on line 2) ERROR: Loading PCF failed. 1 warning, 2 errors ``` top.[[pcf files]]: ``` # Automatically generated by Amaranth 0.4.dev96+g5f6b36e. Do not edit. set_io led_0__io[0] B2 set_io led_0__io[1] G8 set_io led_0__io[2] G9 set_io led_0__io[3] B1 set_io clk_if_0__io K6 set_frequency cd_sync_clk_if_0__i 48.0 # (add_constraints placeholder) ``` looking into nextpnr iCE40 definitions: https://github.com/YosysHQ/nextpnr/blob/master/ice40/chipdb.py the question is ==how does it find the pins?== ``` |🍓 …/glasgow/build arm64 └─x nextpnr-ice40 --json top.json --pcf top.pcf --asc top.asc --package hx8k --debug -v ERROR: package does not have a pin named 'B2' (on line 2) ERROR: Loading PCF failed. 0 warnings, 2 errors ``` even with `--debug` and `-v` (verbose) flags, still no more info... error comes from here: https://github.com/YosysHQ/nextpnr/blob/master/ice40/pcf.cc ``` BelId pin_bel = ctx->get_package_pin_bel(pin); if (pin_bel == BelId()) log_error("package does not have a pin named '%s' (on line %d)\n", pin.c_str(), lineno); ``` looking for the get_package_pin_bel(pin) function. here? https://github.com/YosysHQ/nextpnr/blob/master/ecp5/arch.cc#L370 ``` BelId Arch::get_package_pin_bel(const std::string &pin) const { for (auto &ppin : package_info->pin_data) { if (ppin.name.get() == pin) { BelId bel; bel.location = ppin.abs_loc; bel.index = ppin.bel_index; return bel; } } return BelId(); } ``` if it doesn't "find the pin" or whatever, then it returns `BelId()` and that triggers the error in the pcf reader what is a BelID? here are some struct definitions: https://github.com/YosysHQ/nextpnr/blob/master/fpga_interchange/archdefs.h#L36 anyway.... This is where the ice40 arch flag does things: https://github.com/YosysHQ/nextpnr/blob/master/ice40/arch.cc ``` static const ChipInfoPOD *get_chip_info(ArchArgs::ArchArgsTypes chip) { std::string chipdb; if (chip == ArchArgs::LP384) { chipdb = "ice40/chipdb-384.bin"; } else if (chip == ArchArgs::LP1K || chip == ArchArgs::HX1K) { chipdb = "ice40/chipdb-1k.bin"; } else if (chip == ArchArgs::U1K || chip == ArchArgs::U2K || chip == ArchArgs::U4K) { chipdb = "ice40/chipdb-u4k.bin"; } else if (chip == ArchArgs::UP3K || chip == ArchArgs::UP5K) { chipdb = "ice40/chipdb-5k.bin"; } else if (chip == ArchArgs::LP8K || chip == ArchArgs::HX8K || chip == ArchArgs::LP4K || chip == ArchArgs::HX4K) { chipdb = "ice40/chipdb-8k.bin"; } else { log_error("Unknown chip\n"); } ``` aha, where is that chipdb-8k.bin file?? https://github.com/search?q=repo%3AYosysHQ%2Ficestorm%20chipdb-8k&type=code ? chipdb-8k.txt is referenced several times in icestorm > The IceStorm Makefile builds and installs two files: <span style="font-family:monospace">chipdb-1k.txt</span> and <span style="font-family:monospace">chipdb-8k.txt</span>. This files contain all the relevant information for arachne-pnr to place&amp;route a design and create an IceStorm ASCII file for the placed and routed design. - [source](https://github.com/YosysHQ/icestorm/blob/d20a5e9001f46262bf0cef220f1a6943946e421d/docs/index.html#L290) Found the python script in icestorm that generates the cipdb file, https://github.com/YosysHQ/icestorm/blob/master/icebox/icebox_chipdb.py - The .pins package in here "associates a package pin with an IO tile and block, and global network" line 211: `for key in sorted(icebox.pinloc_db.keys()):` The icebox database dump: https://github.com/YosysHQ/icestorm/blob/master/icebox/iceboxdb.py `icebox.py` actually has pin numbers! in `pinloc_db[8k-bg121]` Format: Pin number, x, y block ``` "8k-bg121": [ ( "A1", 2, 33, 0), ( "A2", 3, 33, 1), ( "A3", 3, 33, 0), ( "A4", 9, 33, 0), ( "A5", 11, 33, 0), ( "A6", 11, 33, 1), ( "A7", 19, 33, 1), ( "A8", 20, 33, 1), ( "A9", 26, 33, 1), ("A10", 30, 33, 1), ("A11", 31, 33, 1), ( "B1", 0, 30, 1), ( "B2", 0, 30, 0), ( "B3", 4, 33, 0), ( "B4", 5, 33, 0), ( "B5", 10, 33, 1), ( "B6", 16, 33, 1), ( "B7", 17, 33, 0), ( "B8", 27, 33, 0), ( "B9", 28, 33, 1), ("B11", 33, 28, 0), ( "C1", 0, 25, 0), ( "C2", 0, 25, 1), ( "C3", 0, 27, 0), ( "C4", 0, 27, 1), ( "C7", 20, 33, 0), ( "C8", 26, 33, 0), ( "C9", 29, 33, 1), ("C11", 33, 27, 1), ( "D1", 0, 22, 0), ( "D2", 0, 21, 1), ( "D3", 0, 21, 0), ( "D5", 8, 33, 1), ( "D7", 25, 33, 0), ( "D9", 33, 21, 0), ("D10", 33, 24, 1), ("D11", 33, 23, 1), ( "E1", 0, 22, 1), ( "E2", 0, 20, 1), ( "E3", 0, 20, 0), ( "E8", 33, 20, 1), ( "E9", 33, 19, 1), ("E10", 33, 17, 0), ("E11", 33, 21, 1), ( "F1", 0, 18, 1), ( "F2", 0, 18, 0), ( "F3", 0, 17, 0), ( "F4", 0, 17, 1), ( "F9", 33, 15, 0), ("F10", 33, 14, 1), ("F11", 33, 16, 1), ( "G1", 0, 16, 1), ( "G2", 0, 16, 0), ( "G3", 0, 12, 1), ( "G8", 33, 5, 1), ( "G9", 33, 10, 1), ("G10", 33, 6, 1), ("G11", 33, 11, 0), ( "H1", 0, 11, 1), ( "H2", 0, 11, 0), ( "H3", 0, 12, 0), ( "H7", 20, 0, 1), ( "H9", 29, 0, 1), ("H10", 33, 4, 1), ("H11", 33, 6, 0), ( "J1", 0, 6, 1), ( "J2", 0, 4, 0), ( "J3", 4, 0, 1), ( "J4", 8, 0, 0), ( "J5", 15, 0, 0), ( "J7", 20, 0, 0), ( "J8", 22, 0, 1), ( "J9", 30, 0, 1), ("J10", 33, 5, 0), ("J11", 33, 3, 1), ( "K1", 0, 6, 0), ( "K2", 0, 4, 1), ( "K3", 7, 0, 1), ( "K4", 12, 0, 1), ( "K5", 15, 0, 1), ( "K6", 17, 0, 0), ( "K7", 21, 0, 1), ( "K9", 30, 0, 0), ("K10", 31, 0, 1), ("K11", 33, 4, 0), ( "L1", 4, 0, 0), ( "L2", 6, 0, 1), ( "L3", 11, 0, 1), ( "L4", 12, 0, 0), ( "L5", 16, 0, 1), ( "L7", 24, 0, 0), ( "L8", 29, 0, 0), ("L10", 31, 0, 0), ], ``` Running nextpnr again, specifying 8k-bg121 as the package: ```bash |🍓 …/glasgow/build arm64 └─x nextpnr-ice40 --json top.json --pcf top.pcf --asc top.asc --package 8k-bg121 --debug -v ERROR: package does not have a pin named 'B2' (on line 2) ERROR: Loading PCF failed. 0 warnings, 2 errors ``` It says package does not have a pin named B2. But I can see it has a pin named B2. Why?? Changed order of pins in LED resource to "G8 B2 G9 B1", built again, ->`ERROR: package does not have a pin named 'B2' (on line 2)` Changed order of pins in LED resource to "G8 G9 B1", build again -> `ERROR: package does not have a pin named 'B2' (on line 2)` . what?? `top.pcf` hasn't changed? why? shows it hasn't been modified since earlier ![[Screenshot 2023-05-18 at 5.44.57 PM.jpg|lg]] ok, found it. ```bash |🍓 …/glasgow/build/build arm64 └─> nextpnr-ice40 --json top.json --pcf top.pcf --asc top.asc --package 8k-bg121 --debug -v ERROR: package does not have a pin named 'G8' (on line 2) ERROR: Loading PCF failed. 0 warnings, 2 errors ``` So it doesn't find a pin named G8... but it is literally blinking the LED on that pin Same thing if we change the resource back to G9 which it was originally: (lol tunneling deeper into build folders) ```bash |🍓 …/build/build/build arm64 └─> nextpnr-ice40 --json top.json --pcf top.pcf --asc top.asc --package 8k-bg121 --debug -v ERROR: package does not have a pin named 'G9' (on line 2) ERROR: Loading PCF failed. 0 warnings, 2 errors ```