Support procedure call generation for $display
This commit is contained in:
parent
94006cb44c
commit
dd30c1b39d
|
|
@ -53,7 +53,13 @@ static int draw_stask_display(vhdl_process *proc, ivl_statement_t stmt)
|
|||
|
||||
// TODO: Write the data into the line
|
||||
|
||||
// TODO: Write_Line(Output, Verilog_Display_Line)
|
||||
// Write_Line(Output, Verilog_Display_Line)
|
||||
vhdl_var_ref *output_ref = new vhdl_var_ref("Output");
|
||||
vhdl_var_ref *line_ref = new vhdl_var_ref(display_line);
|
||||
vhdl_pcall_stmt *write_line = new vhdl_pcall_stmt("Write_Line");
|
||||
write_line->add_expr(output_ref);
|
||||
write_line->add_expr(line_ref);
|
||||
proc->add_stmt(write_line);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -283,3 +283,40 @@ void vhdl_var_decl::emit(std::ofstream &of, int level) const
|
|||
of << ";";
|
||||
emit_comment(of, level, true);
|
||||
}
|
||||
|
||||
void vhdl_expr_list::add_expr(vhdl_expr *e)
|
||||
{
|
||||
exprs_.push_back(e);
|
||||
}
|
||||
|
||||
vhdl_expr_list::~vhdl_expr_list()
|
||||
{
|
||||
delete_children<vhdl_expr>(exprs_);
|
||||
}
|
||||
|
||||
void vhdl_expr_list::emit(std::ofstream &of, int level) const
|
||||
{
|
||||
of << "(";
|
||||
|
||||
int size = exprs_.size();
|
||||
std::list<vhdl_expr*>::const_iterator it;
|
||||
for (it = exprs_.begin(); it != exprs_.end(); ++it) {
|
||||
(*it)->emit(of, level);
|
||||
if (--size > 0)
|
||||
of << ", ";
|
||||
}
|
||||
|
||||
of << ")";
|
||||
}
|
||||
|
||||
void vhdl_pcall_stmt::emit(std::ofstream &of, int level) const
|
||||
{
|
||||
of << name_;
|
||||
exprs_.emit(of, level);
|
||||
of << ";";
|
||||
}
|
||||
|
||||
void vhdl_var_ref::emit(std::ofstream &of, int level) const
|
||||
{
|
||||
of << name_;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,34 @@ private:
|
|||
std::string name_;
|
||||
};
|
||||
|
||||
class vhdl_expr : public vhdl_element {
|
||||
public:
|
||||
virtual ~vhdl_expr() {}
|
||||
};
|
||||
|
||||
/*
|
||||
* A normal scalar variable reference.
|
||||
*/
|
||||
class vhdl_var_ref : public vhdl_expr {
|
||||
public:
|
||||
vhdl_var_ref(const char *name) : name_(name) {}
|
||||
|
||||
void emit(std::ofstream &of, int level) const;
|
||||
private:
|
||||
std::string name_;
|
||||
};
|
||||
|
||||
class vhdl_expr_list : public vhdl_element {
|
||||
public:
|
||||
~vhdl_expr_list();
|
||||
|
||||
void emit(std::ofstream &of, int level) const;
|
||||
void add_expr(vhdl_expr *e);
|
||||
private:
|
||||
std::list<vhdl_expr*> exprs_;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* A concurrent statement appears in architecture bodies but not
|
||||
* processes.
|
||||
|
|
@ -98,6 +126,22 @@ public:
|
|||
};
|
||||
|
||||
|
||||
/*
|
||||
* A procedure call. Which is a statement, unlike a function
|
||||
* call which is an expression.
|
||||
*/
|
||||
class vhdl_pcall_stmt : public vhdl_seq_stmt {
|
||||
public:
|
||||
vhdl_pcall_stmt(const char *name) : name_(name) {}
|
||||
|
||||
void emit(std::ofstream &of, int level) const;
|
||||
void add_expr(vhdl_expr *e) { exprs_.add_expr(e); }
|
||||
private:
|
||||
std::string name_;
|
||||
vhdl_expr_list exprs_;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* A declaration of some sort (variable, component, etc.).
|
||||
* Declarations have names, which is the identifier of the variable,
|
||||
|
|
|
|||
Loading…
Reference in New Issue