简体   繁体   English

myhdl约束将多个引脚关联到一个变量

[英]myhdl constraints associating multiple pins to a variable

I will be using an iCE40HX8K 我将使用iCE40HX8K

given the evaluation boards constraint file 给定评估板约束文件

set_io LED3 A2  
set_io LED7 B3  
...  
etc  

whats the best way to bundle all 8 LED's into one variable I had trouble associating things with my constraint file and ended up with something like this 将所有8个LED捆绑到一个变量中的最佳方法是什么,我在将事物与约束文件关联时遇到了麻烦,最终得到了这样的结果

#main module
def ledcount(LED1, LED2, LED3, LED4, LED5, LED6, LED7, LED8, clk):

when writing a register to the LED's I'm having to resort to this 当向LED写入寄存器时,我必须诉诸于此

op.next = op + 1
LED1 = op[0]
...
LED8 = op[7] 

I'm generating verilog like this... (I did have single sliced bits from a single signal here but it seemed to cause problems - ie LED3 in constrains not assigning to anything) 我正在生成这样的verilog ...(我确实在这里从单个信号中获得了单个切片位,但是这似乎会引起问题-即LED3在约束中未分配任何内容)

clock = Signal(bool(0))
l1 = Signal(bool(0))
...
l8 = Signal(bool(0))
toVerilog(ledcount, l1, l2, l3, l4, l5, l6, l7, l8, clock)

bad enough but its going to become unwieldy with a parallel address and data bus ... 够糟糕的,但它将变得难以处理并行地址和数据总线...

I notice in the generated verilog LED1-8 are specified like this 我注意到在生成的verilog LED1-8中是这样指定的

input LED1;
...
input LED8;

before the always clause and inside the always 在always子句之前和always内部

reg LED1;
...
reg LED8;

While all this compiles (Hardware should arrive tomorrow!) and it might(?) even work... I'm sure it can be done better! 尽管所有这些都已编译(硬件应该明天就可以到达!),并且它可能(?)仍然有效……我敢肯定它可以做得更好!

I'd be quite happy handling the LED's together as a single byte using bit manipulation... 我很乐意使用位操作将LED作为一个字节一起处理...

The most straight forward is to change your constraints to 最直接的方法是将您的约束更改为

set_io LED[2] A2

and then use a single LED port 然后使用一个LED端口

def ledcount(leds, clk)

and it can be converted to 它可以转换为

clk = Signal(bool(0))
leds = Signal(intbv(0)[8:])
myhdl.toVerilog(ledcount, leds, clk)

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

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