2

我是 xilinx 的新手,所以请原谅代码中的任何愚蠢之处。

啊,所以我正在尝试设计一个8 位 ALU,并且该模块在模拟中运行良好,但我们需要在FPGA板上获取输入和显示输出。

从技术上讲,我应该使用RS-232,但由于我们只有一个8 位输入和 8 个开关可用,我们正试图以这种方式对其进行编码。

但是,代码无法编译并给出错误 "expecting 'endmodule', found 'forever'"

我使用'forever'而不是'always'因为总是不允许在其中实例化任何实例。

任何人都可以帮助我们找出代码有什么问题吗?

module main(out,in,switch);
output [7:0] out;
input [7:0] in;
input switch;
reg [7:0] a,b,select;
reg [1:0] count;
wire eq, comp, C8;
initial
begin
count = 2'b00;
select = 8'b0000_0000;
end
MyALU A(eq, comp, C8, out, a, b, 1'b0, select[0], select[1], select[2], select[3]);


forever
begin
if (switch)
    begin
        case (count)
        00: 
             begin
             a  = in;
             count = 2'b01;
             end
        01: 
             begin
             b  = in;
             count = 2'b10;
             end     
        10: 
             begin
             select  = in;
             A(eq, comp, C8, out, a, b, 1'b0, select[0], select[1], select[2], select[3]);
             count = 2'b00;
             end
        default
             a = in;
      endcase        
    end
end 
4

2 回答 2

1

verilog 中的每个模块都必须以行结尾endmodule。您的代码中缺少这一点。并尝试使用always@(*)而不是forever. forever不可综合,仅用于模拟验证。

于 2015-12-07T05:01:41.890 回答
0
  1. Replace the forever statement by always @(*).
  2. Remove this line from the case statement: A(eq, comp, C8, out, a, b, 1'b0, select[0], select[1], select[2], select[3]);
  3. Add endmodule at the end.
于 2015-12-08T16:28:51.683 回答