SYSTEMVERILOG CONSTRAINT PATTERNS
1.Write a constraint to generate the pattern 1234554321.
• i < 5: assigns increasing values.
• 10 - i: mirrors the first half to create the decreasing sequence.
• foreach simplifies the loop-based assignment inside the constraint.
www.linkedin.com/in/jhansi-bendi-2061b5206 [email protected]
2.Write a constraint to generate the pattern 123123123123.
• i % 3 gives values 0, 1, 2 → add 1 → gives 1, 2, 3 in a loop.
• So the pattern becomes:
arr[0] = 1, arr[1] = 2, arr[2] = 3, arr[3] = 1, ..., arr[11] = 3
www.linkedin.com/in/jhansi-bendi-2061b5206 [email protected]
3.Write a constraint to generate the pattern 100100100100.
• Every 3rd index (i.e., i % 3 == 0) is 1
• Others are 0
• Pattern:
arr[0] = 1, arr[1] = 0, arr[2] = 0, arr[3] = 1, arr[4] = 0, arr[5] = 0, etc.
www.linkedin.com/in/jhansi-bendi-2061b5206 [email protected]
4.Generate an array of 10 elements where even indices are
0, and odd indices are random values between 1 and 9.
• Even indices = 0
• Odd indices = Random values between 1 and 9
• i % 2 == 0 → Even index → set to 0
• i % 2 == 1 → Odd index → constrained to 1–9
www.linkedin.com/in/jhansi-bendi-2061b5206 [email protected]
5.Generate a palindrome of even length 8 where values are
random between 1 to 5.
• Values range: 1 to 5
• Palindrome: arr[i] == arr[7 - i]
• arr[i] inside {[1:5]} ensures all values are between 1 and 5.
• arr[i] == arr[7 - i] mirrors each index, forming a palindrome.
• Since it's length 8 (even), every pair from front and back must match.
www.linkedin.com/in/jhansi-bendi-2061b5206 [email protected]