Convert constant bits to integers

This commit is contained in:
Nick Gasson 2008-07-17 14:29:56 +01:00
parent c86377790f
commit 9916686c24
2 changed files with 9 additions and 0 deletions

View File

@ -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_) << "'";

View File

@ -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_;
};