Support IVL_EX_DELAY in VHDL target
This patch adds a translation of 64-bit delay expressions to vhdl_const_time objects.
This commit is contained in:
parent
6828620977
commit
5660e67b8b
|
|
@ -134,6 +134,11 @@ static vhdl_expr *translate_ulong(ivl_expr_t e)
|
|||
return new vhdl_const_int(ivl_expr_uvalue(e));
|
||||
}
|
||||
|
||||
static vhdl_expr *translate_delay(ivl_expr_t e)
|
||||
{
|
||||
return new vhdl_const_time(ivl_expr_delay_val(e), TIME_UNIT_NS);
|
||||
}
|
||||
|
||||
static vhdl_expr *translate_reduction(support_function_t f, bool neg,
|
||||
vhdl_expr *operand)
|
||||
{
|
||||
|
|
@ -684,6 +689,8 @@ vhdl_expr *translate_expr(ivl_expr_t e)
|
|||
return translate_concat(e);
|
||||
case IVL_EX_SFUNC:
|
||||
return translate_sfunc(e);
|
||||
case IVL_EX_DELAY:
|
||||
return translate_delay(e);
|
||||
case IVL_EX_REALNUM:
|
||||
error("No VHDL translation for real expression at %s:%d",
|
||||
ivl_expr_file(e), ivl_expr_lineno(e));
|
||||
|
|
@ -705,10 +712,14 @@ vhdl_expr *translate_time_expr(ivl_expr_t e)
|
|||
if (NULL == time)
|
||||
return NULL;
|
||||
|
||||
vhdl_type integer(VHDL_TYPE_INTEGER);
|
||||
time = time->cast(&integer);
|
||||
|
||||
vhdl_expr *ns1 = new vhdl_const_time(1, TIME_UNIT_NS);
|
||||
return new vhdl_binop_expr(time, VHDL_BINOP_MULT, ns1,
|
||||
vhdl_type::time());
|
||||
if (time->get_type()->get_name() != VHDL_TYPE_TIME) {
|
||||
vhdl_type integer(VHDL_TYPE_INTEGER);
|
||||
time = time->cast(&integer);
|
||||
|
||||
vhdl_expr *ns1 = new vhdl_const_time(1, TIME_UNIT_NS);
|
||||
return new vhdl_binop_expr(time, VHDL_BINOP_MULT, ns1,
|
||||
vhdl_type::time());
|
||||
}
|
||||
else // Translating IVL_EX_DELAY will always return a time type
|
||||
return time;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -208,11 +208,11 @@ enum time_unit_t {
|
|||
|
||||
class vhdl_const_time : public vhdl_expr {
|
||||
public:
|
||||
vhdl_const_time(int64_t value, time_unit_t units = TIME_UNIT_NS)
|
||||
vhdl_const_time(uint64_t value, time_unit_t units = TIME_UNIT_NS)
|
||||
: vhdl_expr(vhdl_type::time(), true), value_(value), units_(units) {}
|
||||
void emit(std::ostream &of, int level) const;
|
||||
private:
|
||||
int64_t value_;
|
||||
uint64_t value_;
|
||||
time_unit_t units_;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue