mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-04 05:19:11 +00:00 
			
		
		
		
	mem2reg: tolerate out of bounds constant accesses
This brings the mem2reg behavior in line with the nomem2reg behavior.
This commit is contained in:
		
							parent
							
								
									d9f11bb7a6
								
							
						
					
					
						commit
						c79fbfe0a1
					
				
					 4 changed files with 94 additions and 5 deletions
				
			
		
							
								
								
									
										27
									
								
								tests/verilog/mem_bounds.sv
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								tests/verilog/mem_bounds.sv
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,27 @@
 | 
			
		|||
module top;
 | 
			
		||||
    reg [0:7] mem [0:2];
 | 
			
		||||
 | 
			
		||||
    initial mem[1] = '1;
 | 
			
		||||
    wire [31:0] a, b, c, d;
 | 
			
		||||
    assign a = mem[1];
 | 
			
		||||
    assign b = mem[-1];
 | 
			
		||||
    assign c = mem[-1][0];
 | 
			
		||||
    assign d = mem[-1][0:1];
 | 
			
		||||
 | 
			
		||||
    always @* begin
 | 
			
		||||
 | 
			
		||||
    	assert ($countbits(a, '0) == 24);
 | 
			
		||||
    	assert ($countbits(a, '1) == 8);
 | 
			
		||||
    	assert ($countbits(a, 'x) == 0);
 | 
			
		||||
 | 
			
		||||
    	assert ($countbits(b, '0) == 24);
 | 
			
		||||
    	assert ($countbits(b, 'x) == 8);
 | 
			
		||||
 | 
			
		||||
    	assert ($countbits(c, '0) == 31);
 | 
			
		||||
    	assert ($countbits(c, 'x) == 1);
 | 
			
		||||
 | 
			
		||||
    	assert ($countbits(d, '0) == 30);
 | 
			
		||||
    	assert ($countbits(d, 'x) == 2);
 | 
			
		||||
 | 
			
		||||
    end
 | 
			
		||||
endmodule
 | 
			
		||||
							
								
								
									
										6
									
								
								tests/verilog/mem_bounds.ys
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								tests/verilog/mem_bounds.ys
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,6 @@
 | 
			
		|||
read_verilog -sv -mem2reg mem_bounds.sv
 | 
			
		||||
proc
 | 
			
		||||
flatten
 | 
			
		||||
opt -full
 | 
			
		||||
select -module top
 | 
			
		||||
sat -verify -seq 1 -tempinduct -prove-asserts -show-all -enable_undef
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue