aboutsummaryrefslogtreecommitdiffstats
path: root/ecp5/lpf.cc
diff options
context:
space:
mode:
authorDavid Shah <dave@ds0.me>2019-02-27 22:54:32 +0000
committerDavid Shah <dave@ds0.me>2019-02-27 22:54:32 +0000
commit8744c46ea0fb5c6428927867447dbe491f340f5b (patch)
treed6ca58ab0b95e4254e65a858479e6b103b2ff349 /ecp5/lpf.cc
parentba4150aeccb0f0dbdfb9f23d1459077d38b15553 (diff)
downloadnextpnr-8744c46ea0fb5c6428927867447dbe491f340f5b.tar.gz
nextpnr-8744c46ea0fb5c6428927867447dbe491f340f5b.tar.bz2
nextpnr-8744c46ea0fb5c6428927867447dbe491f340f5b.zip
ecp5: Fix handling of CRLFs and uppercase frequency units in LPF
Signed-off-by: David Shah <dave@ds0.me>
Diffstat (limited to 'ecp5/lpf.cc')
-rw-r--r--ecp5/lpf.cc10
1 files 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 <boost/algorithm/string.hpp>
#include <sstream>
#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);