diff --git a/tgt-vhdl/expr.cc b/tgt-vhdl/expr.cc index ead20f2bf..80b9a05bc 100644 --- a/tgt-vhdl/expr.cc +++ b/tgt-vhdl/expr.cc @@ -40,7 +40,11 @@ static vhdl_expr *translate_string(ivl_expr_t e) static vhdl_expr *translate_signal(ivl_expr_t e) { ivl_signal_t sig = ivl_expr_signal(e); - return new vhdl_var_ref(ivl_signal_basename(sig)); + + // Assume all signals are single bits at the moment + vhdl_type *type = vhdl_scalar_type::std_logic(); + + return new vhdl_var_ref(ivl_signal_basename(sig), type); } /* diff --git a/tgt-vhdl/stmt.cc b/tgt-vhdl/stmt.cc index bdeb5d2e7..c42110707 100644 --- a/tgt-vhdl/stmt.cc +++ b/tgt-vhdl/stmt.cc @@ -70,7 +70,9 @@ static int draw_stask_display(vhdl_process *proc, ivl_statement_t stmt) e = new vhdl_const_string(" "); vhdl_pcall_stmt *write = new vhdl_pcall_stmt("Write"); - write->add_expr(new vhdl_var_ref(display_line)); + vhdl_var_ref *ref = + new vhdl_var_ref(display_line, vhdl_scalar_type::line()); + write->add_expr(ref); write->add_expr(e); proc->add_stmt(write); @@ -78,8 +80,12 @@ static int draw_stask_display(vhdl_process *proc, ivl_statement_t stmt) // WriteLine(Output, Verilog_Display_Line) vhdl_pcall_stmt *write_line = new vhdl_pcall_stmt("WriteLine"); - write_line->add_expr(new vhdl_var_ref("std.textio.Output")); - write_line->add_expr(new vhdl_var_ref(display_line)); + vhdl_var_ref *output_ref = + new vhdl_var_ref("std.textio.Output", new vhdl_scalar_type("File")); + write_line->add_expr(output_ref); + vhdl_var_ref *ref = + new vhdl_var_ref(display_line, vhdl_scalar_type::line()); + write_line->add_expr(ref); proc->add_stmt(write_line); return 0; diff --git a/tgt-vhdl/vhdl_element.cc b/tgt-vhdl/vhdl_element.cc index 648cde01d..ab3d49b14 100644 --- a/tgt-vhdl/vhdl_element.cc +++ b/tgt-vhdl/vhdl_element.cc @@ -343,6 +343,21 @@ void vhdl_wait_stmt::emit(std::ofstream &of, int level) const of << "wait;"; } +vhdl_scalar_type *vhdl_scalar_type::std_logic() +{ + return new vhdl_scalar_type("std_logic"); +} + +vhdl_scalar_type *vhdl_scalar_type::string() +{ + return new vhdl_scalar_type("String"); +} + +vhdl_scalar_type *vhdl_scalar_type::line() +{ + return new vhdl_scalar_type("Line"); +} + void vhdl_scalar_type::emit(std::ofstream &of, int level) const { of << name_; @@ -374,6 +389,11 @@ void vhdl_signal_decl::emit(std::ofstream &of, int level) const emit_comment(of, level, true); } +vhdl_expr::~vhdl_expr() +{ + delete type_; +} + void vhdl_expr_list::add_expr(vhdl_expr *e) { exprs_.push_back(e); diff --git a/tgt-vhdl/vhdl_element.hh b/tgt-vhdl/vhdl_element.hh index 3e14a2bd6..80029e585 100644 --- a/tgt-vhdl/vhdl_element.hh +++ b/tgt-vhdl/vhdl_element.hh @@ -64,13 +64,21 @@ public: vhdl_scalar_type(const char *name) : name_(name) {} void emit(std::ofstream &of, int level) const; + + // Common types + static vhdl_scalar_type *std_logic(); + static vhdl_scalar_type *string(); + static vhdl_scalar_type *line(); private: std::string name_; }; class vhdl_expr : public vhdl_element { public: - virtual ~vhdl_expr() {} + vhdl_expr(vhdl_type* type) : type_(type) {} + virtual ~vhdl_expr(); +private: + vhdl_type *type_; }; /* @@ -78,7 +86,8 @@ public: */ class vhdl_var_ref : public vhdl_expr { public: - vhdl_var_ref(const char *name) : name_(name) {} + vhdl_var_ref(const char *name, vhdl_type *type) + : vhdl_expr(type), name_(name) {} void emit(std::ofstream &of, int level) const; private: @@ -87,7 +96,8 @@ private: class vhdl_const_string : public vhdl_expr { public: - vhdl_const_string(const char *value) : value_(value) {} + vhdl_const_string(const char *value) + : vhdl_expr(vhdl_scalar_type::string()), value_(value) {} void emit(std::ofstream &of, int level) const; private: