这个 VHDL 代码是如何工作的?
How does this VHDL code work?
我本来想在下面的来源 post 中发表评论,但我还没有那个特权,所以我想我可能只是问一个问题,这样我就可以得到一些澄清。
how to delay a signal for several cycles in vhdl
基本上我需要对位于我的 VHDL 项目行为中的这个过程实施 2 个时钟周期延迟(其代码如下所示):
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 语句提供的方式进行信号分配之前需要一个时钟周期延迟,但我似乎无法创建综合- 尽管阅读了上面回答的问题 linked
,但仍有 2 个时钟脉冲延迟
当我注释掉围绕 case 的 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;
取自本问题开头给出的 link 我得到以下错误:
[Synth 8-690] 赋值宽度不匹配;目标有 2 位,源有 3 位 ["U:/Computer organisation lab/vga/vga_prac.vhd":304]
此错误消息中引用的目标是 a_store 向量,源是 a_store 和 a.
的串联
这是在我将逻辑 1 分配给 a 并创建 a_store 和 a_out 作为具有 2 个元素的 std_logic_vectors 之后(因为我想要延迟两个时钟周期)。我认为我收到这个错误的原因是因为即使在阅读了这个问题几个小时之后,我似乎仍然无法理解它实际上应该如何产生 2 个时钟周期延迟。
起初我认为可能是 1 位通过 a_store 向量迭代,直到 MSB 为 1,然后将此向量应用于 a_out,但看看它的事实总而言之,我看不出这两行代码如何执行多次。如果这是真的,我将不得不进行一些测试以确保 a_out 在其 MSB 中有一个 1。
通常我会继续前进,但经过大量搜索后,我找不到比这更简单的解决方案,尽管我并不完全理解它应该如何工作。
如果有人可以澄清这一点或建议修改我的程序以产生所需的延迟,那就太好了。
提前致谢,
西蒙。
首先,第一个代码效率不高,可以简化为
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位(或者你说的"elements"),那么你可以想象a_store(1 downto 0) & a
是a_store
的2位+[=15=的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;
我本来想在下面的来源 post 中发表评论,但我还没有那个特权,所以我想我可能只是问一个问题,这样我就可以得到一些澄清。
how to delay a signal for several cycles in vhdl
基本上我需要对位于我的 VHDL 项目行为中的这个过程实施 2 个时钟周期延迟(其代码如下所示):
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 语句提供的方式进行信号分配之前需要一个时钟周期延迟,但我似乎无法创建综合- 尽管阅读了上面回答的问题 linked
,但仍有 2 个时钟脉冲延迟当我注释掉围绕 case 的 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;
取自本问题开头给出的 link 我得到以下错误:
[Synth 8-690] 赋值宽度不匹配;目标有 2 位,源有 3 位 ["U:/Computer organisation lab/vga/vga_prac.vhd":304]
此错误消息中引用的目标是 a_store 向量,源是 a_store 和 a.
的串联这是在我将逻辑 1 分配给 a 并创建 a_store 和 a_out 作为具有 2 个元素的 std_logic_vectors 之后(因为我想要延迟两个时钟周期)。我认为我收到这个错误的原因是因为即使在阅读了这个问题几个小时之后,我似乎仍然无法理解它实际上应该如何产生 2 个时钟周期延迟。
起初我认为可能是 1 位通过 a_store 向量迭代,直到 MSB 为 1,然后将此向量应用于 a_out,但看看它的事实总而言之,我看不出这两行代码如何执行多次。如果这是真的,我将不得不进行一些测试以确保 a_out 在其 MSB 中有一个 1。
通常我会继续前进,但经过大量搜索后,我找不到比这更简单的解决方案,尽管我并不完全理解它应该如何工作。
如果有人可以澄清这一点或建议修改我的程序以产生所需的延迟,那就太好了。
提前致谢,
西蒙。
首先,第一个代码效率不高,可以简化为
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位(或者你说的"elements"),那么你可以想象a_store(1 downto 0) & a
是a_store
的2位+[=15=的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;