FPGA实现矩阵求逆模块中矩阵的初始化问题

2019-03-25 10:51发布

我现在要做一个4*4矩阵的运算,先要把矩阵输入到寄存器中(verilog没有二维的概念),然后对这些寄存器进行运算。我的想法是输入的时候一列一列输入,矩阵输入完全再进行计算。我问的是如何对矩阵进行初始化(RTL级)。
  input clk,
    input reset,
    input [5:0] A0,
    input [5:0] A1,
    input [5:0] A2,
    input [5:0] A3,
    input [5:0] A4,
    input [5:0] A5,
    input [5:0] A6,
    input [5:0] A7,
    in        就输出一列
         reg[5:0] temp1[0:3];
         reg[5:0] temp2[0:3];
         reg[5:0] temp3[0:3];
         reg[5:0] temp_in[0:15];//存放矩阵的值,16个6位的寄存器   &nb2,
    output [5:0] B3,
    output [5:0] B4,
    output [5:0] B5,
    output [5:0] B6,
    output [5:0] B7,
    output [5:0] B8,
    output [5:0] B9,
    output [5:0] B10,
    output [5:0] B11,
    output [5:0] B12,
    output [5:0] B13,
    output [5:0] B14,
    output [5:0] B15
    );        
         reg[5:0] temp0[0:3];//temp0~temp3相当于矩阵的第1列到第四列,CLK来一次
                                   就输出一列
         reg[5:0] temp1[0:3];
         reg[5:0] temp2[0:3];
         reg[5:0] temp3[0:3];
         reg[5:0] temp_in[0:15];//存放矩阵的值,16个6位的寄存器               
         reg[5:0] temp_out[0:15];//存放计算后的输出逆矩阵的值
        initial
         begin                             //这样给寄存器赋值是否有问题???
                  temp0[0]<=A0;
                  temp0[1]<=A1;
                  temp0[2]<=A2;
                  temp0[3]<=A3;
                  temp1[0]<=A4;
                  temp1[1]<=A5;
                  temp1[2]<=A6;
                  temp1[3]<=A7;
                  temp2[0]<=A8;
                  temp2[1]<=A9;
                  temp2[2]<=A10;
                  temp2[3]<=A11;
                  temp3[0]<=A12;
                  temp3[1]<=A13;
                  temp3[2]<=A14;
                  temp3[3]<=A15;                                    
      end        
                always @(posedge clk )
                    begin
                         for(i=0;i<4;i=i+1)         //这样是想把矩阵放在RAM里面,方便
                                                             下面计算
                         temp_in<=temp0;
                         temp_in[i+4]<=temp1;
                         temp_in[i+8]<=temp2;
                         temp_in[i+12]<=temp3;
               end
   (1)initial 好像不能综合,那么我那个赋值语句该怎么写?
  (2)我这样对输入的操作好像有问题??? 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
4条回答
wenhuawu
1楼-- · 2019-03-25 15:16
< / 应该可以通过一个初始化标志来先对变量初使化,再运算
tx_xy
2楼-- · 2019-03-25 19:46
 精彩回答 2  元偷偷看……
wang182004
3楼-- · 2019-03-26 00:01
好的,谢谢各位,我先去试试,大家有没做个MIMO检测实现方面的项目啊,大家交流一下哈。。。
eecsseudl
4楼-- · 2019-03-26 02:00
胡扯,你这个的初始化时错误的,应在复位时初始化
eg:
always @(posedge clk or negedge rst) // 异步复位
begin
if(!rst) begin
。。。//         在这里面对其进行初始化
end
else begin
。。。//    在这里执行运算操作
end
end

一周热门 更多>