From 9916686c24d44481804d6451da18bb6eb41da357 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Thu, 17 Jul 2008 14:29:56 +0100 Subject: [PATCH] Convert constant bits to integers --- tgt-vhdl/vhdl_syntax.cc | 8 ++++++++ tgt-vhdl/vhdl_syntax.hh | 1 + 2 files changed, 9 insertions(+) diff --git a/tgt-vhdl/vhdl_syntax.cc b/tgt-vhdl/vhdl_syntax.cc index f437a84f6..8047baa9c 100644 --- a/tgt-vhdl/vhdl_syntax.cc +++ b/tgt-vhdl/vhdl_syntax.cc @@ -662,6 +662,14 @@ void vhdl_const_bits::emit(std::ostream &of, int level) const of << (qualified_ ? "\")" : "\""); } +vhdl_expr *vhdl_const_bit::cast(const vhdl_type *to) +{ + if (to->get_name() == VHDL_TYPE_INTEGER) + return new vhdl_const_int(bit_ == '1' ? 1 : 0); + else + return vhdl_expr::cast(to); +} + void vhdl_const_bit::emit(std::ostream &of, int level) const { of << "'" << vl_to_vhdl_bit(bit_) << "'"; diff --git a/tgt-vhdl/vhdl_syntax.hh b/tgt-vhdl/vhdl_syntax.hh index 21a20510a..9f9fdcfcb 100644 --- a/tgt-vhdl/vhdl_syntax.hh +++ b/tgt-vhdl/vhdl_syntax.hh @@ -151,6 +151,7 @@ public: vhdl_const_bit(char bit) : vhdl_expr(vhdl_type::std_logic(), true), bit_(bit) {} void emit(std::ostream &of, int level) const; + vhdl_expr *cast(const vhdl_type *to); private: char bit_; };