【问题标题】:VHDL explanation in wordsVHDL语言解释
【发布时间】:2011-01-14 15:41:09
【问题描述】:

几天前我开始学习 VHDL 初学者课程。

我有一个代码(在下面),我正试图了解它显示了什么样的电路以及不同步骤的运作方式。 我已经在互联网上四处寻找了一段时间,但无法真正理解它的作用?所以我想现在有人可以给我一些解释吗? :.-)

我不确定,但我认为它是一种带缓冲区的“加法器”?并且缓冲区使用 2 位(Cs-1 下降到 0)但是我不知道 Cs 是什么意思……事实上,这段代码中有很多东西我不明白。

如果有人能花一些时间帮助我理解代码,我将不胜感激。

entity asc is
generic (CS : integer := 8)
port (k, ars, srs, e, u: in std_logic;
r: buffer std_logic_vector(Cs-1 downto 0));
end asc;
architecture arch of asc is
begin
p1: process (ars, k) begin
if ars = ‘1’ then
r <= (others => ‘0’);
elsif (k’event and k=’1’) then
if srs=’1’ then
r <= (others) => ‘0’);
elsif (e = ‘1’ and u = ‘1’) then
r <= r + 1;
elsif (e = ‘1’ and u = ‘0’) then
r <= r - 1;
else
r <= r;
end if;
end if;
end process;
end arch;

【问题讨论】:

  • 你能正确缩进吗?没有缩进帮助很难阅读。

标签: vhdl


【解决方案1】:

我用Sigasi HDT 重命名了您的实体的输入和输出(并纠正了一些语法错误),这应该使您的实体更加清晰。我做了以下重命名:

k -> clock
ars -> asynchronous_reset
srs -> synchronous_reset
e -> enable
u -> count_up
r-> result

如果 enable 被断言且 count_up 为真,则 result (r) 将在时钟上升沿。如果 count_up 为假,如果 enable 在时钟上升沿为真,则结果将递减。

entity asc is
   generic (resultWidth : integer := 8);
   port (clock, asynchronous_reset, synchronous_reset, enable, count_up: in std_logic;
         result: buffer std_logic_vector(resultWidth-1 downto 0)
        );
end asc;

architecture arch of asc is
begin 
  p1: process (asynchronous_reset, clock) begin
     if asynchronous_reset = '1' then
        result <= (others => '0');
     elsif (rising_edge(clock)) then
        if synchronous_reset='1' then
           result <= (others => '0');
        elsif (enable = '1' and count_up = '1') then
           result <= result + 1;
        elsif (enable = '1' and count_up = '0') then
           result <= result - 1;
        else
           result <= result;
        end if;
     end if;
  end process;
end arch;

使用这段代码sn-p时要小心:

  • 此架构似乎使用了已弃用的库:将 1 添加到 std_logic_vector 是什么意思?请改用签名数据类型。这样一来,如果你减零会发生什么是可以预测的。
  • 此实体不会警告您溢出

【讨论】:

  • 所以它是一种“2位全加器”,可以根据“count_up”上的值进行上下计算?或者它是一种计数器?最好的问候/约翰
  • 嗨,约翰,寻求帮助是个好主意,尤其是在这个网站上。不过,如果您想真正学习和理解 VHDL,花一些时间自己查看代码可能是个好主意。您可能想编写一个测试平台并在模拟器上运行它。您可以在信封背面手工绘制一些波迹。通过这种方式,您将快速学习,很快您将在此论坛上回答问题。但要回答你的问题:是的,它是一个向上或向下计数的计数器。
猜你喜欢
  • 1970-01-01
  • 2011-03-16
  • 1970-01-01
  • 2010-09-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-01-15
  • 1970-01-01
相关资源
最近更新 更多