4
module test
(
input rst_n,
input clk,
output reg [7:0] count
);
always @(posedge clk or negedge rst_n) begin
if(!rst_n) begin
count <= 7'h0;
end else begin
if(count == 8) begin
count <= count;
end else begin
count <= count + 1'b1;
end
end
end
endmodule
module test_tb;
reg clk;
reg rst_n;
reg [7:0] counter;
initial begin
clk = 1'b0;
rst_n = 1'b0;
# 10;
rst_n = 1'b1;
end
always begin
#20 clk <= ~clk;
end
test test1 (
.rst_n(rst_n),
.clk(clk),
.count(counter) /* This is the problematic line! */
);
endmodule
我在的ModelSim錯誤「Illegal output or inout port connection for "port 'count'
」。即使錯誤與我的代碼相匹配,但我不明白爲什麼從根本上說,我無法將模塊輸出連接到寄存器。
爲什麼我不能在Verilog中將模塊輸出連接到寄存器?