首页 文章

在verilog中可以输入端口类型为reg吗?

提问于
浏览
0

在我的教科书中有一个侧面说明输入或输入端口永远不会是一个reg,因为这将导致端口中的永久“x” . 但是,当我为AND门编写代码并将输入端口设置为reg类型时,它工作正常 .

和盖茨:

//AND Gate

`timescale 1ns/100ps
module test(output C, input reg A,B);
assign C = A & B;
endmodule

试验台:

//AND GATE TEST BENCH
`timescale 1ns/100ps


module AND_tb;

//Declaring Variables
wire Cwatch;
reg [1:0] stim;

initial begin
#1 stim = 2'b00;
#1 stim = 2'b01;
#1 stim = 2'b10;
#1 stim = 2'b11;
#1 $stop;
end

test AND_1 (
.C(Cwatch),
.A(stim[0]), 
.B(stim[1])
);
endmodule

这是paragraph from the textbook

1 回答

  • 0

    你还没有告诉你使用哪个模拟器 .

    但是,我也注意到一些模拟器对定义为'reg'的输入没有问题 . 我认为它是模拟器的特质 .

    但是,只要您尝试合成它很可能会失败 .

    1:我还没有找到一个接受输入注册的综合工具,但我还没有尝试过所有现有的工具 .

相关问题