15 Important SystemVerilog Interview Questions with Answers
1. What are the differences between `logic`, `reg`, and `wire` in SystemVerilog?
- `wire`: Used for connecting components; requires continuous driver.
- `reg`: Holds values in procedural blocks (deprecated in SystemVerilog).
- `logic`: Can be used in both procedural and continuous assignments.
2. What is the difference between a `struct` and a `union` in SystemVerilog?
- `struct`: All members exist and can hold values simultaneously.
- `union`: All members share the same memory; only one is valid at a time.
3. Explain the different types of procedural blocks in SystemVerilog.
- `initial`: Executes once at time 0.
- `always_comb`: For combinational logic.
- `always_ff`: For sequential logic.
- `always_latch`: For inferred latches.
4. What are `interfaces` in SystemVerilog and why are they useful?
Interfaces group related signals into one structure for clarity and reuse.
5. What are the advantages of using SystemVerilog over Verilog for verification?
- OOP support
- Constrained randomization
- Functional coverage
- Assertions
- Advanced data structures
6. What is a `modport` in an interface?
Defines access directions to interface signals.
7. How is `randomization` handled in SystemVerilog?
- `rand`: Generates random values
- `randc`: Generates cyclic unique values
8. What are constraints in SystemVerilog?
- Hard constraints: Always enforced
- Soft constraints: Overridable
9. How do you debug randomization failures in SystemVerilog?
- Use `$display`, `assert`, `constraint_mode()`, and `randomize() with {}`.
10. What is a `covergroup`?
Used for functional coverage. Tracks variable combinations.
11. What are `mailboxes` and `semaphores`?
- `mailbox`: Inter-thread communication
- `semaphore`: Resource sharing control
12. Explain `queues`, `dynamic arrays`, and `associative arrays`.
- Queue: Resizable with FIFO behavior
- Dynamic array: Resizable
- Associative array: Indexed with custom keys
13. What is the difference between `==` and `===`?
- `==`: Logical comparison
- `===`: Exact match including `x` and `z`
14. What are `virtual interfaces`?
Pointers to interfaces; useful for connecting classes to DUT interfaces.
15. Explain polymorphism and inheritance with an example.
- Inheritance: One class derives from another
- Polymorphism: Parent class handles child class behavior via overridden methods