Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 如何在Verilog中使用二维数组_Arrays_Multidimensional Array_Verilog_System Verilog - Fatal编程技术网

Arrays 如何在Verilog中使用二维数组

Arrays 如何在Verilog中使用二维数组,arrays,multidimensional-array,verilog,system-verilog,Arrays,Multidimensional Array,Verilog,System Verilog,我想用verilog语法将数据保存在二维数组中。我写的代码。请任何人都可以检查代码,可以给我更多的关于如何使用二维数组的好主意 reg [9:0] simple_State [0:10][0:10] reg [9:0] count, reg [9:0] index_R; // row reg [9:0] index_C; // initial begin index_C=0; index_R=0 ; end always @ (posedge clock) simple_S

我想用verilog语法将数据保存在二维数组中。我写的代码。请任何人都可以检查代码,可以给我更多的关于如何使用二维数组的好主意

  reg [9:0] simple_State [0:10][0:10]

reg [9:0] count,
reg [9:0] index_R; // row
reg [9:0] index_C; //
initial  
begin 
 index_C=0;
 index_R=0 ;
end 

always @ (posedge clock)

simple_State[index_R][index_C]  <= count ;
count    <= count+1   ;
 index_C  <= index_C+1 ;  
if (count== 10 * index_C) 
  index_R<= index_R+1 ;
end
reg[9:0]简单状态[0:10][0:10]
注册[9:0]计数,
reg[9:0]索引\u R;//一行
reg[9:0]索引//
最初的
开始
指数C=0;
指数R=0;
终止
始终@(posedge时钟)

简单状态[index_R][index_C]您的代码会导致
index_C
index_R
溢出,并且需要一个乘法运算,如果要合成此描述,则乘法运算可能会很昂贵。
simple_State
有11行11列,所以行索引和列索引的4位就足够了。就像在其他语言中一样:递增列,当它达到最大列值时,重置为0并递增行值。当达到最大值时,将其重置为0

reg [9:0] simple_State [0:10][0:10]
reg [9:0] count,
reg [3:0] index_R; // row
reg [3:0] index_C; // column
initial begin 
  index_C = 0;
  index_R = 0 ;
end 

always @ (posedge clock) begin
  simple_State[index_R][index_C]  <= count ;
  count <= count + 1;
  if (index_C == 10) begin
    index_C <= 0;
    if (index_R == 10)
      index_R <= 0;
    else
      index_R <= index_R + 1;
  end
  else
    index_C <= index_C + 1 ;
end
reg[9:0]简单状态[0:10][0:10]
注册[9:0]计数,
reg[3:0]索引\u R;//一行
reg[3:0]索引\u C;//柱
初始开始
指数C=0;
指数R=0;
终止
始终@(posedge时钟)开始

简单状态[index\u R][index\u C]如果使用顺序逻辑,请尽量避免初始块

reg [9:0] simple_State [0:10][0:10]
reg [9:0] count,
reg [3:0] index_R; // row
reg [3:0] index_C; //
 always @ (posedge clock or negedge rst) begin
   if(!rst) begin
     index_C=0;
     index_R=0 ;
   end
 end
 else
  begin
   simple_State[index_R][index_C]  <= count ;
   count    <= count+1   ;
   index_C  <= index_C+1 ;  
   if (count== 10 * index_C) 
    index_R<= index_R+1 ;
   end
 end
reg[9:0]简单状态[0:10][0:10]
注册[9:0]计数,
reg[3:0]索引\u R;//一行
reg[3:0]索引//
始终@(posedge时钟或negedge rst)开始
如果(!rst)开始
指数C=0;
指数R=0;
终止
终止
其他的
开始
简单状态[index\u R][index\u C]