2017-04-21 35 views
0

我只想在下面的源文章中发表评论,但我没有这个特权,所以我想我可能会问一个问题,以便我可以得到一些澄清。这个VHDL代码是如何工作的?

how to delay a signal for several cycles in vhdl

基本上我需要执行2个时钟周期的延迟这一进程位于我的VHDL项目的行为(代码如下所示为其中):

process(font_address(0), font_address(1), font_address(2), font_address(3),font_address(4), font_address(5), font_address(6), font_address(7),vga_hcount(0), vga_hcount(1),vga_hcount(2),CLK) 

begin 




--if (CLK'event and CLK = '1') then 
    -- a_store <= a_store(1 downto 0) & a; 
    -- a_out <= a_store(1 downto 0); 
--end if; 

if (CLK'event and CLK = '1') then 
case vga_hcount(2 downto 0) is 
when "000" => font_bit <= font_data(7); 
when "001" => font_bit <= font_data(6); 
when "010" => font_bit <= font_data(5); 
when "011" => font_bit <= font_data(4); 
when "100" => font_bit <= font_data(3); 
when "101" => font_bit <= font_data(2); 
when "110" => font_bit <= font_data(1); 
when "111" => font_bit <= font_data(0); 
when others => font_bit <= font_data(0); 
end case; 
end if; 



end process; 

正如你所看到的我已经做了这样的事情,在进程中的信号分配需要一个时钟周期延迟之前,由if语句在信号分配周围提供,但我似乎无法创建可合成的2个时钟脉冲延迟,尽管读取回答了上面链接的问题

当我评论的if语句周围的情况下包裹并取消下面的代码块

if (CLK'event and CLK = '1') then 
a_store <= a_store(1 downto 0) & a; 
a_out <= a_store(1 downto 0); 
end if; 

这是一个从这个问题,我得到以下错误的开头给出的链接采取:

[Synth 8-690]赋值中的宽度不匹配;目标有2位,源有3位[“U:/计算机组织实验室/ vga/vga_prac.vhd”:304]

此错误消息中引用的目标是a_store向量,源是级联a_store和a。

这是我将逻辑1分配给a并创建a_store和a_out作为std_logic_vectors与2个元素(因为我想延迟两个时钟周期)。我认为我得到这个错误的原因是因为即使在阅读了这个问题几个小时之后,我仍然无法理解它实际上应该如何产生2个时钟周期的延迟。

我认为最初可能是1位通过a_store向量迭代,直到MSB为1,然后将此向量应用于a_out,但查看它在所有if语句中的事实,我不能看看这两行代码甚至可以执行多次。如果这是真的,我将不得不做一些测试,以确保a_out在其MSB中有1。

通常我会继续前进,但经过广泛的搜索后,我找不到比这更简单的解决方案,尽管事实上我并不完全了解它应该如何工作。

如果有人可以澄清这一点或建议对我的程序进行修改,这将会产生所需的延迟,这将是非常好的。

在此先感谢,

Simon。

+1

有在这个过程中灵敏度列表许多不必要的名称。只有'CLK'是必需的。 – JHBonarius

+1

您声称从另一个问题复制/粘贴的代码实际上是不同的。 –

+1

Martin对你的链接问题的回答显示'a_store <= a_store(store'high-1 downto 0)& a;'这给出了正确的答案。在下降范围(downto)'high给出左边界的指数值。对于具有两个元素1 downto 0的数组子类型,这将是a_store(0 downto 0)包含一个元素的数组值。你的问题是你没有忠实地执行马丁的回答。您还可以提供[MCVe](https://stackoverflow.com/help/mcve),以便可以看到声明。另外'font_bit <= font_data(to_integer(unsigned(not vga_hcount(2 downto 0))));'一个8输入多路复用器。 – user1155120

回答

2

首先,第一代码是不是有效的,并且可以减少到

use ieee.numeric_std.all; 
[...] 

process(CLK) 
begin 
    if rising_edge(CLK) then 
     font_bit <= font_data(7 - to_integer(unsigned(vga_hcount(2 downto 0)))); 
    end if; 
end process; 

对于第二部分,误差说的一切。你说a_store有2位(或者称之为“元素”),那么你可以想象a_store(1 downto 0) & aa_store的两位+ a = 1位的3位。您不能将3位分配给2位。那会合适吗?分配a_out的同样问题:2位如何适合1位?

因此:

if (CLK'event and CLK = '1') then 
    a_store <= a_store(0) & a; 
    a_out <= a_store(1); 
end if; 
+0

感谢您的反馈,当我回到实验室时,我会进行此更改并查看它是否正常工作。 – burton01

+0

这个工作只有我不得不将a_store(1 downto 0)分配给a_out,而不是你在这里完成的。不过谢谢。 – burton01

+0

@ burton01由于您没有提供完整的代码,这可能是真的。我只是建议正常的两个时钟延迟的代码。 – JHBonarius