aboutsummaryrefslogtreecommitdiffstats
path: root/ecp5/pack.cc
diff options
context:
space:
mode:
authorRoss Schlaikjer <ross@schlaikjer.net>2020-04-29 14:46:09 -0400
committerRoss Schlaikjer <ross@schlaikjer.net>2020-04-29 14:46:09 -0400
commit6e8082860e2e7e0a31bb258ab633ef3146e5c9b3 (patch)
tree12c4e788263cd4dd347762ea9de99ac7008d5955 /ecp5/pack.cc
parent0043ae0807affd77749b162199cd4da3b37d994c (diff)
downloadnextpnr-6e8082860e2e7e0a31bb258ab633ef3146e5c9b3.tar.gz
nextpnr-6e8082860e2e7e0a31bb258ab633ef3146e5c9b3.tar.bz2
nextpnr-6e8082860e2e7e0a31bb258ab633ef3146e5c9b3.zip
Dedupe clock error check
Diffstat (limited to 'ecp5/pack.cc')
-rw-r--r--ecp5/pack.cc25
1 files changed, 13 insertions, 12 deletions
diff --git a/ecp5/pack.cc b/ecp5/pack.cc
index 1c1df2ee..c268e2ac 100644
--- a/ecp5/pack.cc
+++ b/ecp5/pack.cc
@@ -3042,24 +3042,25 @@ void Arch::assignArchInfo()
// Get the input clock setting from the cell
std::string reg_inputa_clk = str_or_default(ci->params, id("REG_INPUTA_CLK"), "NONE");
std::string reg_inputb_clk = str_or_default(ci->params, id("REG_INPUTB_CLK"), "NONE");
+
+ // The clock check is the same IN_A/B and OUT, so hoist it to a function
+ auto verify_clock_parameter = [&](std::string param_name, std::string clk) {
+ if (clk != "NONE" && clk != "CLK0" && clk != "CLK1" && clk != "CLK2" && clk != "CLK3")
+ log_error("MULT18X18D %s has invalid %s configuration '%s'\n", ci->name.c_str(this),
+ param_name.c_str(), clk.c_str());
+ };
+
// Assert we have valid settings for the input clocks
- if (reg_inputa_clk != "NONE" && reg_inputa_clk != "CLK0" && reg_inputa_clk != "CLK1" &&
- reg_inputa_clk != "CLK2" && reg_inputa_clk != "CLK3")
- log_error("MULT18X18D %s has invalid REG_INPUTA_CLK configuration '%s'\n", ci->name.c_str(this),
- reg_inputa_clk.c_str());
- if (reg_inputb_clk != "NONE" && reg_inputb_clk != "CLK0" && reg_inputb_clk != "CLK1" &&
- reg_inputb_clk != "CLK2" && reg_inputb_clk != "CLK3")
- log_error("MULT18X18D %s has invalid REG_INPUTB_CLK configuration '%s'\n", ci->name.c_str(this),
- reg_inputb_clk.c_str());
+ verify_clock_parameter("REG_INPUTA_CLK", reg_inputa_clk);
+ verify_clock_parameter("REG_INPUTB_CLK", reg_inputb_clk);
+
// Inputs are registered IFF the REG_INPUT value is not NONE
const bool is_in_a_registered = reg_inputa_clk != "NONE";
const bool is_in_b_registered = reg_inputb_clk != "NONE";
+
// Similarly, get the output register clock
std::string reg_output_clk = str_or_default(ci->params, id("REG_OUTPUT_CLK"), "NONE");
- if (reg_output_clk != "NONE" && reg_output_clk != "CLK0" && reg_output_clk != "CLK1" &&
- reg_output_clk != "CLK2" && reg_output_clk != "CLK3")
- log_error("MULT18X18D %s has invalid REG_OUTPUT_CLK configuration '%s'\n", ci->name.c_str(this),
- reg_output_clk.c_str());
+ verify_clock_parameter("REG_OUTPUT_CLK", reg_output_clk);
const bool is_output_registered = reg_output_clk != "NONE";
// If only one of the inputs is registered, we are going to treat that as