Add VHDL report statement
Not output yet, but will be used to replace std.textio implementation of $display. Conflicts: tgt-vhdl/vhdl_syntax.cc
This commit is contained in:
parent
2187f30207
commit
9faaf5f817
|
|
@ -788,10 +788,42 @@ void vhdl_cassign_stmt::emit(std::ostream &of, int level) const
|
||||||
of << ";";
|
of << ";";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vhdl_report_stmt::vhdl_report_stmt(vhdl_expr *text,
|
||||||
|
vhdl_severity_t severity)
|
||||||
|
: severity_(severity),
|
||||||
|
text_(text)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void vhdl_report_stmt::emit(ostream& of, int level) const
|
||||||
|
{
|
||||||
|
of << "report ";
|
||||||
|
text_->emit(of, level);
|
||||||
|
|
||||||
|
if (severity_ != SEVERITY_NOTE) {
|
||||||
|
const char *levels[] = { "note", "warning", "error", "failure" };
|
||||||
|
of << " severity " << levels[severity_];
|
||||||
|
}
|
||||||
|
|
||||||
|
of << ";";
|
||||||
|
}
|
||||||
|
|
||||||
|
void vhdl_report_stmt::find_vars(vhdl_var_set_t& read, vhdl_var_set_t& write)
|
||||||
|
{
|
||||||
|
text_->find_vars(read);
|
||||||
|
}
|
||||||
|
|
||||||
|
vhdl_assert_stmt::vhdl_assert_stmt(const char *reason)
|
||||||
|
: vhdl_report_stmt(new vhdl_const_string(reason), SEVERITY_FAILURE)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void vhdl_assert_stmt::emit(std::ostream &of, int level) const
|
void vhdl_assert_stmt::emit(std::ostream &of, int level) const
|
||||||
{
|
{
|
||||||
of << "assert false"; // TODO: Allow arbitrary expression
|
of << "assert false "; // TODO: Allow arbitrary expression
|
||||||
of << " report \"" << reason_ << "\" severity failure;";
|
vhdl_report_stmt::emit(of, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
vhdl_if_stmt::vhdl_if_stmt(vhdl_expr *test)
|
vhdl_if_stmt::vhdl_if_stmt(vhdl_expr *test)
|
||||||
|
|
|
||||||
|
|
@ -453,15 +453,32 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class vhdl_assert_stmt : public vhdl_seq_stmt {
|
enum vhdl_severity_t {
|
||||||
public:
|
SEVERITY_NOTE,
|
||||||
vhdl_assert_stmt(const char *reason)
|
SEVERITY_WARNING,
|
||||||
: reason_(reason) {}
|
SEVERITY_ERROR,
|
||||||
|
SEVERITY_FAILURE
|
||||||
|
};
|
||||||
|
|
||||||
void emit(std::ostream &of, int level) const;
|
class vhdl_report_stmt : public vhdl_seq_stmt {
|
||||||
void find_vars(vhdl_var_set_t& read, vhdl_var_set_t& write) {}
|
public:
|
||||||
|
vhdl_report_stmt(vhdl_expr *text,
|
||||||
|
vhdl_severity_t severity = SEVERITY_NOTE);
|
||||||
|
virtual ~vhdl_report_stmt() {}
|
||||||
|
|
||||||
|
virtual void emit(ostream& of, int level) const;
|
||||||
|
void find_vars(vhdl_var_set_t& read, vhdl_var_set_t& write);
|
||||||
private:
|
private:
|
||||||
std::string reason_;
|
vhdl_severity_t severity_;
|
||||||
|
vhdl_expr *text_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class vhdl_assert_stmt : public vhdl_report_stmt {
|
||||||
|
public:
|
||||||
|
vhdl_assert_stmt(const char *reason);
|
||||||
|
|
||||||
|
void emit(ostream &of, int level) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue