100% found this document useful (2 votes)
2K views

SV Constraint Scenario Questions

The document contains 20 questions about writing constraints in SystemVerilog to generate random values for variables and arrays. The questions cover a range of topics, including randomizing individual and groups of variables, applying multiple constraints to a single variable, generating unique values, ordered arrays, numeric patterns, prime numbers, and assigning probabilities to transactions.

Uploaded by

vivek narakala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
2K views

SV Constraint Scenario Questions

The document contains 20 questions about writing constraints in SystemVerilog to generate random values for variables and arrays. The questions cover a range of topics, including randomizing individual and groups of variables, applying multiple constraints to a single variable, generating unique values, ordered arrays, numeric patterns, prime numbers, and assigning probabilities to transactions.

Uploaded by

vivek narakala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CONSTRAINT Scenario Questions

1. Randomize the below variable such as


class randvar;
rand bit [7:0] var1, var2, var3, var4;
endclass

i) Randomize all variable.


ii) Randomize only var2.
iii) Randomize var1, var4.
iv) Randomize var1, var3, var4.
2. There are two constraints applied to same variable ‘A’. one will
generate the value within the range of [25:50] and another
expression say variable value should be greater than 40. What should
be the value generated, and what is the reason?
3. What is wrong with the below code? What is the correct process to
write the constraint?
Class const;
rand bit [7:0] low, mid, high;
constraint Const_1 {low <mid<high;}
end class

4. Write a single constraint to generate random values for bit [8:0]


variable in the below range, 1-34, 127, 129-156, 192-202,257-260.
5. Write a constraint without an inside function to generate random
values within the range of 34 to 43?
6. Write a constraint to generate a random value for a var1 [7:0] within
50 and var2 [7:0] with the non-repeated value in every
randomization?
7. Without using randomization method or rand keyword(modifiers),
generate an array of unique values.

1 - Augustin JK
8. Generate unique elements in an array without using the keyword
unique.

9. Write a constraint to generate 0, 1, x and z randomly.

10. Write a constraint to generate multiples of power 2.

11. Having 32-bit of variable, only single bit high values need to be
accessed. Write a constraint for that.

12. Write a constraint with array size 5 to 10 values & the array values
should be in ascending order/descending order.

13. Write a constraint to generate a pattern 0102030405.

14. Constraint to Generate Pattern 0, 2, 1, 3, 4, 6, 5, 7, 8.

15. Constraint to generate unique numbers between 99 to 100.

16. Write a constraint - divisible by 5.


17. Derive odd numbers within the range of 10 to 30 using SV
constraint.
18. Write a constraint to generate prime numbers between the range
of 1 to 100.
19. What is circular dependency and how to avoid this problem?

20. Write a constraint in such a way that for read transaction 30% time
and for write transaction 70% time.

2 - Augustin JK

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy