2016-11-21 11 views
0

私はSystemVerilogの中で、ランダムな動的配列を作成する方法を知っている:SystemVerilogでランダムなダイナミック2D配列を作成するには?

class packet; 
    rand int unsigned len; 
    rand byte data[]; 

    constraint size_con { 
     len < 2000; 
     data.size = len; 
    } 
endclass: packet 

が、私は、ランダムな2D動的配列を使用する方法を見つけ出すことはできませんか?

class video_frame; 
    rand int unsigned width; 
    rand int unsigned height; 
    rand int unsigned data[][]; 

    constraint size_con { 
     width >= 8; 
     width <= 4096; 
     height >= 8; 
     height >= 2048; 
     // How to constraint data.size to be [height, width] 
    } 
endclass: video_frame; 

答えて

3

SystemVerilogには、多次元配列と同じではない配列があることを理解する必要があります。これは、各要素が別の動的配列である動的配列を持つことを意味します。したがって、各要素のサイズを制限する必要があります。

constraint size_con { 
     width inside {[8:4096]}; 
     height inside {[8:2048]}; 
     data.size == width; 
     foreach (data[ii]) data[ii].size == height; 
    } 
関連する問題