SV Randamization & Constraints
SV Randamization & Constraints
CONSTRAINTS: ADVANCED
QUESTIONS & INTERVIEW
GUIDE
Prasanthi Chanda
1. How can constrained randomization be used to verify an AXI
bus transaction generator?
To verify an AXI transaction generator, randomization ensures
diverse address, data, and burst sizes while maintaining
protocol compliance.
class AXI_Transaction;
rand bit [31:0] address;
rand bit [127:0] data;
rand int burst_size;
class EthernetFrame;
rand bit [11:0] frame_size;
class SDRAM_Access;
rand bit [2:0] bank;
rand bit [12:0] row;
rand bit [9:0] column;
// Example restriction
constraint avoid_conflicts { !(bank == 3 && row == 100); }
endclass
class UART_Transaction;
rand int baud_rate;
class MultiCoreTest;
rand bit [7:0] core0_instr, core1_instr;
Ensure only valid SPI mode settings (CPOL and CPHA) are
selected.
class SPI_Config;
rand bit cpol, cpha;
class PCIe_TLP;
rand bit [6:0] header_type;
rand bit [15:0] payload_length;
class I2C_Transaction;
rand bit start, stop;
class CacheTest;
rand bit [7:0] core_id;
rand bit [31:0] address;
class RISC_V_IFU;
rand bit [31:0] pc;
constraint align { pc % 4 == 0; }
endclass
class DRAM_Refresh;
rand int refresh_interval;
constraint timing { refresh_interval inside {[64:128]}; } // Within
valid refresh period
endclass
class EthernetFrame;
rand bit [11:0] frame_size;
constraint frame_distribution {
frame_size dist {64 := 50, [500:1000] := 30, 1518 := 20};
}
endclass
CONTACT DETAILS:
Email : elearn@provlogic.com
Website : https://provlogic.com/
Phone : +91 91822 80927
LinkedIn : @ProV Logic
Excellence in World class
VLSI Training & Placements
+91- 9182280927