I want to constrain my address in Packet class such that
- addr is non 0
- addr is word aligned
addr is 32 bit unpacked array of 32 bit vectors and it is declared in Packet class as
class Packet;
rand bit [31:0] dest_addr;
rand bit [31:0] source_addr;
rand bit [7:0] data_length;
rand byte data[];
rand byte fcs;
rand bit [31:0] addr [0:3];
string name;
rand bit [28:0] n;
rand bit [3:0] test;
static int count;
rand da_kind_t da_kind;
rand fcs_kind_t fcs_kind;
rand length_kind_t length_kind;
constraint c_n {
n != 0;
}
//Word alignment constraint
constraint c_addr {
foreach(addr[i])
addr[i] == 4*n;
}
However the constraint resolver fails. I have also tried these methods, which also fail.
constraint c_addr {
foreach(addr[i])
addr[i][31:2] != 0;
addr[i][1:0] == 0;
}
This method also fails
constraint c_addr {
addr[0] > 0;
addr[1] > 0;
addr[2] > 0;
addr[3] > 0;
}
constraint c_addr1 {
foreach(addr[i])
addr[i][1:0] == 0;
}
The Packet is for a 1x4 router verification and the requirement is that address of the destination port has to be word aligned, at the same a non 0 value. Any help is appreciated. Also, please note that the addr is to be randomized just once, i.e just one set of 4 unique non 0 word aligned addressses and if I just provide word aligned constraint, I get always one addr in the array which is 0x00000000.
Aucun commentaire:
Enregistrer un commentaire