// often one needs to check if a given IdString is part of a list (for example a list
// of cell types). the following functions helps with that.
- template<typename T, typename... Args>
- bool in(T first, Args... rest) const {
- return in(first) || in(rest...);
+ template<typename... Args>
+ bool in(Args... args) const {
+ // Credit: https://articles.emptycrate.com/2016/05/14/folds_in_cpp11_ish.html
+ bool result = false;
+ (void) std::initializer_list<int>{ (result = result || in(args), 0)... };
+ return result;
}
- bool in(IdString rhs) const { return *this == rhs; }
+ bool in(const IdString &rhs) const { return *this == rhs; }
bool in(const char *rhs) const { return *this == rhs; }
bool in(const std::string &rhs) const { return *this == rhs; }
bool in(const pool<IdString> &rhs) const { return rhs.count(*this) != 0; }
namespace ID {
#define X(_id) extern IdString _id;
-#include "constids.inc"
+#include "kernel/constids.inc"
#undef X
};
extern dict<std::string, std::string> constpad;
+ const pool<IdString> &builtin_ff_cell_types();
+
static inline std::string escape_id(const std::string &str) {
if (str.size() > 0 && str[0] != '\\' && str[0] != '$')
return "\\" + str;
{
dict<RTLIL::IdString, RTLIL::Const> attributes;
+ bool has_attribute(RTLIL::IdString id) const;
+
void set_bool_attribute(RTLIL::IdString id, bool value=true);
bool get_bool_attribute(RTLIL::IdString id) const;
return get_bool_attribute(ID::blackbox) || (!ignore_wb && get_bool_attribute(ID::whitebox));
}
+ void set_string_attribute(RTLIL::IdString id, string value);
+ string get_string_attribute(RTLIL::IdString id) const;
+
void set_strpool_attribute(RTLIL::IdString id, const pool<string> &data);
void add_strpool_attribute(RTLIL::IdString id, const pool<string> &data);
pool<string> get_strpool_attribute(RTLIL::IdString id) const;
- void set_src_attribute(const std::string &src);
- std::string get_src_attribute() const;
+ void set_src_attribute(const std::string &src) {
+ set_string_attribute(ID::src, src);
+ }
+ std::string get_src_attribute() const {
+ return get_string_attribute(ID::src);
+ }
};
struct RTLIL::SigChunk
std::vector<RTLIL::SigSig> connections_;
RTLIL::IdString name;
- pool<RTLIL::IdString> avail_parameters;
+ idict<RTLIL::IdString> avail_parameters;
+ dict<RTLIL::IdString, RTLIL::Const> parameter_default_values;
dict<RTLIL::IdString, RTLIL::Memory*> memories;
dict<RTLIL::IdString, RTLIL::Process*> processes;