• Techo

[IC驗證] Memory block randomization constraint

更新日期:2020年9月14日

1. Try to allocate the 4KB SRAM into 5 partitions with each partition having equal size

Ans:

class Allocate_mem;


rand bit[12:0] start_addr[5];

rand int unsigned size;

constraint c_size {

size <= 4096 / 5;

size inside {64, 128, 512 };

}

constraint c_no_overlap {

foreach( start_addr[i] )

if( i < 5 )

( unsigned'(start_addr[i]) + size ) < start_addr [i+1];

else

( unsigned'(start_addr[i]) + size ) < 4096;

}

endclass


2. Try to partition the 4KB SRAM into 5~10 partitions with each partition having equal size

Ans:

class Allocate_mem;


rand bit[12:0] start_addr[];

rand int unsigned number;

rand int unsigned size;

constraint c_num { number >= 5; number <=10; }

constraint c_num_part { start_addr.size() == number; }

constraint c_size {

size <= 4096 / number;

size inside {64, 128, 512 };

}

constraint c_no_overlap {

foreach( start_addr[i] )

if( i != (number-1) )

( unsigned'(start_addr[i]) + size) < start_addr[i+1];

else

( unsigned'(start_addr[i]) +size ) < 4096;

}

endclass


3. Try to partition the 4KB SRAM into 5~10 partitions with each partition having random size

Ans:

class Allocate_mem;

rand bit[12:0] start_addr[];

rand int unsigned number;

rand int unsigned size[];

constraint c_num {

number >= 5; number <=10;

}

constraint c_num_part {

start_addr.size() == number;

size.size() == number;

}

constraint c_sum {

size.sum() <= 4096;

}

constraint c_blk_size {

foreach(size[i]) {

size[i] inside {64, 128, 512 };

}

}

constraint c_no_overlap {

foreach( start_addr[i] )

if( i != (number-1) )

unsigned'(start_addr[i]) + size[i] < start_addr[i+1];

else

unsigned'(start_addr[i]) + size[i] < 4096;

}


endclass


68 次瀏覽0 則留言
Logo2020.JPG