• Techo

[IC驗證] Memory block randomization constraint

更新日期: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


9 次瀏覽
Logo2020.JPG
  • Instagram - White Circle
  • Google+ - White Circle
  • Facebook - White Circle

Contact Us

Techo私人程式家教

官方LINE ID : @tutortecho

zh-Hant.png

© Copyright 2018 by Sherry Wu and Techo Chao.

Proudly created with Wix.com,

but page loading is too slow,so I don't recommend it.