aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2013-11-09 12:02:27 +0100
committerClifford Wolf <clifford@clifford.at>2013-11-09 12:02:27 +0100
commit223892ac286b1dd0d09bf2449cd8953b1029ae68 (patch)
tree704ff413b0dd4112106b7dca8fa5761236700019 /kernel
parent2864cb3b59d1e293d3738eebbaf363b4e03d365e (diff)
downloadyosys-223892ac286b1dd0d09bf2449cd8953b1029ae68.tar.gz
yosys-223892ac286b1dd0d09bf2449cd8953b1029ae68.tar.bz2
yosys-223892ac286b1dd0d09bf2449cd8953b1029ae68.zip
Improved user-friendliness of "sat" and "eval" expression parsing
Diffstat (limited to 'kernel')
-rw-r--r--kernel/rtlil.cc14
-rw-r--r--kernel/rtlil.h1
2 files changed, 15 insertions, 0 deletions
diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc
index d03fb0448..a65f0bb24 100644
--- a/kernel/rtlil.cc
+++ b/kernel/rtlil.cc
@@ -1216,6 +1216,20 @@ bool RTLIL::SigSpec::parse(RTLIL::SigSpec &sig, RTLIL::Module *module, std::stri
return true;
}
+bool RTLIL::SigSpec::parse_rhs(const RTLIL::SigSpec &lhs, RTLIL::SigSpec &sig, RTLIL::Module *module, std::string str)
+{
+ if (lhs.chunks.size() == 1) {
+ char *p = (char*)str.c_str(), *endptr;
+ long long int val = strtoll(p, &endptr, 10);
+ if (endptr && endptr != p && *endptr == 0) {
+ sig = RTLIL::SigSpec(val, lhs.width);
+ return true;
+ }
+ }
+
+ return parse(sig, module, str);
+}
+
RTLIL::CaseRule::~CaseRule()
{
for (auto it = switches.begin(); it != switches.end(); it++)
diff --git a/kernel/rtlil.h b/kernel/rtlil.h
index 7628bf0a8..952cb5944 100644
--- a/kernel/rtlil.h
+++ b/kernel/rtlil.h
@@ -357,6 +357,7 @@ struct RTLIL::SigSpec {
RTLIL::Const as_const() const;
bool match(std::string pattern) const;
static bool parse(RTLIL::SigSpec &sig, RTLIL::Module *module, std::string str);
+ static bool parse_rhs(const RTLIL::SigSpec &lhs, RTLIL::SigSpec &sig, RTLIL::Module *module, std::string str);
};
struct RTLIL::CaseRule {