嗨,我收到无法确定C:/Modeltech_pe_edu_10.3c/examples的语言错误,当我尝试编译此Verilog代码时。对我来说似乎很简单。做错什么了吗?任何的意见都将会有帮助。我不喜欢Modelsim,但被迫使用它。我很好奇设置是否有问题。
这使用case语句实现了基本的ALU设计。请帮忙。稍后我将尝试Xilinx,看看我是否可以运行它。谢谢!
`timescale 1ns / 1ps
module alu(result,operand0,operand1,control)
(
input [31:0] operand0,
input [31:0] operand1,
input [3:0] control,
output [31:0] result,
reg [31:0] result;
always @(control, operand0, operand1)
begin
case(control)
4'b0000: result = operand0 && operand1;
4'b0001: result = operand0 || operand1;
4'b0010: result = operand0 ^ operand1;
4'b0011: result = operand0 ~| operand1;
4'b0100: result = operand0 + operand1;
4'b0110: result = operand0 - operand1;
4'b1000: result = operand0 < operand1;
4'b1001: result = operand0 << operand1;
4'b1010: result = operand0 >> operand1;
4'b1011: result = operand0 >>> operand1;
endcase
end
endmodule
最佳答案
看起来您混合了ANSI和非ANSI样式。这将所有模拟器
非ANSI(IEEE Std 1364-1995及更高版本):
module alu(result,operand0,operand1,control)
// ( <-- you have an open parenthesizes that should be here
input [31:0] operand0;
input [31:0] operand1;
input [3:0] control;
output [31:0] result;
reg [31:0] result;
或ANSI(IEEE标准1364-2001及更高版本):
module alu(
output reg [31:0] result,
input [31:0] operand0, operand1,
input [3:0] control
);
其他建议:使用
always @*
代替always @(control, operand0, operand1)
作为自动灵敏度列表。如果您需要遵循IEEE Std 1364-1995,请使用always @(control or operand0 or operand1)
作为,
功能,以便在IEEE Std 1364-2001中添加敏感列表(以及@*
)。关于compiler-errors - 编译时出现Verilog(modelsim)语言错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26812143/