From 6da8f98eacab15fad804ffa66ca95acb6350bbf3 Mon Sep 17 00:00:00 2001 From: David Shah Date: Sun, 10 Jun 2018 12:17:55 +0200 Subject: ice40: Lock out mutually exclusive pips Signed-off-by: David Shah --- ice40/chip.cc | 1 + ice40/chip.h | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ice40/chip.cc b/ice40/chip.cc index c2fba89f..0caabe0c 100644 --- a/ice40/chip.cc +++ b/ice40/chip.cc @@ -97,6 +97,7 @@ Chip::Chip(ChipArgs args) : args(args) bel_to_cell.resize(chip_info.num_bels); wire_to_net.resize(chip_info.num_wires); pip_to_net.resize(chip_info.num_pips); + pips_locked.resize(chip_info.num_pips); } // ----------------------------------------------------------------------- diff --git a/ice40/chip.h b/ice40/chip.h index 45987803..1a978fcd 100644 --- a/ice40/chip.h +++ b/ice40/chip.h @@ -404,7 +404,7 @@ struct Chip vector bel_to_cell; vector wire_to_net; vector pip_to_net; - + vector pips_locked; Chip(ChipArgs args); ChipArgs args; @@ -561,6 +561,11 @@ struct Chip assert(pip != PipId()); assert(pip_to_net[pip.index] == IdString()); 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; + } } void unbindPip(PipId pip) @@ -568,12 +573,17 @@ struct Chip assert(pip != PipId()); assert(pip_to_net[pip.index] != IdString()); 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; + } } bool checkPipAvail(PipId pip) const { assert(pip != PipId()); - return pip_to_net[pip.index] == IdString(); + return !pips_locked[pip.index]; } IdString getPipNet(PipId pip) const -- cgit v1.2.3