diff --git a/ivtest/ivltests/br_gh1237.v b/ivtest/ivltests/br_gh1237.v new file mode 100644 index 000000000..52889e1cc --- /dev/null +++ b/ivtest/ivltests/br_gh1237.v @@ -0,0 +1,30 @@ +// The ternary operator should cause the 'in' variable to be unsigned extended. +module test; + reg passed; + reg [7:0] res; + reg signed in; + + initial begin + passed = 1'b1; + in = 1; + $display("in4: %0d", in); + + res = 0 ? 1'h0 : in; + $display("T0 = %d, %d", 0 ? 1'h0 : in, res); // These work + case (0 ? 1'h0 : in) // But this fails + 5'b0101: begin $display("FAILED: T0 matched 5'b0101"); passed = 1'b0;end + 8'b000001: begin $display("T0 matched 8'b000001"); end + default: begin $display("FAILED: T0 matched default"); passed = 1'b0;end + endcase + + res = 1 ? in : 1'h0; + $display("T1 = %d, %d", 1 ? in : 1'h0, res); // These work + case (1 ? in : 1'h0) // But this fails + 5'b0101: begin $display("FAILED: T1 matched 5'b0101"); passed = 1'b0;end + 8'b000001: begin $display("T1 matched 8'b000001"); end + default: begin $display("FAILED: T1 matched default"); passed = 1'b0;end + endcase + + if (passed) $display("PASSED"); + end +endmodule diff --git a/ivtest/regress-vlg.list b/ivtest/regress-vlg.list index 54d54ed92..5a9c6aa33 100644 --- a/ivtest/regress-vlg.list +++ b/ivtest/regress-vlg.list @@ -370,6 +370,7 @@ br_gh1223c normal,-g2009 ivltests br_gh1225a CE ivltests gold=br_gh1225a.gold br_gh1225b CE ivltests gold=br_gh1225b.gold br_gh1225c CE ivltests gold=br_gh1225c.gold +br_gh1237 normal ivltests br_ml20150315 normal ivltests gold=br_ml_20150315.gold br_ml20150321 CE ivltests br_mw20171108 normal ivltests diff --git a/ivtest/regress-vlog95.list b/ivtest/regress-vlog95.list index b8289cbfc..05a8b8388 100644 --- a/ivtest/regress-vlog95.list +++ b/ivtest/regress-vlog95.list @@ -862,6 +862,7 @@ br_gh793 normal,-pallowsigned=1 ivltests br_gh1223a normal,-g2009,-pallowsigned=1 ivltests br_gh1223b normal,-g2009,-pallowsigned=1 ivltests br_gh1223c normal,-g2009,-pallowsigned=1 ivltests +br_gh1237 normal,-pallowsigned=1 ivltests ca_mult normal,-pallowsigned=1 ivltests gold=ca_mult.gold cast_int normal,-pallowsigned=1 ivltests cfunc_assign_op_vec normal,-g2009,-pallowsigned=1 ivltests diff --git a/net_proc.cc b/net_proc.cc index ad2644b40..fe4ab5a8f 100644 --- a/net_proc.cc +++ b/net_proc.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2021 Stephen Williams (steve@icarus.com) + * Copyright (c) 2000-2025 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -154,7 +154,8 @@ void NetCase::prune() } // Prune the case expression - expr_ = pad_to_width(unpadded_expr->dup_expr(), prune_width, *expr_); + expr_ = pad_to_width(unpadded_expr->dup_expr(), prune_width, + padded_expr->has_sign(), *expr_); delete padded_expr; // Prune the case item expressions