Support delays in logic devices
This commit is contained in:
parent
a5db0297b0
commit
30fdadc525
|
|
@ -242,9 +242,26 @@ static void declare_logic(vhdl_arch *arch, ivl_scope_t scope)
|
|||
dynamic_cast<vhdl_var_ref*>(nexus_to_expr(arch->get_scope(), output));
|
||||
if (NULL == lhs)
|
||||
continue; // Not suitable for continuous assignment
|
||||
|
||||
|
||||
vhdl_expr *rhs = translate_logic(arch->get_scope(), log);
|
||||
arch->add_stmt(new vhdl_cassign_stmt(lhs, rhs));
|
||||
vhdl_cassign_stmt *ass = new vhdl_cassign_stmt(lhs, rhs);
|
||||
|
||||
ivl_expr_t delay = ivl_logic_delay(log, 1);
|
||||
vhdl_expr *after;
|
||||
if (delay && (after = translate_expr(delay))) {
|
||||
// Need to make 'after' a time value
|
||||
// we can do this by multiplying by 1ns
|
||||
vhdl_type integer(VHDL_TYPE_INTEGER);
|
||||
after = after->cast(&integer);
|
||||
|
||||
vhdl_expr *ns1 = new vhdl_const_time(1, TIME_UNIT_NS);
|
||||
after = new vhdl_binop_expr(after, VHDL_BINOP_MULT, ns1,
|
||||
vhdl_type::time());
|
||||
|
||||
ass->set_after(after);
|
||||
}
|
||||
|
||||
arch->add_stmt(ass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -611,6 +611,12 @@ void vhdl_cassign_stmt::emit(std::ostream &of, int level) const
|
|||
of << "else ";
|
||||
}
|
||||
rhs_->emit(of, level);
|
||||
|
||||
if (after_) {
|
||||
of << " after ";
|
||||
after_->emit(of, level);
|
||||
}
|
||||
|
||||
of << ";";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -227,14 +227,15 @@ typedef std::list<vhdl_conc_stmt*> conc_stmt_list_t;
|
|||
class vhdl_cassign_stmt : public vhdl_conc_stmt {
|
||||
public:
|
||||
vhdl_cassign_stmt(vhdl_var_ref *lhs, vhdl_expr *rhs)
|
||||
: lhs_(lhs), rhs_(rhs) {}
|
||||
: lhs_(lhs), rhs_(rhs), after_(NULL) {}
|
||||
~vhdl_cassign_stmt();
|
||||
|
||||
void emit(std::ostream &of, int level) const;
|
||||
void add_condition(vhdl_expr *value, vhdl_expr *cond);
|
||||
void set_after(vhdl_expr *a) { after_ = a; }
|
||||
private:
|
||||
vhdl_var_ref *lhs_;
|
||||
vhdl_expr *rhs_;
|
||||
vhdl_expr *rhs_, *after_;
|
||||
|
||||
struct when_part_t {
|
||||
vhdl_expr *value, *cond;
|
||||
|
|
|
|||
Loading…
Reference in New Issue