Tests: Verilog format

This commit is contained in:
Veripool API Bot 2026-03-07 08:00:45 -05:00 committed by Wilson Snyder
parent b38c4bd7d6
commit cf965464a2
4 changed files with 287 additions and 297 deletions

View File

@ -4,8 +4,10 @@
// SPDX-FileCopyrightText: 2024 Wilson Snyder
// SPDX-License-Identifier: CC0-1.0
// verilog_format: off
`define stop $stop
`define checkd(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0);
// verilog_format: on
// Test that item.index in array reduction constraints is supported
// Test 1: Basic item.index usage with sum
@ -13,9 +15,9 @@ class Test1_BasicIndex;
rand bit [3:0] data[5];
constraint c {
// Sum of indices: 0+1+2+3+4 = 10
// Cast to match result type (32-bit)
data.sum() with (item.index) <= 10;
// Sum of indices: 0+1+2+3+4 = 10
// Cast to match result type (32-bit)
data.sum() with (item.index) <= 10;
}
endclass
@ -24,8 +26,8 @@ class Test2_IndexPlusItem;
rand bit [3:0] data[5];
constraint c {
// Cast both to same width for expression
data.sum() with (int'(item) + item.index) <= 50;
// Cast both to same width for expression
data.sum() with (int'(item) + item.index) <= 50;
}
endclass
@ -34,8 +36,8 @@ class Test3_ConditionalOnIndex;
rand bit [3:0] data[5];
constraint c {
// Only sum items at even indices
data.sum() with ((item.index % 2 == 0) ? int'(item) : 0) <= 20;
// Only sum items at even indices
data.sum() with ((item.index % 2 == 0) ? int'(item) : 0) <= 20;
}
endclass
@ -44,8 +46,8 @@ class Test4_ProductWithIndex;
rand bit [2:0] data[4];
constraint c {
// Product of (item + index + 1) to avoid zero
data.product() with (int'(item) + item.index + 1) <= 1000;
// Product of (item + index + 1) to avoid zero
data.product() with (int'(item) + item.index + 1) <= 1000;
}
endclass
@ -54,8 +56,8 @@ class Test5_XorWithIndex;
rand int data[4];
constraint c {
// Use int array so no casting needed
data.xor() with (item ^ item.index) >= 0;
// Use int array so no casting needed
data.xor() with (item ^ item.index) >= 0;
}
endclass
@ -63,18 +65,14 @@ endclass
class Test6_AndWithIndex;
rand int data[4];
constraint c {
data.and() with (item | item.index) != 0;
}
constraint c {data.and() with (item | item.index) != 0;}
endclass
// Test 7: item.index with or (using 32-bit result)
class Test7_OrWithIndex;
rand int data[4];
constraint c {
data.or() with (item & item.index) >= 0;
}
constraint c {data.or() with (item & item.index) >= 0;}
endclass
// Test 8: Complex expression with multiple uses
@ -82,8 +80,8 @@ class Test8_ComplexExpression;
rand bit [3:0] data[6];
constraint c {
// Use item.index multiple times in expression
data.sum() with (int'(item) * item.index + item.index) <= 100;
// Use item.index multiple times in expression
data.sum() with (int'(item) * item.index + item.index) <= 100;
}
endclass
@ -92,8 +90,8 @@ class Test9_JustIndex;
rand bit [3:0] data[5];
constraint c {
// This tests sum of just indices
data.sum() with (item.index * 2) == 20; // 0+2+4+6+8 = 20
// This tests sum of just indices
data.sum() with (item.index * 2) == 20; // 0+2+4+6+8 = 20
}
endclass
@ -105,13 +103,11 @@ class Test10_DynamicArray;
dyn_data = new[5];
endfunction
constraint c_size {
dyn_data.size() == 5;
}
constraint c_size {dyn_data.size() == 5;}
constraint c {
// item.index with dynamic array
dyn_data.sum() with (item.index) <= 10;
// item.index with dynamic array
dyn_data.sum() with (item.index) <= 10;
}
endclass
@ -120,8 +116,8 @@ class Test11_LargerArray;
rand bit [3:0] data[16];
constraint c {
// Sum of indices: 0+1+2+...+15 = 120
data.sum() with (item.index) <= 120;
// Sum of indices: 0+1+2+...+15 = 120
data.sum() with (item.index) <= 120;
}
endclass
@ -130,9 +126,9 @@ class Test12_LargeComplex;
rand int data[20];
constraint c {
// Complex expression with larger array
data.sum() with ((item.index < 10) ? item : item * 2) <= 5000;
foreach (data[i]) data[i] inside {[1:100]};
// Complex expression with larger array
data.sum() with ((item.index < 10) ? item : item * 2) <= 5000;
foreach (data[i]) data[i] inside {[1 : 100]};
}
endclass
@ -141,94 +137,94 @@ class Test13_VeryLargeArray;
rand int data[50];
constraint c {
// Test scalability - sum of first 50 indices = 1225
data.sum() with (item.index) == 1225;
// Test scalability - sum of first 50 indices = 1225
data.sum() with (item.index) == 1225;
}
endclass
module t;
initial begin
Test1_BasicIndex t1;
Test2_IndexPlusItem t2;
Test3_ConditionalOnIndex t3;
Test4_ProductWithIndex t4;
Test5_XorWithIndex t5;
Test6_AndWithIndex t6;
Test7_OrWithIndex t7;
Test8_ComplexExpression t8;
Test9_JustIndex t9;
Test10_DynamicArray t10;
Test11_LargerArray t11;
Test12_LargeComplex t12;
Test13_VeryLargeArray t13;
int i;
Test1_BasicIndex t1;
Test2_IndexPlusItem t2;
Test3_ConditionalOnIndex t3;
Test4_ProductWithIndex t4;
Test5_XorWithIndex t5;
Test6_AndWithIndex t6;
Test7_OrWithIndex t7;
Test8_ComplexExpression t8;
Test9_JustIndex t9;
Test10_DynamicArray t10;
Test11_LargerArray t11;
Test12_LargeComplex t12;
Test13_VeryLargeArray t13;
int i;
// Test 1: Basic index
t1 = new;
i = t1.randomize();
`checkd(i, 1)
// Test 1: Basic index
t1 = new;
i = t1.randomize();
`checkd(i, 1)
// Test 2: Index plus item
t2 = new;
i = t2.randomize();
`checkd(i, 1)
// Test 2: Index plus item
t2 = new;
i = t2.randomize();
`checkd(i, 1)
// Test 3: Conditional on index
t3 = new;
i = t3.randomize();
`checkd(i, 1)
// Test 3: Conditional on index
t3 = new;
i = t3.randomize();
`checkd(i, 1)
// Test 4: Product with index
t4 = new;
i = t4.randomize();
`checkd(i, 1)
// Test 4: Product with index
t4 = new;
i = t4.randomize();
`checkd(i, 1)
// Test 5: XOR with index
t5 = new;
i = t5.randomize();
`checkd(i, 1)
// Test 5: XOR with index
t5 = new;
i = t5.randomize();
`checkd(i, 1)
// Test 6: AND with index
t6 = new;
i = t6.randomize();
`checkd(i, 1)
// Test 6: AND with index
t6 = new;
i = t6.randomize();
`checkd(i, 1)
// Test 7: OR with index
t7 = new;
i = t7.randomize();
`checkd(i, 1)
// Test 7: OR with index
t7 = new;
i = t7.randomize();
`checkd(i, 1)
// Test 8: Complex expression
t8 = new;
i = t8.randomize();
`checkd(i, 1)
// Test 8: Complex expression
t8 = new;
i = t8.randomize();
`checkd(i, 1)
// Test 9: Just index
t9 = new;
i = t9.randomize();
`checkd(i, 1)
// Test 9: Just index
t9 = new;
i = t9.randomize();
`checkd(i, 1)
// Test 10: Dynamic array
t10 = new;
i = t10.randomize();
`checkd(i, 1)
// Test 10: Dynamic array
t10 = new;
i = t10.randomize();
`checkd(i, 1)
// Test 11: Larger array (16 elements)
t11 = new;
i = t11.randomize();
`checkd(i, 1)
// Test 11: Larger array (16 elements)
t11 = new;
i = t11.randomize();
`checkd(i, 1)
// Test 12: Large complex
t12 = new;
i = t12.randomize();
`checkd(i, 1)
// Test 12: Large complex
t12 = new;
i = t12.randomize();
`checkd(i, 1)
// Test 13: Very large array (50 elements)
t13 = new;
i = t13.randomize();
`checkd(i, 1)
// Test 13: Very large array (50 elements)
t13 = new;
i = t13.randomize();
`checkd(i, 1)
$write("*-* All Finished *-*\n");
$finish;
$write("*-* All Finished *-*\n");
$finish;
end
endmodule

View File

@ -4,8 +4,10 @@
// SPDX-FileCopyrightText: 2026 Wilson Snyder
// SPDX-License-Identifier: CC0-1.0
// verilog_format: off
`define stop $stop
`define checkd(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0);
// verilog_format: on
// Comprehensive test that item.index in array reduction constraints is supported
@ -14,8 +16,8 @@ class Test1_BasicSum;
rand int data[5];
constraint c {
// Use item.index in sum - indices 0,1,2,3,4 sum to 10
data.sum() with (item.index) <= 10;
// Use item.index in sum - indices 0,1,2,3,4 sum to 10
data.sum() with (item.index) <= 10;
}
endclass
@ -24,8 +26,8 @@ class Test2_IndexTimesTwo;
rand int data[5];
constraint c {
// Index * 2: 0,2,4,6,8 sum to 20
data.sum() with (item.index * 2) == 20;
// Index * 2: 0,2,4,6,8 sum to 20
data.sum() with (item.index * 2) == 20;
}
endclass
@ -34,8 +36,8 @@ class Test3_ItemPlusIndex;
rand int data[3];
constraint c {
// item + index for each element
data.sum() with (item + item.index) <= 50;
// item + index for each element
data.sum() with (item + item.index) <= 50;
}
endclass
@ -44,8 +46,8 @@ class Test4_Product;
rand int data[4];
constraint c {
// Product with index+1 to avoid zeros
data.product() with (item.index + 1) <= 24; // 1*2*3*4 = 24
// Product with index+1 to avoid zeros
data.product() with (item.index + 1) <= 24; // 1*2*3*4 = 24
}
endclass
@ -54,8 +56,8 @@ class Test5_Conditional;
rand int data[6];
constraint c {
// Only sum indices that are even
data.sum() with ((item.index % 2 == 0) ? item.index : 0) <= 6; // 0+2+4 = 6
// Only sum indices that are even
data.sum() with ((item.index % 2 == 0) ? item.index : 0) <= 6; // 0+2+4 = 6
}
endclass
@ -63,27 +65,21 @@ endclass
class Test6_Xor;
rand int data[4];
constraint c {
data.xor() with (item.index) >= 0;
}
constraint c {data.xor() with (item.index) >= 0;}
endclass
// Test 7: item.index with AND
class Test7_And;
rand int data[4];
constraint c {
data.and() with (item + item.index) != 0;
}
constraint c {data.and() with (item + item.index) != 0;}
endclass
// Test 8: item.index with OR
class Test8_Or;
rand int data[4];
constraint c {
data.or() with (item - item.index) >= -10;
}
constraint c {data.or() with (item - item.index) >= -10;}
endclass
// Test 9: Complex expression with item.index
@ -91,8 +87,8 @@ class Test9_Complex;
rand int data[4];
constraint c {
// Multiple uses of item.index
data.sum() with ((item.index * item.index) + item) <= 100;
// Multiple uses of item.index
data.sum() with ((item.index * item.index) + item) <= 100;
}
endclass
@ -104,12 +100,10 @@ class Test10_Dynamic;
data = new[4];
endfunction
constraint c_size {
data.size() == 4;
}
constraint c_size {data.size() == 4;}
constraint c {
data.sum() with (item.index) <= 6; // 0+1+2+3 = 6
data.sum() with (item.index) <= 6; // 0+1+2+3 = 6
}
endclass
@ -118,7 +112,7 @@ class Test11_LargerArray;
rand int data[10];
constraint c {
data.sum() with (item.index) == 45; // 0+1+2+...+9 = 45
data.sum() with (item.index) == 45; // 0+1+2+...+9 = 45
}
endclass
@ -127,7 +121,7 @@ class Test12_Negative;
rand int data[5];
constraint c {
data.sum() with (item.index - 2) <= 5; // -2,-1,0,1,2 = 0
data.sum() with (item.index - 2) <= 5; // -2,-1,0,1,2 = 0
}
endclass
@ -135,9 +129,7 @@ endclass
class Test13_JustItem;
rand int data[3];
constraint c {
data.sum() with (item) <= 30;
}
constraint c {data.sum() with (item) <= 30;}
endclass
// Test 14: item.index only (no item reference)
@ -145,7 +137,7 @@ class Test14_IndexOnly;
rand int data[5];
constraint c {
data.sum() with (item.index + 10) <= 60; // 10,11,12,13,14 = 60
data.sum() with (item.index + 10) <= 60; // 10,11,12,13,14 = 60
}
endclass
@ -154,9 +146,9 @@ class Test15_PositionWeight;
rand int data[6];
constraint c {
// Later elements weighted more heavily: item * index
data.sum() with (item * item.index) <= 200;
foreach (data[i]) data[i] inside {[1:10]};
// Later elements weighted more heavily: item * index
data.sum() with (item * item.index) <= 200;
foreach (data[i]) data[i] inside {[1 : 10]};
}
endclass
@ -165,10 +157,10 @@ class Test16_AlternatingPattern;
rand int data[8];
constraint c {
// Alternating positive/negative based on even/odd index
data.sum() with ((item.index % 2 != 0) ? item : -item) >= -20;
data.sum() with ((item.index % 2 != 0) ? item : -item) <= 20;
foreach (data[i]) data[i] inside {[1:10]};
// Alternating positive/negative based on even/odd index
data.sum() with ((item.index % 2 != 0) ? item : -item) >= -20;
data.sum() with ((item.index % 2 != 0) ? item : -item) <= 20;
foreach (data[i]) data[i] inside {[1 : 10]};
}
endclass
@ -177,9 +169,9 @@ class Test17_IndexBounds;
rand int data[5];
constraint c {
// Each element should be within [0, index*2]
data.sum() with ((item >= 0 && item <= item.index*2) ? item : 0) <= 40;
foreach (data[i]) data[i] inside {[0:i*2]};
// Each element should be within [0, index*2]
data.sum() with ((item >= 0 && item <= item.index * 2) ? item : 0) <= 40;
foreach (data[i]) data[i] inside {[0 : i * 2]};
}
endclass
@ -188,9 +180,9 @@ class Test18_Progressive;
rand int data[6];
constraint c {
// Count how many elements are greater than their index
data.sum() with ((item > item.index) ? 1 : 0) >= 3;
foreach (data[i]) data[i] inside {[0:10]};
// Count how many elements are greater than their index
data.sum() with ((item > item.index) ? 1 : 0) >= 3;
foreach (data[i]) data[i] inside {[0 : 10]};
}
endclass
@ -199,9 +191,9 @@ class Test19_DistanceFromMiddle;
rand int data[10];
constraint c {
// Weight by distance from middle index
data.sum() with (item * ((item.index < 5) ? item.index : (9 - item.index))) <= 500;
foreach (data[i]) data[i] inside {[1:10]};
// Weight by distance from middle index
data.sum() with (item * ((item.index < 5) ? item.index : (9 - item.index))) <= 500;
foreach (data[i]) data[i] inside {[1 : 10]};
}
endclass
@ -210,10 +202,9 @@ class Test20_HalfConstraint;
rand int data[8];
constraint c {
// First half sum should be less than second half sum
data.sum() with ((item.index < 4) ? item : 0) <=
data.sum() with ((item.index >= 4) ? item : 0);
foreach (data[i]) data[i] inside {[1:20]};
// First half sum should be less than second half sum
data.sum() with ((item.index < 4) ? item : 0) <= data.sum() with ((item.index >= 4) ? item : 0);
foreach (data[i]) data[i] inside {[1 : 20]};
}
endclass
@ -222,9 +213,9 @@ class Test21_ModuloPattern;
rand int data[12];
constraint c {
// Sum every third element (indices 0,3,6,9)
data.sum() with (((item.index % 3) == 0) ? item : 0) <= 40;
foreach (data[i]) data[i] inside {[1:15]};
// Sum every third element (indices 0,3,6,9)
data.sum() with (((item.index % 3) == 0) ? item : 0) <= 40;
foreach (data[i]) data[i] inside {[1 : 15]};
}
endclass
@ -233,9 +224,9 @@ class Test22_IndexPower;
rand int data[5];
constraint c {
// Use index squared as multiplier
data.sum() with (item * (item.index * item.index)) <= 1000;
foreach (data[i]) data[i] inside {[1:10]};
// Use index squared as multiplier
data.sum() with (item * (item.index * item.index)) <= 1000;
foreach (data[i]) data[i] inside {[1 : 10]};
}
endclass
@ -244,9 +235,9 @@ class Test23_BoundaryElements;
rand int data[10];
constraint c {
// First and last elements should dominate
data.sum() with ((item.index == 0 || item.index == 9) ? item*3 : item) <= 150;
foreach (data[i]) data[i] inside {[1:20]};
// First and last elements should dominate
data.sum() with ((item.index == 0 || item.index == 9) ? item * 3 : item) <= 150;
foreach (data[i]) data[i] inside {[1 : 20]};
}
endclass
@ -255,161 +246,161 @@ class Test24_CascadingConstraint;
rand int data[7];
constraint c {
// Each position contributes: item * (index + 1)
data.sum() with (item * (item.index + 1)) <= 300;
foreach (data[i]) data[i] inside {[1:10]};
// Each position contributes: item * (index + 1)
data.sum() with (item * (item.index + 1)) <= 300;
foreach (data[i]) data[i] inside {[1 : 10]};
}
endclass
module t;
initial begin
Test1_BasicSum t1;
Test2_IndexTimesTwo t2;
Test3_ItemPlusIndex t3;
Test4_Product t4;
Test5_Conditional t5;
Test6_Xor t6;
Test7_And t7;
Test8_Or t8;
Test9_Complex t9;
Test10_Dynamic t10;
Test11_LargerArray t11;
Test12_Negative t12;
Test13_JustItem t13;
Test14_IndexOnly t14;
Test15_PositionWeight t15;
Test16_AlternatingPattern t16;
Test17_IndexBounds t17;
Test18_Progressive t18;
Test19_DistanceFromMiddle t19;
Test20_HalfConstraint t20;
Test21_ModuloPattern t21;
Test22_IndexPower t22;
Test23_BoundaryElements t23;
Test24_CascadingConstraint t24;
int i;
Test1_BasicSum t1;
Test2_IndexTimesTwo t2;
Test3_ItemPlusIndex t3;
Test4_Product t4;
Test5_Conditional t5;
Test6_Xor t6;
Test7_And t7;
Test8_Or t8;
Test9_Complex t9;
Test10_Dynamic t10;
Test11_LargerArray t11;
Test12_Negative t12;
Test13_JustItem t13;
Test14_IndexOnly t14;
Test15_PositionWeight t15;
Test16_AlternatingPattern t16;
Test17_IndexBounds t17;
Test18_Progressive t18;
Test19_DistanceFromMiddle t19;
Test20_HalfConstraint t20;
Test21_ModuloPattern t21;
Test22_IndexPower t22;
Test23_BoundaryElements t23;
Test24_CascadingConstraint t24;
int i;
// Test 1: Basic sum
t1 = new;
i = t1.randomize();
`checkd(i, 1)
// Test 1: Basic sum
t1 = new;
i = t1.randomize();
`checkd(i, 1)
// Test 2: Index times two
t2 = new;
i = t2.randomize();
`checkd(i, 1)
// Test 2: Index times two
t2 = new;
i = t2.randomize();
`checkd(i, 1)
// Test 3: Item plus index
t3 = new;
i = t3.randomize();
`checkd(i, 1)
// Test 3: Item plus index
t3 = new;
i = t3.randomize();
`checkd(i, 1)
// Test 4: Product
t4 = new;
i = t4.randomize();
`checkd(i, 1)
// Test 4: Product
t4 = new;
i = t4.randomize();
`checkd(i, 1)
// Test 5: Conditional
t5 = new;
i = t5.randomize();
`checkd(i, 1)
// Test 5: Conditional
t5 = new;
i = t5.randomize();
`checkd(i, 1)
// Test 6: XOR
t6 = new;
i = t6.randomize();
`checkd(i, 1)
// Test 6: XOR
t6 = new;
i = t6.randomize();
`checkd(i, 1)
// Test 7: AND
t7 = new;
i = t7.randomize();
`checkd(i, 1)
// Test 7: AND
t7 = new;
i = t7.randomize();
`checkd(i, 1)
// Test 8: OR
t8 = new;
i = t8.randomize();
`checkd(i, 1)
// Test 8: OR
t8 = new;
i = t8.randomize();
`checkd(i, 1)
// Test 9: Complex
t9 = new;
i = t9.randomize();
`checkd(i, 1)
// Test 9: Complex
t9 = new;
i = t9.randomize();
`checkd(i, 1)
// Test 10: Dynamic array
t10 = new;
i = t10.randomize();
`checkd(i, 1)
// Test 10: Dynamic array
t10 = new;
i = t10.randomize();
`checkd(i, 1)
// Test 11: Larger array
t11 = new;
i = t11.randomize();
`checkd(i, 1)
// Test 11: Larger array
t11 = new;
i = t11.randomize();
`checkd(i, 1)
// Test 12: Negative
t12 = new;
i = t12.randomize();
`checkd(i, 1)
// Test 12: Negative
t12 = new;
i = t12.randomize();
`checkd(i, 1)
// Test 13: Just item
t13 = new;
i = t13.randomize();
`checkd(i, 1)
// Test 13: Just item
t13 = new;
i = t13.randomize();
`checkd(i, 1)
// Test 14: Index only
t14 = new;
i = t14.randomize();
`checkd(i, 1)
// Test 14: Index only
t14 = new;
i = t14.randomize();
`checkd(i, 1)
// Test 15: Position weight
t15 = new;
i = t15.randomize();
`checkd(i, 1)
// Test 15: Position weight
t15 = new;
i = t15.randomize();
`checkd(i, 1)
// Test 16: Alternating pattern
t16 = new;
i = t16.randomize();
`checkd(i, 1)
// Test 16: Alternating pattern
t16 = new;
i = t16.randomize();
`checkd(i, 1)
// Test 17: Index bounds
t17 = new;
i = t17.randomize();
`checkd(i, 1)
// Test 17: Index bounds
t17 = new;
i = t17.randomize();
`checkd(i, 1)
// Test 18: Progressive
t18 = new;
i = t18.randomize();
`checkd(i, 1)
// Test 18: Progressive
t18 = new;
i = t18.randomize();
`checkd(i, 1)
// Test 19: Distance from middle
t19 = new;
i = t19.randomize();
`checkd(i, 1)
// Test 19: Distance from middle
t19 = new;
i = t19.randomize();
`checkd(i, 1)
// Test 20: Half constraint
t20 = new;
i = t20.randomize();
`checkd(i, 1)
// Test 20: Half constraint
t20 = new;
i = t20.randomize();
`checkd(i, 1)
// Test 21: Modulo pattern
t21 = new;
i = t21.randomize();
`checkd(i, 1)
// Test 21: Modulo pattern
t21 = new;
i = t21.randomize();
`checkd(i, 1)
// Test 22: Index power
t22 = new;
i = t22.randomize();
`checkd(i, 1)
// Test 22: Index power
t22 = new;
i = t22.randomize();
`checkd(i, 1)
// Test 23: Boundary elements
t23 = new;
i = t23.randomize();
`checkd(i, 1)
// Test 23: Boundary elements
t23 = new;
i = t23.randomize();
`checkd(i, 1)
// Test 24: Cascading constraint
t24 = new;
i = t24.randomize();
`checkd(i, 1)
// Test 24: Cascading constraint
t24 = new;
i = t24.randomize();
`checkd(i, 1)
$write("*-* All Finished *-*\n");
$finish;
$write("*-* All Finished *-*\n");
$finish;
end
endmodule

View File

@ -26,14 +26,12 @@ module t;
rand reg_slave_TABLES TABLES[4];
virtual function void build();
foreach (TABLES[i])
TABLES[i] = new;
foreach (TABLES[i]) TABLES[i] = new;
this.configure(TABLES); // Issue was here
endfunction
function void configure(uvm_reg reg_a[]);
foreach (reg_a[i])
$display("%p", reg_a[i]);
foreach (reg_a[i]) $display("%p", reg_a[i]);
endfunction
endclass

View File

@ -12,7 +12,7 @@
// verilog_format: on
module t (
input clk
input clk
);
int cyc;
@ -41,17 +41,22 @@ module t (
cyc <= cyc + 1;
if (cyc == 0) begin
// Setup
end else if (cyc < 50) begin
end
else if (cyc < 50) begin
if (!driver1_en && !driver2_en) begin
`checkh(tribus, 1'bz);
end else if (driver1_en && !driver2_en) begin
end
else if (driver1_en && !driver2_en) begin
`checkh(tribus, driver1_dat);
end else if (!driver1_en && driver2_en) begin
end
else if (!driver1_en && driver2_en) begin
`checkh(tribus, driver2_dat);
end else begin
end
else begin
// Ignore conflict cases
end
end else if (cyc == 99) begin
end
else if (cyc == 99) begin
$write("*-* All Finished *-*\n");
$finish;
end