【发布时间】:2016-03-09 22:53:54
【问题描述】:
我正在使用 Xilinx,它使用 XST 来综合我的设计。我在写someReg[offest*index+:constant] <= someOtherReg; 之类的东西时遇到了麻烦。给出的错误是“信号中不支持变量索引。”我在网上搜索后收集到的是 XST 综合工具不支持索引左侧的信号。
我想知道的是如何在不使用该语法的情况下实现索引信号的逻辑。在下面的示例中,我正在创建一个重用“rowByColumn”乘数的矩阵乘数。
基本上在每个时钟上升沿,我都会将新值加载到“rowByColumn”乘法器的输入端,并在下一个时钟上升沿将结果保存在新寄存器中。将结果保存在新寄存器中是我遇到的主要问题。
这是给出错误的代码。您能否就解决或解决问题的方法提出建议。
module MatrixSeq(clk,A,B,C);
// param
parameter WIDTH = 32;
parameter ROW_A = 2;
parameter COL_A = 2;
parameter ROW_B = 2;
parameter COL_B = 2;
//ports
input clk;
input [WIDTH*COL_A*ROW_A-1:0] A;
input [WIDTH*COL_B*ROW_B-1:0] B;
output [WIDTH*ROW_A*COL_B-1:0] C;
// inputs to rowBycol
reg signed [WIDTH*COL_A-1:0] currentRowA;
reg signed [WIDTH*ROW_B-1:0] currentColB;
reg signed [WIDTH-1:0] rowByColOut;
wire signed [WIDTH-1:0] rowByColOutWire; // wire to connet to rowByColOut
// A,B matrix holders
reg signed [WIDTH*COL_A*ROW_A-1:0] AsigHolder;
reg signed [WIDTH*COL_B*ROW_B-1:0] BsigHolder;
reg signed [WIDTH*ROW_A*ROW_B-1:0] CsigHolder; // C = A*B
// reg signed [WIDTH-1:0] count;
integer idxA = 0; // iterates through the rows of A
integer idxB = 0; // iterates through the 'rows' of B
// Indexing Syntax:
// signalAdd[some_expression +: some_range];
// Resolves to
// signalAdd[some_expression + (some_range - 1) : some_expression];
always @(posedge clk) begin // assume we have the transpose of matrix B
currentRowA <= AsigHolder[WIDTH*COL_A*idxA+:WIDTH*COL_A];
currentColB <= BsigHolder[WIDTH*COL_B+idxB+:WIDTH*COL_B];
CsigHolder[WIDTH*(idxA*ROW_A+idxB)+:WIDTH] <= rowByColOut; // Error: 'Variable index is not supported in signal.'
idxB <= idxB +1;
if(idxB == ROW_B) begin // multiply each row of A with every 'row' B
idxA <= idxA + 1;
idxB <= 0;
end else if(idxA == ROW_A) begin
idxA <= 0;
idxB <= 0;
end
end
assign rowByColOutWire = rowByColOut;
rowBycol rowMultColumn (.CLK(clk), .a(currentRowA), .b(currentColB), .y(rowByColOutWire)); // row by column multiplier
assign C = CsigHolder;
endmodule
为了清楚起见,问题是 always 块内的第三行给出错误“信号中不支持变量索引。”
【问题讨论】:
标签: indexing verilog xilinx hdl xilinx-ise