我是 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