mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 11:42:30 +00:00 
			
		
		
		
	Add $size() function. At the moment it works only on expressions, not on memories.
This commit is contained in:
		
							parent
							
								
									29f8acf095
								
							
						
					
					
						commit
						64eb8f29ad
					
				
					 2 changed files with 29 additions and 0 deletions
				
			
		|  | @ -1870,6 +1870,20 @@ skip_dynamic_range_lvalue_expansion:; | ||||||
| 				goto apply_newNode; | 				goto apply_newNode; | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
|  | 			if (str == "\\$size") | ||||||
|  | 			{ | ||||||
|  | 				if (children.size() != 1) | ||||||
|  | 					log_error("System function %s got %d arguments, expected 1 at %s:%d.\n", | ||||||
|  | 							RTLIL::unescape_id(str).c_str(), int(children.size()), filename.c_str(), linenum); | ||||||
|  | 
 | ||||||
|  | 				AstNode *buf = children[0]->clone(); | ||||||
|  | 				buf->detectSignWidth(width_hint, sign_hint); | ||||||
|  | 				delete buf; | ||||||
|  | 
 | ||||||
|  | 				newNode = mkconst_int(width_hint, false); | ||||||
|  | 				goto apply_newNode; | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
| 			if (str == "\\$ln" || str == "\\$log10" || str == "\\$exp" || str == "\\$sqrt" || str == "\\$pow" || | 			if (str == "\\$ln" || str == "\\$log10" || str == "\\$exp" || str == "\\$sqrt" || str == "\\$pow" || | ||||||
| 					str == "\\$floor" || str == "\\$ceil" || str == "\\$sin" || str == "\\$cos" || str == "\\$tan" || | 					str == "\\$floor" || str == "\\$ceil" || str == "\\$sin" || str == "\\$cos" || str == "\\$tan" || | ||||||
| 					str == "\\$asin" || str == "\\$acos" || str == "\\$atan" || str == "\\$atan2" || str == "\\$hypot" || | 					str == "\\$asin" || str == "\\$acos" || str == "\\$atan" || str == "\\$atan2" || str == "\\$hypot" || | ||||||
|  |  | ||||||
							
								
								
									
										15
									
								
								tests/simple/functions01.sv
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								tests/simple/functions01.sv
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,15 @@ | ||||||
|  | module functions01; | ||||||
|  | wire [3:0]x; | ||||||
|  | wire [$size(x)-1:0]x_size; | ||||||
|  | wire [$size({x, x})-1:0]xx_size; | ||||||
|  | wire [3:0]w[0:5]; | ||||||
|  | 
 | ||||||
|  | //
 | ||||||
|  | // The following are not supported yet:
 | ||||||
|  | //
 | ||||||
|  | 
 | ||||||
|  | //wire [$size(w)-1:0]w_s;
 | ||||||
|  | //wire [$bits(x)-1:0]x_bits;
 | ||||||
|  | //wire [$bits({x, x})-1:0]xx_bits;
 | ||||||
|  | 
 | ||||||
|  | endmodule | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue