From eae43e2db430c951018b5cb70f047de84ad010b0 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Thu, 24 Oct 2013 10:59:27 +0200 Subject: Fixed handling of boolean attributes (kernel) --- kernel/rtlil.h | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'kernel') diff --git a/kernel/rtlil.h b/kernel/rtlil.h index b69dc814..87271bbf 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -233,6 +233,17 @@ struct RTLIL::Design { } }; +#define RTLIL_ATTRIBUTE_MEMBERS \ + std::map attributes; \ + void set_bool_attribute(RTLIL::IdString id) { \ + attributes[id] = RTLIL::Const(1); \ + } \ + bool get_bool_attribute(RTLIL::IdString id) const { \ + if (attributes.count(id) == 0) \ + return false; \ + return attributes.at(id).as_bool(); \ + } + struct RTLIL::Module { RTLIL::IdString name; std::map wires; @@ -240,7 +251,7 @@ struct RTLIL::Module { std::map cells; std::map processes; std::vector connections; - std::map attributes; + RTLIL_ATTRIBUTE_MEMBERS virtual ~Module(); virtual RTLIL::IdString derive(RTLIL::Design *design, std::map parameters); virtual void update_auto_wires(std::map auto_sizes); @@ -255,20 +266,21 @@ struct RTLIL::Module { template void rewrite_sigspecs(T functor); void cloneInto(RTLIL::Module *new_mod) const; virtual RTLIL::Module *clone() const; + }; struct RTLIL::Wire { RTLIL::IdString name; int width, start_offset, port_id; bool port_input, port_output, auto_width; - std::map attributes; + RTLIL_ATTRIBUTE_MEMBERS Wire(); }; struct RTLIL::Memory { RTLIL::IdString name; int width, start_offset, size; - std::map attributes; + RTLIL_ATTRIBUTE_MEMBERS Memory(); }; @@ -276,8 +288,8 @@ struct RTLIL::Cell { RTLIL::IdString name; RTLIL::IdString type; std::map connections; - std::map attributes; std::map parameters; + RTLIL_ATTRIBUTE_MEMBERS void optimize(); template void rewrite_sigspecs(T functor); @@ -377,7 +389,7 @@ struct RTLIL::SyncRule { struct RTLIL::Process { RTLIL::IdString name; - std::map attributes; + RTLIL_ATTRIBUTE_MEMBERS RTLIL::CaseRule root_case; std::vector syncs; ~Process(); -- cgit v1.2.3