From eed89ba3a3feba692a7a55aeafee1c5a1dcb98ad Mon Sep 17 00:00:00 2001 From: Matthias Breithaupt Date: Thu, 23 May 2024 11:48:48 +0000 Subject: [PATCH] Add support for the Efinix reconfiguration interface This adds low level support for the reconfiguration interface (sometimes also called remote update by Efinix) Signed-off-by: Matthias Breithaupt --- litex/build/efinix/ifacewriter.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/litex/build/efinix/ifacewriter.py b/litex/build/efinix/ifacewriter.py index b3485854a..4dd4fac25 100644 --- a/litex/build/efinix/ifacewriter.py +++ b/litex/build/efinix/ifacewriter.py @@ -602,6 +602,31 @@ design.create("{2}", "{3}", "./../gateware", overwrite=True) return '\n'.join(cmd) + '\n' + def generate_remote_update(self, block, verbose=True): + name = block["name"] + pins = block["pins"] + clock = block["clock"] + invert_clk = block["invert_clock"] + enable = block["enable"] + + def get_pin_name(pin): + return pin.backtrace[-1][0] + + cmds = [] + cmds.append(f"# ---------- REMOTE UPDATE ---------") + cmds.append(f'design.set_device_property("ru", "RECONFIG_EN", "{enable}", "RU")') + if enable: + cmds.append(f'design.set_device_property("ru", "CBSEL_PIN", "{get_pin_name(pins.CBSEL)}", "RU")') + cmds.append(f'design.set_device_property("ru", "CLK_PIN", "{clock}", "RU")') + cmds.append(f'design.set_device_property("ru", "CONFIG_PIN", "{get_pin_name(pins.CONFIG)}", "RU")') + cmds.append(f'design.set_device_property("ru", "ENA_PIN", "{get_pin_name(pins.ENA)}", "RU")') + cmds.append(f'design.set_device_property("ru", "ERROR_PIN", "{get_pin_name(pins.ERROR)}", "RU")') + if hasattr(pins, 'IN_USER'): + cmds.append(f'design.set_device_property("ru", "IN_USER_PIN", "{get_pin_name(pins.IN_USER)}", "RU")') + cmds.append(f'design.set_device_property("ru", "INVERT_CLK_EN", "{invert_clk}", "RU")') + cmds.append(f"# ---------- END REMOTE UPDATE ---------\n") + return "\n".join(cmds) + def generate(self, partnumber): output = "" for block in self.blocks: @@ -624,6 +649,8 @@ design.create("{2}", "{3}", "./../gateware", overwrite=True) output += self.generate_jtag(block) if block["type"] == "SPI_FLASH": output += self.generate_spiflash(block) + if block["type"] == "REMOTE_UPDATE": + output += self.generate_remote_update(block) return output def footer(self):