From 25458b8cc20dac76f7ba674e839ec3b11bbeeaa9 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Fri, 8 May 2015 15:55:26 +0200 Subject: [PATCH] vhdlpp: inout direction for ports. --- vhdlpp/entity.h | 2 +- vhdlpp/entity_emit.cc | 8 ++++++-- vhdlpp/entity_stream.cc | 3 +++ vhdlpp/parse.y | 1 + vhdlpp/subprogram_emit.cc | 3 +++ 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/vhdlpp/entity.h b/vhdlpp/entity.h index b93d6a369..8c41e52ab 100644 --- a/vhdlpp/entity.h +++ b/vhdlpp/entity.h @@ -27,7 +27,7 @@ # include "StringHeap.h" # include "LineInfo.h" -typedef enum { PORT_NONE=0, PORT_IN, PORT_OUT } port_mode_t; +typedef enum { PORT_NONE=0, PORT_IN, PORT_OUT, PORT_INOUT } port_mode_t; class Architecture; class Expression; diff --git a/vhdlpp/entity_emit.cc b/vhdlpp/entity_emit.cc index 268b36f7d..fd2077fdc 100644 --- a/vhdlpp/entity_emit.cc +++ b/vhdlpp/entity_emit.cc @@ -74,17 +74,21 @@ int Entity::emit(ostream&out) switch (port->mode) { case PORT_NONE: // Should not happen + cerr << get_fileline() << ": error: Undefined port direction." << endl; out << "NO_PORT " << port->name; break; case PORT_IN: out << "input "; - errors += decl.emit(out, port->name); break; case PORT_OUT: out << "output "; - errors += decl.emit(out, port->name); + break; + case PORT_INOUT: + out << "inout "; break; } + + errors += decl.emit(out, port->name); } cout << ")"; } diff --git a/vhdlpp/entity_stream.cc b/vhdlpp/entity_stream.cc index cd1e67334..dfde97c74 100644 --- a/vhdlpp/entity_stream.cc +++ b/vhdlpp/entity_stream.cc @@ -69,6 +69,9 @@ void ComponentBase::write_to_stream(ostream&fd) const case PORT_OUT: fd << "out "; break; + case PORT_INOUT: + fd << "inout "; + break; } item->type->write_to_stream(fd); diff --git a/vhdlpp/parse.y b/vhdlpp/parse.y index 9e60453b1..0927022be 100644 --- a/vhdlpp/parse.y +++ b/vhdlpp/parse.y @@ -1584,6 +1584,7 @@ loop_statement mode : K_in { $$ = PORT_IN; } | K_out { $$ = PORT_OUT; } + | K_inout { $$ = PORT_INOUT; } ; mode_opt : mode {$$ = $1;} | {$$ = PORT_NONE;} ; diff --git a/vhdlpp/subprogram_emit.cc b/vhdlpp/subprogram_emit.cc index 5cb43e3a6..c2ae47cd8 100644 --- a/vhdlpp/subprogram_emit.cc +++ b/vhdlpp/subprogram_emit.cc @@ -50,6 +50,9 @@ int Subprogram::emit_package(ostream&fd) const case PORT_OUT: fd << "output "; break; + case PORT_INOUT: + fd << "inout "; + break; case PORT_NONE: fd << "inout /* PORT_NONE? */ "; break;