vhdlpp: CHARACTER type is converted to bit[7:0] instead of byte.
This way it is possible to have limited size strings. Previously they were translated to unpacked array of bytes, which cannot be assigned as it was a string.
This commit is contained in:
parent
b414733f34
commit
ba3c07a59a
|
|
@ -931,7 +931,7 @@ int ExpString::emit_as_array_(ostream& out, Entity*, ScopeBase*, const VTypeArra
|
|||
|
||||
// Detect the special case that this is an array of
|
||||
// CHARACTER. In this case, emit at a Verilog string.
|
||||
if (etype->type()==VTypePrimitive::CHARACTER) {
|
||||
if (arr->element_type() == &primitive_CHARACTER) {
|
||||
vector<char> tmp (value_.size() + 3);
|
||||
tmp[0] = '"';
|
||||
memcpy(&tmp[1], &value_[0], value_.size());
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ const VTypePrimitive primitive_INTEGER(VTypePrimitive::INTEGER);
|
|||
const VTypePrimitive primitive_NATURAL(VTypePrimitive::NATURAL);
|
||||
const VTypePrimitive primitive_REAL(VTypePrimitive::REAL);
|
||||
const VTypePrimitive primitive_STDLOGIC(VTypePrimitive::STDLOGIC, true);
|
||||
const VTypePrimitive primitive_CHARACTER(VTypePrimitive::CHARACTER);
|
||||
const VTypePrimitive primitive_TIME(VTypePrimitive::TIME);
|
||||
|
||||
VTypeDef type_BOOLEAN(perm_string::literal("boolean"));
|
||||
|
||||
const VTypeArray primitive_CHARACTER(&primitive_BIT, 7, 0);
|
||||
const VTypeArray primitive_BIT_VECTOR(&primitive_BIT, vector<VTypeArray::range_t> (1));
|
||||
const VTypeArray primitive_BOOL_VECTOR(&type_BOOLEAN, vector<VTypeArray::range_t> (1));
|
||||
const VTypeArray primitive_STDLOGIC_VECTOR(&primitive_STDLOGIC, vector<VTypeArray::range_t> (1));
|
||||
|
|
|
|||
|
|
@ -35,11 +35,11 @@ extern const VTypePrimitive primitive_INTEGER;
|
|||
extern const VTypePrimitive primitive_NATURAL;
|
||||
extern const VTypePrimitive primitive_REAL;
|
||||
extern const VTypePrimitive primitive_STDLOGIC;
|
||||
extern const VTypePrimitive primitive_CHARACTER;
|
||||
extern const VTypePrimitive primitive_TIME;
|
||||
|
||||
extern VTypeDef type_BOOLEAN;
|
||||
|
||||
extern const VTypeArray primitive_CHARACTER;
|
||||
extern const VTypeArray primitive_BIT_VECTOR;
|
||||
extern const VTypeArray primitive_BOOL_VECTOR;
|
||||
extern const VTypeArray primitive_STDLOGIC_VECTOR;
|
||||
|
|
|
|||
|
|
@ -58,9 +58,6 @@ void VTypePrimitive::show(ostream&out) const
|
|||
case BIT:
|
||||
out << "BIT";
|
||||
break;
|
||||
case CHARACTER:
|
||||
out << "CHARACTER";
|
||||
break;
|
||||
case INTEGER:
|
||||
out << "INTEGER";
|
||||
break;
|
||||
|
|
@ -90,9 +87,6 @@ int VTypePrimitive::get_width(ScopeBase*) const
|
|||
case NATURAL:
|
||||
return 32;
|
||||
|
||||
case CHARACTER:
|
||||
return 8;
|
||||
|
||||
default:
|
||||
std::cerr << "sorry: primitive type " << type_ <<
|
||||
" has no get_width() implementation." << std::endl;
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ class VTypeERROR : public VType {
|
|||
class VTypePrimitive : public VType {
|
||||
|
||||
public:
|
||||
enum type_t { BIT, INTEGER, NATURAL, REAL, STDLOGIC, CHARACTER, TIME };
|
||||
enum type_t { BIT, INTEGER, NATURAL, REAL, STDLOGIC, TIME };
|
||||
|
||||
public:
|
||||
VTypePrimitive(type_t tt, bool packed = false);
|
||||
|
|
|
|||
|
|
@ -163,9 +163,6 @@ int VTypePrimitive::emit_primitive_type(ostream&out) const
|
|||
case REAL:
|
||||
out << "real";
|
||||
break;
|
||||
case CHARACTER:
|
||||
out << "byte";
|
||||
break;
|
||||
case TIME:
|
||||
out << "time";
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -161,9 +161,6 @@ void VTypePrimitive::write_to_stream(ostream&fd) const
|
|||
case STDLOGIC:
|
||||
fd << "std_logic";
|
||||
break;
|
||||
case CHARACTER:
|
||||
fd << "character";
|
||||
break;
|
||||
case TIME:
|
||||
fd << "time";
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in New Issue