【问题标题】:IF statement doesn't work in a vhdl processIF 语句在 vhdl 进程中不起作用
【发布时间】:2018-10-24 22:51:37
【问题描述】:

感谢 FPGA 板上的 VGA 端口,我正在尝试在屏幕上显示动画图像。

所以,我有一个名为 sonic_digit 的实体,它允许发送我的图像:

sonic_digit0 : sonic_digit port map(    
                                val => val2,                                
                                posX=> posXX,
                                posY =>conv_std_logic_vector(300,10),
                                rgbOut => rgb,
                                beamX=>beamX,
                                beamY=>beamY,
                                beamValid=>beamValid);

val 用于改变图像(要显示的精灵)。

首先,我想循环显示 3 个第一个精灵,并在它到达 x 中的第 550 个像素时停止它并显示第 4 个精灵。所以我必须有 val : 00, 01, 10, 00, 01, 10, 00 ........ 然后当 posXX 到达 550 时为 11。

所以,我厌倦了使用我的过程来管理两个图像之间的时间:

process (clk50) begin
    if rising_edge(clk50) then
        count <= count+1;

        if count = conv_std_logic_vector(0,23) then
            posXX <= posXX+1;
            val2  <= val2+1;

            if val2 = "11" then
                val2 <= "00";
            end if;
        end if;
    end if;
end process;

我的图像在 x 中正确移动,但它不断增加到 11,就像 if val2 = "11" 行不起作用... 我有 00, 01, 10, 11, 00, 01, 10, 11, ...

有人有想法吗? 感谢您的帮助

【问题讨论】:

  • 感谢您的提议。但是,它仍然无法按预期工作。 if 不被尊重 ....
  • 这看起来很正常。当val2 达到“11”时,您对它有什么期望?
  • 也许您需要检查val2 = "10" 而不是"11"。每当count = 0 时,都会检查if

标签: vhdl


【解决方案1】:

val2 比较是同步的,仅在时钟的上升沿发生。所以val2的值必须增加到“11”才能触发比较,所以生成的序列是“00”“01”“10”“11”“00”......

如果你想省略“11”这个词,你的条件需要是:

if val2 = "10" then
    val2 <= "00";
end if;

另外,虽然不是严格要求,但我不喜欢在流程块中重叠分配,所以我会将您的代码重构为:

if val2 = "10" then
    val2 <= "00";
else
    val2 <= val2 + 1;
end if;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-22
    • 2016-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多