连续作业验证 [英] Continuous assignment verilog

查看:323
本文介绍了连续作业验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

-此代码是使用Modelsim 10.2d在verilog中编写的。以下错误表明{cout,l3}分配存在一些问题。

-This code is written in verilog using Modelsim 10.2d.The errors below indicate there is some problem with {cout,l3} assignment.

module alu(a,b,bin,cin,op,cout,res);
input [31:0] a,b;
input [1:0] op;
input bin,cin;
reg [31:0] l1,l2,l3;
output cout;
output [31:0] res;

assign l1 = a & b;
assign l2 = a | b;

initial
if(bin == 1'b0)
  assign {cout,l3} = a + b + cin;
else
  assign {cout,l3} = a - b + cin;

mux4to1(l1,l2,l3,op,res);
endmodule

Error-
v(14): LHS in procedural continuous assignment may not be a net: cout.
v(16): LHS in procedural continuous assignment may not be a net: cout.


推荐答案

电线不能在 initial always 块内分配。您应该将类​​型更改为 reg

wire can not be assigned inside an initial or always block. You should change the type to reg.

初始块仅在模拟开始时运行一次,而不是不断进行评估,因此应改为使用始终

The initial block will only be run once at the start of the simulation, not continually evaluated, therefore you should use always instead.

//...
output reg cout;
//...

always @* begin
  if(bin == 1'b0) begin
    {cout,l3} = a + b + cin;
  end
  else begin
    {cout,l3} = a - b + cin;
  end
end

这篇关于连续作业验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆