diff --git a/vhdlpp/entity.h b/vhdlpp/entity.h index 3919c5366..a6ec469c1 100644 --- a/vhdlpp/entity.h +++ b/vhdlpp/entity.h @@ -75,8 +75,9 @@ class Entity : public LineInfo { std::maparch_; Architecture*bind_arch_; - enum vtype_t { VNONE, VUWIRE }; + enum vtype_t { VNONE, VBOOL, VLOGIC }; struct decl_t { + bool signed_flag; vtype_t type; long msb, lsb; }; diff --git a/vhdlpp/entity_elaborate.cc b/vhdlpp/entity_elaborate.cc index 752f8efc5..9ad06ed11 100644 --- a/vhdlpp/entity_elaborate.cc +++ b/vhdlpp/entity_elaborate.cc @@ -87,17 +87,24 @@ int Entity::elaborate_ports_(void) InterfacePort*cur_port = *cur; decl_t cur_decl; cur_decl.type = VNONE; + cur_decl.signed_flag = false; cur_decl.msb = 0; cur_decl.lsb = 0; if (strcasecmp(cur_port->type_name, "std_logic") == 0) { - cur_decl.type = VUWIRE; + cur_decl.type = VLOGIC; } else if (strcasecmp(cur_port->type_name, "bit") == 0) { - cur_decl.type = VUWIRE; + cur_decl.type = VBOOL; } else if (strcasecmp(cur_port->type_name, "boolean") == 0) { - cur_decl.type = VUWIRE; + cur_decl.type = VBOOL; + + } else if (strcasecmp(cur_port->type_name, "integer") == 0) { + cur_decl.type = VBOOL; + cur_decl.signed_flag = true; + cur_decl.msb = 31; + cur_decl.lsb = 0; } else { cerr << get_fileline() << ": error: " diff --git a/vhdlpp/entity_emit.cc b/vhdlpp/entity_emit.cc index 3f82396d7..a35e1a3b2 100644 --- a/vhdlpp/entity_emit.cc +++ b/vhdlpp/entity_emit.cc @@ -49,6 +49,8 @@ int Entity::emit(ostream&out) ; cur != ports_.end() ; ++cur) { InterfacePort*port = *cur; + decl_t&decl = declarations_[port->name]; + if (sep) out << sep; else sep = ", "; @@ -57,10 +59,18 @@ int Entity::emit(ostream&out) out << "NO_PORT " << port->name; break; case PORT_IN: - out << "input " << port->name; + out << "input "; + if (decl.msb != decl.lsb) + out << "[" << decl.msb + << ":" << decl.lsb << "] "; + out << port->name; break; case PORT_OUT: - out << "output " << port->name; + out << "output "; + if (decl.msb != decl.lsb) + out << "[" << decl.msb + << ":" << decl.lsb << "] "; + out << port->name; break; } } @@ -76,8 +86,16 @@ int Entity::emit(ostream&out) case VNONE: out << "// N type for " << cur->first << endl; break; - case VUWIRE: - out << "wire "; + case VLOGIC: + out << "wire logic "; + if (cur->second.msb != cur->second.lsb) + out << "[" << cur->second.msb + << ":" << cur->second.lsb << "] "; + out << cur->first << ";" << endl; + case VBOOL: + out << "wire bool "; + if (cur->second.signed_flag) + out << "signed "; if (cur->second.msb != cur->second.lsb) out << "[" << cur->second.msb << ":" << cur->second.lsb << "] ";