Generate correct VHDL signal values

This commit is contained in:
Nick Gasson 2008-06-12 10:50:46 +01:00
parent 46991aa65c
commit d6f1162547
2 changed files with 19 additions and 2 deletions

View File

@ -23,6 +23,7 @@
#include <fstream> #include <fstream>
#include <list> #include <list>
#include <cassert>
template <class T> template <class T>
void emit_children(std::ofstream &of, void emit_children(std::ofstream &of,
@ -54,4 +55,20 @@ void delete_children(std::list<T*> &children)
children.clear(); children.clear();
} }
static inline char vl_to_vhdl_bit(char bit)
{
switch (bit) {
case '0':
case 'Z':
case '1':
return bit;
case 'z':
return 'Z';
case 'x':
case 'X':
return 'U';
}
assert(false);
}
#endif #endif

View File

@ -522,14 +522,14 @@ void vhdl_const_bits::emit(std::ofstream &of, int level) const
// The bits appear to be in reverse order // The bits appear to be in reverse order
std::string::const_reverse_iterator it; std::string::const_reverse_iterator it;
for (it = value_.rbegin(); it != value_.rend(); ++it) for (it = value_.rbegin(); it != value_.rend(); ++it)
of << *it; of << vl_to_vhdl_bit(*it);
of << "\")"; of << "\")";
} }
void vhdl_const_bit::emit(std::ofstream &of, int level) const void vhdl_const_bit::emit(std::ofstream &of, int level) const
{ {
of << "'" << bit_ << "'"; of << "'" << vl_to_vhdl_bit(bit_) << "'";
} }
void vhdl_const_int::emit(std::ofstream &of, int level) const void vhdl_const_int::emit(std::ofstream &of, int level) const