ice40: split out cells_map.v into ff_map.v
[yosys.git] / kernel / rtlil.h
index f6ba9a66374d6c0fb6fbba59af3fb841ed5556e4..11c45bbec77904615e85d669cfd5b2a181fb1bcb 100644 (file)
@@ -361,12 +361,15 @@ namespace RTLIL
                // 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(std::forward<Args>(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; }
@@ -374,12 +377,14 @@ namespace RTLIL
 
        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;
@@ -651,6 +656,8 @@ struct RTLIL::AttrObject
 {
        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;
 
@@ -658,12 +665,19 @@ struct RTLIL::AttrObject
                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
@@ -1077,7 +1091,8 @@ public:
        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;