我对 Verilog HDL 很陌生,我必须编写这个 4 位向上计数器。在阅读了一些上下计数器和 t 触发器的帮助下,我已经编写了以下代码:
module up_down_4bitcounter (
out,
up_down,
clk,
data,
reset
);
//Output Ports
output [3:0] out;
//Input Ports
input [3:0] data;
input up_down, clk, reset;
//Internal Variables
reg [3:0] out;
//Start of Code
always @(negedge clk)
if (reset) begin // active high reset
out <= 4'b0 ;
end else if (up_down) begin
out <= out + 1;
end else begin
out <= out - 1;
end
endmodule
现在,我收到此错误:
Exercise5_1.v:25: syntax error
Exercise5_1.v:25: error: unmatched character (')
Exercise5_1.v:25: error: malformed statement
第 25 行是这一行:
out <= 4'b0 ;
我不是 100% 确定我的编码是否正确。你能告诉我我的问题在哪里吗?