简体   繁体   English

从MyHDL生成的Verilog代码中缺少输出端口

[英]Output port missing in generated Verilog code from MyHDL

I am trying to generate a verilog module from the following MyHDL module: 我正在尝试从以下MyHDL模块生成verilog模块:

top.py: top.py:

from myhdl import *
from counter import Counter

def Top(clkIn, leds):
    counter = Counter(clkIn, leds)
    return counter

clkIn = Signal(bool(0))
leds = intbv(0)[8:0]

toVerilog(Top, clkIn, leds)

and, 和,

counter.py: counter.py:

from myhdl import *

def Counter(clk, count):
    c = Signal(modbv(0)[8:0])

    @always(clk.posedge)
    def logic():
        c.next = c + 1

    @always_comb
    def outputs():
        count.next = c

    return logic, outputs

However, in the generated file's module definition, (lines 1-3) 但是,在生成的文件的模块定义中,(1-3行)

top.v: top.v:

module top (
    clkIn
);

input clkIn;
reg [7:0] counter_c;

always @(posedge clkIn) begin: TOP_COUNTER_LOGIC
    counter_c <= (counter_c + 1);
end

assign count = counter_c;

endmodule

leds[7:0] are missing. leds[7:0]丢失。 Even though these LEDs are unused I need them for my synthesizer to assign them to the proper pins on the development board. 即使这些LED未使用,我的合成器也需要它们将它们分配给开发板上正确的引脚。 Why is MyHDL omitting them? 为什么MyHDL省略了它们? and how can I make it include them? 以及如何使它们包括在内?

Change leds = intbv(0)[8:0] into leds = Signal(intbv(0)[8:0]) . leds = intbv(0)[8:0]更改为leds = Signal(intbv(0)[8:0]) Module (output) ports need to be declared as Signal . 模块(输出)端口需要声明为Signal

In your module top design, you didn't declare leds as an output. 在模块顶部设计中,没有将led声明为输出。 On clkIn is defined and it is an input. 在clkIn上定义了它,它是一个输入。 Most synthesizers will check that logic is driving outputs or some other visible, or kept logic. 大多数合成器都会检查逻辑是否在驱动输出或其他可见或保留的逻辑。 If the synthesizer determines that there is no possible way for you tell that leds is present in the design externally, it may just optimize it away as well as any dedicated logic driving it, away. 如果合成器确定没有办法告诉您外部存在设计中的LED,则它可能会将其优化,也可能将其专用的逻辑驱动掉。

If this is Altera, there is a qsf assignment called virtual pins which could be assigned to leds, to keep it. 如果这是Altera,则存在一个称为虚拟引脚的qsf分配,可以将其分配给led,以保持不变。 But the easy thing to do is add leds to the module top pin definition and assign it as an out. 但是,最简单的方法是将led添加到模块顶部引脚定义,并将其分配为out。

Per the comment from Alper, you don't assign Count to anything. 根据Alper的评论,您不会将Count分配给任何内容。 That needs to be fixed. 这需要解决。

Also, you don't initialize counter in the Counter definition. 另外,您不会在Counter定义中初始化counter。 This might work in synthesis because the logic will either init to zeros, or some other definitive value, but in simulation, the value may (probably/will) remain unknown. 这可能在综合中起作用,因为逻辑将初始化为零或某个其他确定的值,但是在仿真中,该值可能(可能/将)保持未知。 Get a reset signal if you can. 如果可以的话,获得复位信号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM