首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Verilog ICE40 LED驱动程序作为IO - SB_IO_OD,如何分配

Verilog ICE40 LED驱动程序作为IO - SB_IO_OD,如何分配
EN

Stack Overflow用户
提问于 2022-02-07 00:28:44
回答 1查看 199关注 0票数 0

新来这里的。

Ice40有一个RGB驱动程序,它也可以作为一个正常IO分配。

尝试访问引脚而不将其设置为IO将给出一个IceCube2错误。

约束IO放置E2792中的错误:实例ipInertedIOPad_LED_B在SB_IO_OD位置被不正确地约束

为此,使用了以下verilog:

代码语言:javascript
复制
    SB_IO_OD #(             // open drain IP instance
    .PIN_TYPE(6'b011001)  // configure as output
    ) pin_out_driver (
    .PACKAGEPIN(LED_B), // connect to this pin
    .DOUT0(ledb)           // output the state of "led"
    );

因此,最终的verilog代码看起来像(简化为1 led):

代码语言:javascript
复制
module top (output LED_R, output LED_G, output LED_B);

    reg ledb = 0;

    reg [3:0] cnt;

    SB_IO_OD #(             // open drain IP instance
    .PIN_TYPE(6'b011001)  // configure as output
    ) pin_out_driver (
    .PACKAGEPIN(LED_B), // connect to this pin
    .DOUT0(ledb)           // output the state of "led"
    );

    always
    begin
        ledb = ~cnt[2];
    end

    always @(posedge clkout)
    begin
        cnt <= cnt + 1;
    end

endmodule

而且确实有用。

但是,我在一个始终块中分配了led,据我所理解,这是连续的。会以“正确”的方式将分类帐指定为一条线路,但却与SB_IO_OD不兼容。

这是正确的方法,还是有一种非顺序的方式来分配led,基本上没有在始终块中分配。

EN

回答 1

Stack Overflow用户

发布于 2022-02-07 00:57:29

经过一番挖掘,我相信这是正确的方法。它使用的逻辑单元也要少得多。

IceCube2上的工作代码,简单的LED闪光灯:

代码语言:javascript
复制
module top (output LED_R, output LED_G, output LED_B);

wire [2:0] leds;
reg [2:0] cnt;

SB_IO_OD #(             // open drain IP instance
.PIN_TYPE(6'b011001)  // configure as output
) pin_out_driver (
.PACKAGEPIN(LED_B), // connect to this pin
.DOUT0(leds[0])           // output the state of "led"
);

SB_IO_OD #(             // open drain IP instance
.PIN_TYPE(6'b011001)  // configure as output
) pin_out_driver2 (
.PACKAGEPIN(LED_G), // connect to this pin
.DOUT0(leds[1])           // output the state of "led"
);

SB_IO_OD #(             // open drain IP instance
.PIN_TYPE(6'b011001)  // configure as output
) pin_out_driver3 (
.PACKAGEPIN(LED_R), // connect to this pin
.DOUT0(leds[2])           // output the state of "led"
);

wire sysclk;

SB_HFOSC #(.CLKHF_DIV("0b00")) osc (
.CLKHFEN(1'b1),
.CLKHFPU(1'b1),
.CLKHF(sysclk) 
) /* synthesis ROUTE_THROUGH_FABRIC = 0 */;

wire clkout;
clockdivider #(.bits(28)) div(
.clkin(sysclk),
.clkout(clkout),
.div(28'd48000000)
);

assign leds  = {~cnt[2:0]};

always @(posedge clkout)
begin
    cnt <= cnt + 1;
end

endmodule
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71012326

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档