Don't bother calling reduction function if argument is std_logic
This commit is contained in:
parent
33885ed891
commit
09f3eb4a36
|
|
@ -106,18 +106,26 @@ static vhdl_expr *translate_ulong(ivl_expr_t e)
|
||||||
static vhdl_expr *translate_reduction(support_function_t f, bool neg,
|
static vhdl_expr *translate_reduction(support_function_t f, bool neg,
|
||||||
vhdl_expr *operand)
|
vhdl_expr *operand)
|
||||||
{
|
{
|
||||||
require_support_function(f);
|
vhdl_expr *result;
|
||||||
vhdl_fcall *fcall =
|
if (operand->get_type()->get_name() == VHDL_TYPE_STD_LOGIC)
|
||||||
new vhdl_fcall(support_function::function_name(f),
|
result = operand;
|
||||||
vhdl_type::std_logic());
|
else {
|
||||||
|
require_support_function(f);
|
||||||
vhdl_type std_logic_vector(VHDL_TYPE_STD_LOGIC_VECTOR);
|
vhdl_fcall *fcall =
|
||||||
fcall->add_expr(operand->cast(&std_logic_vector));
|
new vhdl_fcall(support_function::function_name(f),
|
||||||
|
vhdl_type::std_logic());
|
||||||
|
|
||||||
|
vhdl_type std_logic_vector(VHDL_TYPE_STD_LOGIC_VECTOR);
|
||||||
|
fcall->add_expr(operand->cast(&std_logic_vector));
|
||||||
|
|
||||||
|
result = fcall;
|
||||||
|
}
|
||||||
|
|
||||||
if (neg)
|
if (neg)
|
||||||
return new vhdl_unaryop_expr(VHDL_UNARYOP_NOT, fcall,
|
return new vhdl_unaryop_expr(VHDL_UNARYOP_NOT, result,
|
||||||
vhdl_type::std_logic());
|
vhdl_type::std_logic());
|
||||||
else
|
else
|
||||||
return fcall;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static vhdl_expr *translate_unary(ivl_expr_t e)
|
static vhdl_expr *translate_unary(ivl_expr_t e)
|
||||||
|
|
|
||||||
|
|
@ -144,22 +144,29 @@ static vhdl_expr *ufunc_lpm_to_expr(vhdl_scope *scope, ivl_lpm_t lpm)
|
||||||
static vhdl_expr *reduction_lpm_to_expr(vhdl_scope *scope, ivl_lpm_t lpm,
|
static vhdl_expr *reduction_lpm_to_expr(vhdl_scope *scope, ivl_lpm_t lpm,
|
||||||
support_function_t f, bool invert)
|
support_function_t f, bool invert)
|
||||||
{
|
{
|
||||||
require_support_function(f);
|
|
||||||
vhdl_fcall *fcall = new vhdl_fcall(support_function::function_name(f),
|
|
||||||
vhdl_type::std_logic());
|
|
||||||
|
|
||||||
vhdl_var_ref *ref = nexus_to_var_ref(scope, ivl_lpm_data(lpm, 0));
|
vhdl_var_ref *ref = nexus_to_var_ref(scope, ivl_lpm_data(lpm, 0));
|
||||||
if (NULL == ref)
|
if (NULL == ref)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
vhdl_type std_logic_vector(VHDL_TYPE_STD_LOGIC_VECTOR);
|
vhdl_expr *result;
|
||||||
fcall->add_expr(ref->cast(&std_logic_vector));
|
if (ref->get_type()->get_name() == VHDL_TYPE_STD_LOGIC)
|
||||||
|
result = ref;
|
||||||
|
else {
|
||||||
|
require_support_function(f);
|
||||||
|
vhdl_fcall *fcall = new vhdl_fcall(support_function::function_name(f),
|
||||||
|
vhdl_type::std_logic());
|
||||||
|
|
||||||
|
vhdl_type std_logic_vector(VHDL_TYPE_STD_LOGIC_VECTOR);
|
||||||
|
fcall->add_expr(ref->cast(&std_logic_vector));
|
||||||
|
|
||||||
|
result = fcall;
|
||||||
|
}
|
||||||
|
|
||||||
if (invert)
|
if (invert)
|
||||||
return new vhdl_unaryop_expr
|
return new vhdl_unaryop_expr
|
||||||
(VHDL_UNARYOP_NOT, fcall, vhdl_type::std_logic());
|
(VHDL_UNARYOP_NOT, result, vhdl_type::std_logic());
|
||||||
else
|
else
|
||||||
return fcall;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static vhdl_expr *sign_extend_lpm_to_expr(vhdl_scope *scope, ivl_lpm_t lpm)
|
static vhdl_expr *sign_extend_lpm_to_expr(vhdl_scope *scope, ivl_lpm_t lpm)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue