From 67a5cedbe30f681fd3c5c52ed8552abcc7583a45 Mon Sep 17 00:00:00 2001 From: David Shah Date: Tue, 12 Jun 2018 13:09:36 +0200 Subject: ice40: Pack constants to LCs Signed-off-by: David Shah --- ice40/pack.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'ice40/pack.cc') diff --git a/ice40/pack.cc b/ice40/pack.cc index 47e55b68..eb783f2f 100644 --- a/ice40/pack.cc +++ b/ice40/pack.cc @@ -89,9 +89,34 @@ static void pack_nonlut_ffs(Design *design) } } +// Pack constants (simple implementation) +static void pack_constants(Design *design) { + CellInfo *gnd_cell = create_ice_cell(design, "ICESTORM_LC", + "$PACKER_GND"); + gnd_cell->attrs["LUT_INIT"] = "0"; + + CellInfo *vcc_cell = create_ice_cell(design, "ICESTORM_LC", + "$PACKER_VCC"); + vcc_cell->attrs["LUT_INIT"] = "1"; + + for (auto net : design->nets) { + NetInfo *ni = net.second; + if (ni->driver.cell != nullptr && ni->driver.cell->type == "GND") { + ni->driver.cell = gnd_cell; + ni->driver.port = "O"; + design->cells[gnd_cell->name] = gnd_cell; + } else if (ni->driver.cell != nullptr && ni->driver.cell->type == "VCC") { + ni->driver.cell = vcc_cell; + ni->driver.port = "O"; + design->cells[vcc_cell->name] = vcc_cell; + } + } +} + // Main pack function void pack_design(Design *design) { + pack_constants(design); pack_lut_lutffs(design); pack_nonlut_ffs(design); } -- cgit v1.2.3