From f9bfccf68e939a2d14c0d94a14234822e9727b89 Mon Sep 17 00:00:00 2001 From: David Shah Date: Sun, 17 Jun 2018 11:14:49 +0200 Subject: Add 'get or default' functions Signed-off-by: David Shah --- ice40/arch_place.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'ice40') diff --git a/ice40/arch_place.cc b/ice40/arch_place.cc index 93b7beb4..83dd63aa 100644 --- a/ice40/arch_place.cc +++ b/ice40/arch_place.cc @@ -19,6 +19,7 @@ #include "arch_place.h" #include "cells.h" +#include "util.h" NEXTPNR_NAMESPACE_BEGIN @@ -39,7 +40,7 @@ static bool logicCellsCompatible(const std::vector &cells) std::unordered_set locals; for (auto cell : cells) { - if (std::stoi(cell->params.at("DFF_ENABLE"))) { + if (bool_or_default(cell->params, "DFF_ENABLE")) { if (!dffs_exist) { dffs_exist = true; cen = get_net_or_nullptr(cell, "CEN"); @@ -53,7 +54,7 @@ static bool logicCellsCompatible(const std::vector &cells) if (!is_global_net(sr)) locals.insert(sr); - if (std::stoi(cell->params.at("NEG_CLK"))) { + if (bool_or_default(cell->params, "NEG_CLK")) { dffs_neg = true; } } else { @@ -63,7 +64,7 @@ static bool logicCellsCompatible(const std::vector &cells) return false; if (sr != get_net_or_nullptr(cell, "SR")) return false; - if (dffs_neg != bool(std::stoi(cell->params.at("NEG_CLK")))) + if (dffs_neg != bool_or_default(cell->params, "NEG_CLK")) return false; } } -- cgit v1.2.3