From 4a79e70470987ba54a16ab97eb25d664509550fc Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Sun, 10 Jun 2018 14:08:00 +0200 Subject: Fix ice40 pip/switch locked performance issue Signed-off-by: Clifford Wolf --- ice40/chip.h | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'ice40/chip.h') diff --git a/ice40/chip.h b/ice40/chip.h index 84b2196a..7e20a252 100644 --- a/ice40/chip.h +++ b/ice40/chip.h @@ -162,6 +162,7 @@ struct ChipInfoPOD { int width, height; int num_bels, num_wires, num_pips; + int num_switches; BelInfoPOD *bel_data; WireInfoPOD *wire_data; PipInfoPOD *pip_data; @@ -411,7 +412,7 @@ struct Chip vector bel_to_cell; vector wire_to_net; vector pip_to_net; - vector pips_locked; + vector switches_locked; Chip(ChipArgs args); ChipArgs args; @@ -567,32 +568,24 @@ struct Chip { assert(pip != PipId()); assert(pip_to_net[pip.index] == IdString()); + assert(!switches_locked[chip_info.pip_data[pip.index].switch_index]); pip_to_net[pip.index] = net; - // Optimise? - for (int i = 0; i < chip_info.num_pips; i++) { - if (chip_info.pip_data[i].switch_index == - chip_info.pip_data[pip.index].switch_index) - pips_locked[i] = true; - } + switches_locked[chip_info.pip_data[pip.index].switch_index] = true; } void unbindPip(PipId pip) { assert(pip != PipId()); assert(pip_to_net[pip.index] != IdString()); + assert(switches_locked[chip_info.pip_data[pip.index].switch_index]); pip_to_net[pip.index] = IdString(); - // Optimise? - for (int i = 0; i < chip_info.num_pips; i++) { - if (chip_info.pip_data[i].switch_index == - chip_info.pip_data[pip.index].switch_index) - pips_locked[i] = false; - } + switches_locked[chip_info.pip_data[pip.index].switch_index] = false; } bool checkPipAvail(PipId pip) const { assert(pip != PipId()); - return !pips_locked[pip.index]; + return !switches_locked[chip_info.pip_data[pip.index].switch_index]; } IdString getPipNet(PipId pip) const -- cgit v1.2.3