[英]Verilog Error: Can't elaborate user hierarchy “counter:counter”
I'm tring to write snake from LED on a Quartus Board. 我想在Quartus Board上用LED编写蛇。 It's kind of like KITT-Leds, but when I try to run my program, I get an error.
有点像KITT-Leds,但是当我尝试运行程序时,出现错误。
module ukol3(KEY,LEDR);
input[1:0]KEY;
output[14:0] LEDR;
counter counter(KEY[0], KEY[1], LEDR[14:0]);
endmodule
module counter(C,CLR,Q);
input C, CLR;
output [14:0] Q;
reg [14:0] tmp;
integer i;
always @(posedge C or posedge CLR)
begin
if (CLR)
tmp = 15'b000000000000000;
if (tmp == 15'b111111111111111)
i = 0;
if (tmp == 15'b000000000000000)
i = 1;
if (i == 1)
tmp = tmp + 1'b1;
if (i == 0)
tmp = tmp - 1'b1;
end
assign Q = tmp;
endmodule
This gives me an error: 这给我一个错误:
Error: Can't elaborate user hierarchy "counter:counter"
错误:无法阐述用户层次结构“ counter:counter”
I really don't know what's going on. 我真的不知道发生了什么。
This question is about Verilog, not vhdl. 这个问题是关于Verilog,而不是vhdl。 I want to ask a couple of questions: Is your code synthesizable?
我想问几个问题:您的代码可综合吗? and what do you get after a synthesis module counter?
合成模块计数器之后您会得到什么?
For your question, I think you should compile counter
first, then compile ukol3
. 对于您的问题,我认为您应该先编译
counter
,然后再编译ukol3
。 The EDA tool will not find counter when you didn't did it first. 如果您不首先使用EDA工具,它将找不到计数器。 You should split it into two separable files and do the counter first.
您应该将其分成两个可分离的文件,然后首先进行计数。
PS: You should use a better mapping port method such as counter counter (.C(KEY[0]),.CLR (KEY[1]),.Q (LEDR[14:0]));
PS:您应该使用更好的映射端口方法,例如
counter counter (.C(KEY[0]),.CLR (KEY[1]),.Q (LEDR[14:0]));
for clearer code. 以获得更清晰的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.