Fix mapping of VHDL expressions to function arguments
Noticed this as part of the test case for pr2516774b. Under some circumstances the input arguments would be cast to the wrong type. This patch ensures that all the arguments have the correct type.
This commit is contained in:
parent
3cc2018346
commit
e5ce88304e
|
|
@ -292,3 +292,9 @@ vhdl_expr *vhdl_const_bit::to_boolean()
|
|||
{
|
||||
return new vhdl_const_bool(bit_ == '1');
|
||||
}
|
||||
|
||||
vhdl_expr *vhdl_const_bit::to_vector(vhdl_type_name_t name, int w)
|
||||
{
|
||||
// Zero-extend this bit to the correct width
|
||||
return (new vhdl_const_bits(&bit_, 1, name == VHDL_TYPE_SIGNED))->resize(w);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -522,13 +522,17 @@ static vhdl_expr *translate_ufunc(ivl_expr_t e)
|
|||
vhdl_fcall *fcall = new vhdl_fcall(funcname, rettype);
|
||||
|
||||
int nparams = ivl_expr_parms(e);
|
||||
int func_scope_sig = 0;
|
||||
for (int i = 0; i < nparams; i++) {
|
||||
vhdl_expr *param = translate_expr(ivl_expr_parm(e, i));
|
||||
if (NULL == param)
|
||||
return NULL;
|
||||
|
||||
// Ensure the parameter has the correct VHDL type
|
||||
ivl_signal_t param_sig = ivl_scope_sig(defscope, i);
|
||||
ivl_signal_t param_sig;
|
||||
do {
|
||||
param_sig = ivl_scope_sig(defscope, func_scope_sig++);
|
||||
} while (ivl_signal_port(param_sig) != IVL_SIP_INPUT);
|
||||
vhdl_type *param_type =
|
||||
vhdl_type::type_for(ivl_signal_width(param_sig),
|
||||
ivl_signal_signed(param_sig) != 0);
|
||||
|
|
|
|||
|
|
@ -196,6 +196,7 @@ public:
|
|||
void emit(std::ostream &of, int level) const;
|
||||
vhdl_expr *to_boolean();
|
||||
vhdl_expr *to_integer();
|
||||
vhdl_expr *to_vector(vhdl_type_name_t name, int w);
|
||||
private:
|
||||
char bit_;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue