赞
踩
SystemVerilog生成随机矩阵:
- // 1.first part: a systemvrilog program block. (this part can be omitted)
- class hello_str;
- string str = "Hello world";
- endclass
-
- class hello_martix;
- rand reg[(4+6):0] m[16][16];
-
- reg[10:0] col_sum[16];
-
- function void random_mat();
- assert(this.randomize() with{
- m[0].sum()<=128;
- m[1].sum()<=128;
- m[2].sum()<=128;
- m[3].sum()<=128;
- m[4].sum()<=128;
- m[5].sum()<=128;
- m[6].sum()<=128;
- m[7].sum()<=128;
- m[8].sum()<=128;
- m[9].sum()<=128;
- m[10].sum()<=128;
- m[11].sum()<=128;
- m[12].sum()<=128;
- m[13].sum()<=128;
- m[14].sum()<=128;
- m[15].sum()<=128;
-
- (m[0][ 0]+m[1][ 0]+m[2][ 0]+m[3][ 0]+m[4][ 0]+m[5][ 0]+m[6][ 0]+m[7][ 0]+m[8][ 0]+m[9][ 0]+m[10][ 0]+m[11][ 0]+m[12][ 0]+m[13][ 0]+m[14][ 0]+m[15][ 0])<=128;
- (m[0][ 1]+m[1][ 1]+m[2][ 1]+m[3][ 1]+m[4][ 1]+m[5][ 1]+m[6][ 1]+m[7][ 1]+m[8][ 1]+m[9][ 1]+m[10][ 1]+m[11][ 1]+m[12][ 1]+m[13][ 1]+m[14][ 1]+m[15][ 1])<=128;
- (m[0][ 2]+m[1][ 2]+m[2][ 2]+m[3][ 2]+m[4][ 2]+m[5][ 2]+m[6][ 2]
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。