mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-04 05:19:11 +00:00 
			
		
		
		
	verilog: Fix const eval of unbased unsized constants
When the verilog frontend perfomed constant evaluation of unbased unsized constants in a context-determined expression it did not properly extend them by repeating the bit value. This only affected constant evaluation and not constants that made it through unchanged to RTLIL. The latter case was already covered by tests and working before. This fixes the const-eval issue by checking the `is_unsized` flag in bitsAsConst and extending the value accordingly. The newly added test also tests the already working non-const-eval case to highlight that both cases should behave the same.
This commit is contained in:
		
							parent
							
								
									7efc50367e
								
							
						
					
					
						commit
						985f4926b7
					
				
					 3 changed files with 36 additions and 1 deletions
				
			
		
							
								
								
									
										28
									
								
								tests/verilog/unbased_unsized_shift.sv
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								tests/verilog/unbased_unsized_shift.sv
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,28 @@
 | 
			
		|||
module pass_through(
 | 
			
		||||
    input [63:0] inp,
 | 
			
		||||
    output [63:0] out
 | 
			
		||||
);
 | 
			
		||||
    assign out = inp;
 | 
			
		||||
endmodule
 | 
			
		||||
 | 
			
		||||
module top;
 | 
			
		||||
    logic [63:0] s0c, s1c, sxc, s0d, s1d, sxd, d;
 | 
			
		||||
 | 
			
		||||
    pass_through pt(8, d);
 | 
			
		||||
 | 
			
		||||
    assign s0c = '0 << 8;
 | 
			
		||||
    assign s1c = '1 << 8;
 | 
			
		||||
    assign sxc = 'x << 8;
 | 
			
		||||
    assign s0d = '0 << d;
 | 
			
		||||
    assign s1d = '1 << d;
 | 
			
		||||
    assign sxd = 'x << d;
 | 
			
		||||
 | 
			
		||||
    always @* begin
 | 
			
		||||
        assert (s0c === 64'h0000_0000_0000_0000);
 | 
			
		||||
        assert (s1c === 64'hFFFF_FFFF_FFFF_FF00);
 | 
			
		||||
        assert (sxc === 64'hxxxx_xxxx_xxxx_xx00);
 | 
			
		||||
        assert (s0d === 64'h0000_0000_0000_0000);
 | 
			
		||||
        assert (s1d === 64'hFFFF_FFFF_FFFF_FF00);
 | 
			
		||||
        assert (sxd === 64'hxxxx_xxxx_xxxx_xx00);
 | 
			
		||||
    end
 | 
			
		||||
endmodule
 | 
			
		||||
							
								
								
									
										7
									
								
								tests/verilog/unbased_unsized_shift.ys
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								tests/verilog/unbased_unsized_shift.ys
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,7 @@
 | 
			
		|||
read_verilog -sv unbased_unsized_shift.sv
 | 
			
		||||
hierarchy
 | 
			
		||||
proc
 | 
			
		||||
flatten
 | 
			
		||||
opt -full
 | 
			
		||||
select -module top
 | 
			
		||||
sat -verify -seq 1 -tempinduct -prove-asserts -show-all
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue