我试图在Verilogcase
语句中使用`define
来进行我的设计,但是edaplayground编译器会为使用`define
的所有行抛出以下错误:
ERROR VCP2000 "语法错误。意外标记:non-printable:
如果我在case
语句之外使用`define
,那么它工作得很好。Verilog不允许define
在case
里面吗?
下面是我的代码示例:
`define AND 4’b0000
`define OR 4’b0001
`define ADD 4’b0010
`define SLL 4’b0011
`define SLLFunc 6’b000000
`define SRLFunc 6’b000010
`define SRAFunc 6’b000011
`define ADDFunc 6’b100000
module ALUControl(
ALUCtrl,
ALUOp,
FuncCode);
input [3:0]ALUOp;
input [5:0]FuncCode;
output reg [3:0]ALUCtrl;
always@(*) begin
if (ALUOp == 4'b1111) begin
case(FuncCode)
//Compiler throws error for the below 2 lines
`SLLFunc: ALUCtrl = `SLL;
default: ALUCtrl = `AND;
endcase
end else begin
ALUCtrl = ALUOp;
end
end
endmodule
文本宏不理解Verilog语法。这只是简单的文本替换。
您的问题是用于创建`define
的编辑器。它使用了结束的单引号’
,而不是重音/打号'
。