[英]verilog_mode autoreginput behavior when using assignment
I wonder if the following case is possible. 我想知道以下情况是否可能。
I have : 我有 :
module a(
input [2:0] a_i
);
endmodule
module b ();
/*AUTOREGINPUTS*/
a u_a(/*AUTOINST*/)
endmodule
It expands to: 它扩展为:
module b ();
/*AUTOREGINPUTS*/
reg [2:0] a_i;
a u_a(/*AUTOINST*/
.a_i(a_i))
endmodule
But if I modify adding the line assign a_i = '0;
但是,如果我修改添加行,则
assign a_i = '0;
, then it does not expands AUTOREGINPUTS
anymore. ,则不会再扩展
AUTOREGINPUTS
。 Is there a way to expand it even if I'm doing an assignment ? 即使我正在做作业,有没有办法扩展它?
The short answer is because when running verilog-auto
to fill in /*AUTOREGINPUT*/
will exclude any signal that is already declared and by adding assign a_i = '0;
简短的答案是因为在运行
verilog-auto
时填写/*AUTOREGINPUT*/
将排除任何已声明的信号,并添加assign a_i = '0;
, you are declaring a_i
. ,您正在声明
a_i
。
In Verilog, explicit variable declarations are not required and will take on the default nettype if left undeclared under certain circumstances. 在Verilog中,不需要显式变量声明,并且在某些情况下未声明时将采用默认的网络类型。 So, if I had the following:
所以,如果我有以下几点:
module x;
assign myVar = '0;
endmodule
myVar
will be implicitly declared to be a net with the default nettype (which by default is wire
). myVar
将被隐式声明为具有默认nettype(默认为wire
)的网络。 You can read more in the System-Verilog LRM (IEEE1800-2009 Section 6.10). 您可以在System-Verilog LRM(IEEE1800-2009第6.10节)中阅读更多内容。 One recommendation to avoid typos generating implicitly declared variables is to change the default nettype with the
`default_nettype
macro to none
(ie `default_nettype none
on the top of every file); 避免拼写错误生成隐式声明的变量的一个建议是将带有
`default_nettype
宏的默认nettype更改为none
(即,每个文件顶部的`default_nettype none
); doing this forces all variables to be explicitly declared or the compiler/synthesizer will throw an error. 这样做将强制所有变量明确声明,否则编译器/合成器将引发错误。
verilog-mode
mode in emacs is aware of implicit declaration and, as such, will not autogenerate anything declared. emacs中的
verilog-mode
模式知道隐式声明,因此不会自动生成任何声明的内容。 Thus, when you add the assign
statement, you are declaring a_i
and so the autogenerator will not "redefine" a_i
. 因此,在添加
assign
语句时,您正在声明a_i
,因此自动生成器将不会“重新定义” a_i
。
To avoid this, I can only recommend running the generator before you assign any of the variables to be autogenerated. 为避免这种情况,我仅建议您在分配任何要自动生成的变量之前运行生成器。 Im not sure if it handles
`default_nettype none
correctly, but I would assume not. 我不确定它是否正确处理
`default_nettype none
,但我认为不会。
Also note, it should be /*AUTOREGINPUT*/
, not /*AUTOREGINPUTS*/
, no 's' at the end. 还要注意,它应该是
/*AUTOREGINPUT*/
,而不是/*AUTOREGINPUTS*/
,最后没有's'。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.