大家帮我分析一下,谢谢!
module sync_reset(clock,rst_n,d,q);input d;
input clock;
input rst_n;
outputq;
regd;
regq;
always@(posedge clock)
if(!rst_n)
q<=3'b000;
else
q<=d;
endmodule
==================================
为什么编译时会报错:
** Error: F:/code/sync_reset.v(7): Port mode is incompatible with declaration: d
请赐教!!! 如果要把d和q都定义为寄存器变量,应该怎么改? d不能定义为reg型。程序如下。
module sync_reset(clock,rst_n,d,q);
input d;
input clock;
input rst_n;
outputq;
regq;
always@(posedge clock)
if(!rst_n)
q<=3'b000;
else
q<=d;
endmodule
此时d默认为wire型,你也可以添加一句,wire d。 恩 为什么d不能定义成reg型呢?
reg型变量可以赋给另外一个reg型变量的,对吧? d是输入值,变量是程序运行时其值可以改变的量,input连变量都不是,怎么可以定义成reg型变量呢 那既然input不是变量,为什么d定义成线网类型变量又可以呢? a,不好意思,我把它当成VHDL了,我又查了一下,在Verilog HDL模块中的输入/输出信号类型缺省时自动定义为wire型。reg型对应于触发器或寄存器这一类记忆功能,而input变量是不具备这一性质的。
页:
[1]