SystemVerilog 中的 Variable slice of vector and array
2011-11-07 15:46
417 查看
/////////////////////////////////////////////////////////////////////////////
/*- unpack2pack(): Convert unpack array to packed.*/
/////////////////////////////////////////////////////////////////////////////
function bit128 unpack2pack(bit8_16 dataBlock);
for (int i = 0; i < 16; i++) unpack2pack[8*i+:8] = dataBlock[i];
endfunction
/////////////////////////////////////////////////////////////////////////////
/*- pack2unpack(): Convert packed array to unpacked.*/
/////////////////////////////////////////////////////////////////////////////
function bit8_16 pack2unpack(bit128 dataBlock);
for (int i = 0; i < 16; i++) pack2unpack[i] = dataBlock[8*i+:8];
endfunction
在SystemVerilog中,如何存取bitvector或者array的slice呢? 我们知道即使systemverilog也不允许以bitvector[x:y] (其中x和y是变量)的方式存取slice,但是如果长度固定,则可以利用如下形式存取
bvpart = bv[startindex+:len] 效果上等同于 bvpart = bv[starindex+len-1:startindex] , 但是后者编译器是不支持的。
bvpart = bv[endindex-:len] 效果上等同于 bvpart = bv[endindex:endindex]
/*- unpack2pack(): Convert unpack array to packed.*/
/////////////////////////////////////////////////////////////////////////////
function bit128 unpack2pack(bit8_16 dataBlock);
for (int i = 0; i < 16; i++) unpack2pack[8*i+:8] = dataBlock[i];
endfunction
/////////////////////////////////////////////////////////////////////////////
/*- pack2unpack(): Convert packed array to unpacked.*/
/////////////////////////////////////////////////////////////////////////////
function bit8_16 pack2unpack(bit128 dataBlock);
for (int i = 0; i < 16; i++) pack2unpack[i] = dataBlock[8*i+:8];
endfunction
在SystemVerilog中,如何存取bitvector或者array的slice呢? 我们知道即使systemverilog也不允许以bitvector[x:y] (其中x和y是变量)的方式存取slice,但是如果长度固定,则可以利用如下形式存取
bvpart = bv[startindex+:len] 效果上等同于 bvpart = bv[starindex+len-1:startindex] , 但是后者编译器是不支持的。
bvpart = bv[endindex-:len] 效果上等同于 bvpart = bv[endindex:endindex]
相关文章推荐
- What's the difference of name scope and a variable scope in tensorflow?
- how to accepte the array of the checkbox in asp and in php
- Codeforces Round #249 (Div. 2)C Devu and Partitioning of the Array
- array summation and merging based on uniqueness of element at certain position + ruby arrays
- If you had an array of 1 million values and you had to remove duplicates
- Python Theano TypeError: Cannot convert Type TensorType(float64, vector) (of Variable Subtensor{int64:int64:}.0) into Type TensorType(float64, matrix)
- What's the difference of name scope and a variable scope in tensorflow?
- h264 u(v) decode of frame_num, pic_order_cnt_lsb and slice_group_change_cycle
- Codeforces Round #249 (Div. 2)C Devu and Partitioning of the Array
- vector array and normal stanard array
- array and vector
- Codeforces Round #251 (Div. 2) C. Devu and Partitioning of the Array
- CF 439C(251C题)Devu and Partitioning of the Array
- 【Henu ACM Round#20 D】 Devu and Partitioning of the Array
- the macro of watch variable value and its memory content
- pointer to ref of an array, and to the func that return a ref of an array
- Exchange the numbers of row and array of a two-dimensional array, and form a new two-dimensional ar
- Box2D: 错误variable length array of non-POD element type 'b2Vec2'
- Golang Slice interface and array concatenation