compiler-errors - verilog中的并发分配错误
问题描述
我的代码如下:
module trapverilog(
input CLK,
input SIGNALP,
input SIGNAL1,
input SIGNAL2,
input SIGNAL3,
input SIGNAL4,
input SIGNAL5,
input SIGNAL6,
input SIGNAL7,
input X1,
input X2,
input X3,
input X4,
input X5,
input X6,
input X7,
input SUMP,
input SUM1,
input SUM2,
input SUM3,
input SUM4,
input SUM5,
input SUM6,
input SUM7, // OUT pins are mapped to SUM pins on board
output reg OUTP,
output reg OUT1,
output reg OUT2,
output reg OUT3,
output reg OUT4,
output reg OUT5,
output reg OUT6,
output reg OUT7
);
reg[6:0] yregone;
reg[6:0] yregtwo;
reg[6:0] sum;
reg[6:0] SUM;
assign SUM = {SUM1, SUM2, SUM3, SUM4, SUM5, SUM6, SUM7};
reg[7:0] SIGNAL;
assign SIGNAL = {SIGNAL1, SIGNAL2, SIGNAL3, SIGNAL4, SIGNAL5, SIGNAL6, SIGNAL7};
reg[6:0] x;
assign x = {X1. X2. X3. X4. X5, X6, X7};
always @(posedge CLK)
begin
if (SIGNALP == 1)
begin
SIGNAL = SIGNAL * -1;
end
if (SUMP == 1)
begin
SUM = SUM * -1;
end
yregtwo = yregone;
yregone = SIGNAL;
if (yregtwo != 0)
begin
sum = ((yregone + yregtwo)*x/2) + SUM; //treats x as plain h, change if treated as h/2
if (sum < 0)
begin
OUTP = 1;
end
OUT1 = sum[1];
OUT2 = sum[2];
OUT3 = sum[3];
OUT4 = sum[4];
OUT5 = sum[5];
OUT6 = sum[6];
OUT7 = sum[7];
end
end
endmodule
它产生错误
Target <SUM> of concurrent assignment or output port connection should be a net type.
Target <SIGNAL> of concurrent assignment or output port connection should be a net type.
Target <x> of concurrent assignment or output port connection should be a net type.
这些错误出现在定义SIGNAL
、SUM
和的行上x
。我相信部分问题是由于这些变量没有在always
循环中定义,但这样做会产生更多错误。我能做些什么来解决这个问题?
代码是在verilog中实现梯形积分法。大量输入是因为我想并行输入数据而不是串行输入,因为它更快。所有带SIGNAL
前缀的输入都用在SIGNAL
变量中,所有带X
前缀的输入都用在x
变量中,依此类推。P
输入名称末尾的A表示它是奇偶校验位。数字表示该位应该在结果寄存器中的哪个位置。
解决方案
您正在多个地方分配这些信号。你不能那样做。
assign SUM = {SUM1, SUM2, SUM3, SUM4, SUM5, SUM6, SUM7};
assign SIGNAL = {SIGNAL1, SIGNAL2, SIGNAL3, SIGNAL4, SIGNAL5, SIGNAL6, SIGNAL7};
....
if (SIGNALP == 1)
begin
SIGNAL = SIGNAL * -1;
end
if (SUMP == 1)
begin
SUM = SUM * -1;
etc.
关于 X:
assign x = {X1. X2. X3. X4. X5, X6, X7};
^ ^ ^ ^ Full stop????
always @(posedge CLK)
此外,您应该在您的部分中使用非阻塞分配。
推荐阅读
- asp.net - DataTables - 请求的未知参数(ASP.NET Core MVC)
- python - 使用枕头时的图像粘贴问题 - python
- c++ - 当您将内存地址传递给具有指针传递参数的函数时会发生什么?
- javascript - 选择/取消选择单选按钮时显示/隐藏表单
- reactjs - 如何使用 React 更改数据集?
- javascript - Chrome扩展程序:防止点击内容脚本
- python - 数组中相同列表的出现次数
- docker - How to use Docker Host Service Connection in Azure Pipelines
- python - matplotlib 条形图 - 只有大小为 1 的数组可以转换为 Python 标量
- c++ - 如何在 Qt 中合并两个 QJsonObjects?