mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 03:32:29 +00:00 
			
		
		
		
	Merge pull request #2122 from PeterCrozier/struct_array2
Support 2D bit arrays in structures. Optimise array indexing.
This commit is contained in:
		
						commit
						87b9ee330d
					
				
					 2 changed files with 84 additions and 30 deletions
				
			
		|  | @ -1,7 +1,7 @@ | |||
| // test for array indexing in structures
 | ||||
| 
 | ||||
| module top; | ||||
| 	 | ||||
| 
 | ||||
| 	struct packed { | ||||
| 		bit [5:0] [7:0] a;	// 6 element packed array of bytes
 | ||||
| 		bit [15:0] b;		// filler for non-zero offset
 | ||||
|  | @ -19,4 +19,24 @@ module top; | |||
| 
 | ||||
| 	always_comb assert(s==64'h4200_0012_3400_FFFC); | ||||
| 
 | ||||
| 	struct packed { | ||||
| 		bit [7:0] [7:0] a;	// 8 element packed array of bytes
 | ||||
| 		bit [15:0] b;		// filler for non-zero offset
 | ||||
| 	} s2; | ||||
| 
 | ||||
| 	initial begin | ||||
| 		s2 = '0; | ||||
| 
 | ||||
| 		s2.a[2:1] = 16'h1234; | ||||
| 		s2.a[5] = 8'h42; | ||||
| 
 | ||||
| 		s2.a[7] = '1; | ||||
| 		s2.a[7][1:0] = '0; | ||||
| 
 | ||||
| 		s2.b = '1; | ||||
| 		s2.b[1:0] = '0; | ||||
| 	end | ||||
| 
 | ||||
| 	always_comb assert(s2==80'hFC00_4200_0012_3400_FFFC); | ||||
| 
 | ||||
| endmodule | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue