0% found this document useful (0 votes)
116 views2 pages

SV Randomization Example

This document defines a RandomConstraints class that specifies random variables and constraints for network packet generation. It defines enum and random bit variables for IP version, addresses, packet counts, and lengths. Constraints control the valid ranges and distributions for these variables, including implications based on channel number. A constraint order specifies that channel number is solved before addresses. Default minimum and maximum values are set for packet counts and lengths.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
116 views2 pages

SV Randomization Example

This document defines a RandomConstraints class that specifies random variables and constraints for network packet generation. It defines enum and random bit variables for IP version, addresses, packet counts, and lengths. Constraints control the valid ranges and distributions for these variables, including implications based on channel number. A constraint order specifies that channel number is solved before addresses. Default minimum and maximum values are set for packet counts and lengths.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

class RandomConstraints;

enum IpVersionType {IPV4=2, IPV6, IPVx}


//Randomly iterate over values without repetition
randc bit [7:0] cyclicCounter;
//Regular random variables
rand bit [15:0] destAddress;
rand bit [15:0] sourceAddress;
rand bit [15:0] numberOfPackets;
rand bit [15:0] packetLength;
rand bit [7:0] var1;
rand bit [7:0] var2;
IpVersionType ipVersion;
//Non-random variables that can be used to control constraints
bit [15:0] minNumberOfPackets, maxNumberOfPackets;
bit [15:0] minPacketLength, maxPacketLength;
integer IPV4Weight, IPV6Weight;
constraint cPacketLength {
packetLength in { minPacketLength : maxPacketLength }
}
constraint cChannelNumber {
channelNumber in {0:1}
}
constraint cIPVersionType {
ipVersion dist { IPV4 := IPV4Weight, IPV6 := IPV6Weight, IPVX := (100 IPV4Weight - IPV6Weight) }
}
//Probability of var1 being 1,2,3,4,5 in the ratio 1,2,4,4,4
constraint cDist1 {
var1 dist { 1 := 1, 2 := 2, [3:4] := 4 }
}
//Probability of var2 being 1,2,3,4,5 is in the ratio 1,2,4/3,4/3,4/3
constraint cDist2 {
var2 dist { 1 := 1, 2 := 2, [3:5] :/ 4 }
}
//Implication constraint - if(channelNum == i) then { ... }
constraint cImplication {
(channelNumber == 0) => {
destAddress in {0:200};
sourceAddress in {201:400};
}
(channelNumber == 1) => {
destAddress in {201:400};
sourceAddress in {0:200};
}
}
//Controlling order of constraints solved using a constraint solver
constraint order_solver {
solver channelNumber before destAddress;
solver channelNumber before sourceAddress;
}
function new();
//Setting default min/max packets and min/max packet length
minNumberOfPackets = 100;
maxNumberOfPackets = 1000;
minPacketLength = 128;
maxPacketLength = 256;

IPV4Weight = 50;
IPV6Weight = 30;
endfunction
endclass

You might also like