From 122890fef402ec16b4913e5c3827b37ef16a98d6 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Tue, 2 Sep 2008 19:02:54 +0100 Subject: [PATCH 1/3] Make sure LPM expression is cast to the output type This fixes some signed/unsigned bugs identified by the signedX tests. --- tgt-vhdl/lpm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tgt-vhdl/lpm.cc b/tgt-vhdl/lpm.cc index 3c2af5ead..22dd53394 100644 --- a/tgt-vhdl/lpm.cc +++ b/tgt-vhdl/lpm.cc @@ -323,7 +323,7 @@ int draw_lpm(vhdl_arch *arch, ivl_lpm_t lpm) out->set_slice(off, ivl_lpm_width(lpm) - 1); } - arch->add_stmt(new vhdl_cassign_stmt(out, f)); + arch->add_stmt(new vhdl_cassign_stmt(out, f->cast(out->get_type()))); return 0; } From ff766899b09a94fd8f566cdca5862e85344293cc Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Tue, 2 Sep 2008 19:07:38 +0100 Subject: [PATCH 2/3] Add IVL_LPM_CMP_GT --- tgt-vhdl/lpm.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tgt-vhdl/lpm.cc b/tgt-vhdl/lpm.cc index 22dd53394..9213cd24c 100644 --- a/tgt-vhdl/lpm.cc +++ b/tgt-vhdl/lpm.cc @@ -241,6 +241,8 @@ static vhdl_expr *lpm_to_expr(vhdl_scope *scope, ivl_lpm_t lpm) return concat_lpm_to_expr(scope, lpm); case IVL_LPM_CMP_GE: return rel_lpm_to_expr(scope, lpm, VHDL_BINOP_GEQ); + case IVL_LPM_CMP_GT: + return rel_lpm_to_expr(scope, lpm, VHDL_BINOP_GT); case IVL_LPM_CMP_EQ: case IVL_LPM_CMP_EEQ: return rel_lpm_to_expr(scope, lpm, VHDL_BINOP_EQ); From 4cb209097893bb7f159ed350d2e0aecf74252cb0 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Tue, 2 Sep 2008 20:22:50 +0100 Subject: [PATCH 3/3] Fix vhdl_expr::cast when expression has no assigned type This avoids a couple of segfaults --- tgt-vhdl/cast.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tgt-vhdl/cast.cc b/tgt-vhdl/cast.cc index 2499e0c6f..d56b6de09 100644 --- a/tgt-vhdl/cast.cc +++ b/tgt-vhdl/cast.cc @@ -32,6 +32,11 @@ vhdl_expr *vhdl_expr::cast(const vhdl_type *to) // << " (" << type_->get_width() << ") " // << " to=" << to->get_string() << " (" // << to->get_width() << ")" << std::endl; + + // If this expression hasn't been given a type then + // we can't generate any type conversion code + if (NULL == type_) + return this; if (to->get_name() == type_->get_name()) { if (to->get_width() == type_->get_width())