我尝试将模块输出连接到寄存器,如下所示:
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
Run Code Online (Sandbox Code Playgroud)
我Illegal output or inout port connection for "port 'count'在ModelSim中得到了错误" ".即使错误与我的代码匹配,我也不明白为什么,从根本上说,我无法将模块输出连接到寄存器.
为什么我不能将模块输出连接到Verilog中的寄存器?
| 归档时间: |
|
| 查看次数: |
7730 次 |
| 最近记录: |