From f9c4d33909c54b69d5ba513762ce4b05ed61dd30 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Sun, 2 Feb 2014 21:35:26 +0100 Subject: [PATCH] Added RTLIL::SigSpec::to_single_sigbit() --- kernel/rtlil.cc | 9 +++++++++ kernel/rtlil.h | 1 + 2 files changed, 10 insertions(+) diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 7638d4689..1d1448d45 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -1551,6 +1551,15 @@ std::vector RTLIL::SigSpec::to_sigbit_vector() const return sigbits; } +RTLIL::SigBit RTLIL::SigSpec::to_single_sigbit() const +{ + log_assert(width == 1); + for (auto &c : chunks) + if (c.width) + return RTLIL::SigBit(c); + log_abort(); +} + static void sigspec_parse_split(std::vector &tokens, const std::string &text, char sep) { size_t start = 0, end = 0; diff --git a/kernel/rtlil.h b/kernel/rtlil.h index e0b3a693d..df0e94dcc 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -409,6 +409,7 @@ struct RTLIL::SigSpec { bool match(std::string pattern) const; std::set to_sigbit_set() const; std::vector to_sigbit_vector() const; + RTLIL::SigBit to_single_sigbit() 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); };