Associate a type with each VHDL expression node
This commit is contained in:
parent
a8ecce7421
commit
cdb180e1d4
|
|
@ -40,7 +40,11 @@ static vhdl_expr *translate_string(ivl_expr_t e)
|
||||||
static vhdl_expr *translate_signal(ivl_expr_t e)
|
static vhdl_expr *translate_signal(ivl_expr_t e)
|
||||||
{
|
{
|
||||||
ivl_signal_t sig = ivl_expr_signal(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,9 @@ static int draw_stask_display(vhdl_process *proc, ivl_statement_t stmt)
|
||||||
e = new vhdl_const_string(" ");
|
e = new vhdl_const_string(" ");
|
||||||
|
|
||||||
vhdl_pcall_stmt *write = new vhdl_pcall_stmt("Write");
|
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);
|
write->add_expr(e);
|
||||||
|
|
||||||
proc->add_stmt(write);
|
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)
|
// WriteLine(Output, Verilog_Display_Line)
|
||||||
vhdl_pcall_stmt *write_line = new vhdl_pcall_stmt("WriteLine");
|
vhdl_pcall_stmt *write_line = new vhdl_pcall_stmt("WriteLine");
|
||||||
write_line->add_expr(new vhdl_var_ref("std.textio.Output"));
|
vhdl_var_ref *output_ref =
|
||||||
write_line->add_expr(new vhdl_var_ref(display_line));
|
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);
|
proc->add_stmt(write_line);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -343,6 +343,21 @@ void vhdl_wait_stmt::emit(std::ofstream &of, int level) const
|
||||||
of << "wait;";
|
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
|
void vhdl_scalar_type::emit(std::ofstream &of, int level) const
|
||||||
{
|
{
|
||||||
of << name_;
|
of << name_;
|
||||||
|
|
@ -374,6 +389,11 @@ void vhdl_signal_decl::emit(std::ofstream &of, int level) const
|
||||||
emit_comment(of, level, true);
|
emit_comment(of, level, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vhdl_expr::~vhdl_expr()
|
||||||
|
{
|
||||||
|
delete type_;
|
||||||
|
}
|
||||||
|
|
||||||
void vhdl_expr_list::add_expr(vhdl_expr *e)
|
void vhdl_expr_list::add_expr(vhdl_expr *e)
|
||||||
{
|
{
|
||||||
exprs_.push_back(e);
|
exprs_.push_back(e);
|
||||||
|
|
|
||||||
|
|
@ -64,13 +64,21 @@ public:
|
||||||
vhdl_scalar_type(const char *name) : name_(name) {}
|
vhdl_scalar_type(const char *name) : name_(name) {}
|
||||||
|
|
||||||
void emit(std::ofstream &of, int level) const;
|
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:
|
private:
|
||||||
std::string name_;
|
std::string name_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class vhdl_expr : public vhdl_element {
|
class vhdl_expr : public vhdl_element {
|
||||||
public:
|
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 {
|
class vhdl_var_ref : public vhdl_expr {
|
||||||
public:
|
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;
|
void emit(std::ofstream &of, int level) const;
|
||||||
private:
|
private:
|
||||||
|
|
@ -87,7 +96,8 @@ private:
|
||||||
|
|
||||||
class vhdl_const_string : public vhdl_expr {
|
class vhdl_const_string : public vhdl_expr {
|
||||||
public:
|
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;
|
void emit(std::ofstream &of, int level) const;
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue