Add repeat statement
This commit is contained in:
parent
8bee5b1108
commit
39c9c54760
|
|
@ -570,6 +570,26 @@ int draw_forever(vhdl_procedural *proc, stmt_container *container,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int draw_repeat(vhdl_procedural *proc, stmt_container *container,
|
||||
ivl_statement_t stmt)
|
||||
{
|
||||
vhdl_expr *times = translate_expr(ivl_stmt_cond_expr(stmt));
|
||||
if (NULL == times)
|
||||
return 1;
|
||||
|
||||
vhdl_type integer(VHDL_TYPE_INTEGER);
|
||||
times = times->cast(&integer);
|
||||
|
||||
const char *it_name = "Verilog_Repeat";
|
||||
vhdl_for_stmt *loop =
|
||||
new vhdl_for_stmt(it_name, new vhdl_const_int(1), times);
|
||||
container->add_stmt(loop);
|
||||
|
||||
draw_stmt(proc, loop->get_container(), ivl_stmt_sub_stmt(stmt));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate VHDL statements for the given Verilog statement and
|
||||
* add them to the given VHDL process. The container is the
|
||||
|
|
@ -606,6 +626,8 @@ int draw_stmt(vhdl_procedural *proc, stmt_container *container,
|
|||
return draw_while(proc, container, stmt);
|
||||
case IVL_ST_FOREVER:
|
||||
return draw_forever(proc, container, stmt);
|
||||
case IVL_ST_REPEAT:
|
||||
return draw_repeat(proc, container, stmt);
|
||||
default:
|
||||
error("No VHDL translation for statement at %s:%d (type = %d)",
|
||||
ivl_stmt_file(stmt), ivl_stmt_lineno(stmt),
|
||||
|
|
|
|||
|
|
@ -773,6 +773,22 @@ void vhdl_loop_stmt::emit(std::ostream &of, int level) const
|
|||
of << "end loop;";
|
||||
}
|
||||
|
||||
vhdl_for_stmt::~vhdl_for_stmt()
|
||||
{
|
||||
delete from_;
|
||||
delete to_;
|
||||
}
|
||||
|
||||
void vhdl_for_stmt::emit(std::ostream &of, int level) const
|
||||
{
|
||||
of << "for " << lname_ << " in ";
|
||||
from_->emit(of, level);
|
||||
of << " to ";
|
||||
to_->emit(of, level);
|
||||
of << " ";
|
||||
loop_.emit(of, level);
|
||||
}
|
||||
|
||||
vhdl_function::vhdl_function(const char *name, vhdl_type *ret_type)
|
||||
: vhdl_decl(name, ret_type)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -417,6 +417,21 @@ private:
|
|||
};
|
||||
|
||||
|
||||
class vhdl_for_stmt : public vhdl_seq_stmt {
|
||||
public:
|
||||
vhdl_for_stmt(const char *lname, vhdl_expr *from, vhdl_expr *to)
|
||||
: lname_(lname), from_(from), to_(to) {}
|
||||
~vhdl_for_stmt();
|
||||
|
||||
stmt_container *get_container() { return loop_.get_container(); }
|
||||
void emit(std::ostream &of, int level) const;
|
||||
private:
|
||||
vhdl_loop_stmt loop_;
|
||||
const char *lname_;
|
||||
vhdl_expr *from_, *to_;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* A procedure call. Which is a statement, unlike a function
|
||||
* call which is an expression.
|
||||
|
|
|
|||
Loading…
Reference in New Issue