Wait statements

This commit is contained in:
Nick Gasson 2008-06-09 12:40:59 +01:00
parent 1d28b935e8
commit d762253f74
4 changed files with 50 additions and 4 deletions

View File

@ -73,7 +73,7 @@ int draw_process(ivl_process_t proc, void *cd)
assert(ivl_scope_type(scope) == IVL_SCT_MODULE);
vhdl_entity *ent = find_entity(ivl_scope_tname(scope));
assert(ent != NULL);
// If the scope this process belongs to is the same as the
// VHDL entity was generated from, then create a VHDL process
// from this Verilog process. This ensures that each process

View File

@ -190,7 +190,22 @@ static int draw_nbassign(vhdl_process *proc, ivl_statement_t stmt)
*/
static int draw_delay(vhdl_process *proc, ivl_statement_t stmt)
{
std::cout << "draw_delay" << std::endl;
uint64_t value = ivl_stmt_delay_val(stmt);
// This currently ignores the time units and precision
// of the enclosing scope
// A neat way to do this would be to make these values
// constants in the scope (type is Time), and have the
// VHDL wait statement compute the value from that.
// The other solution is to add them as parameters to
// the vhdl_process class
std::cout << "Delay for " << value << std::endl;
// Expand the sub-statement as well
// Often this can result in a useless `null' statement
// Maybe add a check here and ignore it if it IVL_ST_NOOP?
draw_stmt(proc, ivl_stmt_sub_stmt(stmt));
return 0;
}

View File

@ -262,10 +262,28 @@ void vhdl_component_decl::emit(std::ofstream &of, int level) const
of << "end component;";
}
vhdl_wait_stmt::~vhdl_wait_stmt()
{
if (expr_ != NULL)
delete expr_;
}
void vhdl_wait_stmt::emit(std::ofstream &of, int level) const
{
// TODO: There are lots of different types of `wait'
of << "wait;";
of << "wait";
switch (type_) {
case VHDL_WAIT_INDEF:
break;
case VHDL_WAIT_FOR_NS:
assert(expr_);
of << " for ";
expr_->emit(of, level);
of << " ns";
break;
}
of << ";";
}

View File

@ -154,13 +154,26 @@ private:
vhdl_expr *rhs_;
};
enum vhdl_wait_type_t {
VHDL_WAIT_INDEF, // Suspend indefinitely
VHDL_WAIT_FOR_NS, // Wait for a constant number of nanoseconds
};
/*
* Delay simulation indefinitely, until an event, or for a
* specified time.
*/
class vhdl_wait_stmt : public vhdl_seq_stmt {
public:
vhdl_wait_stmt(vhdl_wait_type_t type = VHDL_WAIT_INDEF,
vhdl_expr *expr = NULL)
: type_(type), expr_(expr) {}
~vhdl_wait_stmt();
void emit(std::ofstream &of, int level) const;
private:
vhdl_wait_type_t type_;
vhdl_expr *expr_;
};