From 8744c46ea0fb5c6428927867447dbe491f340f5b Mon Sep 17 00:00:00 2001 From: David Shah Date: Wed, 27 Feb 2019 22:54:32 +0000 Subject: ecp5: Fix handling of CRLFs and uppercase frequency units in LPF Signed-off-by: David Shah --- ecp5/lpf.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ecp5/lpf.cc b/ecp5/lpf.cc index b561807d..4ac70fc9 100644 --- a/ecp5/lpf.cc +++ b/ecp5/lpf.cc @@ -17,6 +17,7 @@ * */ +#include #include #include "log.h" @@ -25,7 +26,7 @@ NEXTPNR_NAMESPACE_BEGIN bool Arch::applyLPF(std::string filename, std::istream &in) { auto isempty = [](const std::string &str) { - return std::all_of(str.begin(), str.end(), [](char c) { return isblank(c); }); + return std::all_of(str.begin(), str.end(), [](char c) { return isblank(c) || c == '\r' || c == '\n'; }); }; auto strip_quotes = [](const std::string &str) { if (str.at(0) == '"') { @@ -77,11 +78,12 @@ bool Arch::applyLPF(std::string filename, std::istream &in) std::string target = strip_quotes(words.at(2)); float freq = std::stof(words.at(3)); std::string unit = words.at(4); - if (unit == "MHz") + boost::algorithm::to_upper(unit); + if (unit == "MHZ") ; - else if (unit == "kHz") + else if (unit == "KHZ") freq /= 1.0e3; - else if (unit == "Hz") + else if (unit == "HZ") freq /= 1.0e6; else log_error("unsupported frequency unit '%s' (on line %d)\n", unit.c_str(), lineno); -- cgit v1.2.3