VHDL文字解释

发布于 2024-10-12 01:28:51 字数 745 浏览 0 评论 0原文

几天前我开始学习 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;

I started with VHDL course for beginners a few days ago.

I’ve got a code (under) and I’m trying to understand what kind of circuit it shows and how the different steps are functioning.
I’ve been looking around fore a while now in the Internet but can’t really understand what it does? So I thought someone who now this might give me some explanations’? :.-)

I`m not sure but I think it is a type of an “adder” with a buffer? And the buffer is working with 2 bits (Cs-1 downto 0) however I don’t know what Cs means….in fact there is a lot of things in this code I don’t understand.

I would really appreciate if some one would take some time to help me understand the code in words.

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;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽袖吟 2024-10-19 01:28:51

我用 Sigasi HDT 重命名了实体的输入和输出(并更正了一些语法错误),这应该会带来更多好处明确你的实体确实如此。我做了以下重命名:

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

如果 enable 被断言并且 count_up 为 true,结果 (r) 将增加在时钟上升沿。如果 count_up 为 false,且在时钟上升沿 enable 为 true,则结果将递减。

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;

使用此代码片段时要小心:

  • 此架构似乎正在使用已弃用的库:向 std_logic_vector 添加 1 意味着什么?请改用带符号的数据类型。这样,如果减零,就可以预测会发生什么。
  • 该实体不会警告您溢出

I renamed the inputs and outputs of your entity with Sigasi HDT (and corrected some syntax errors) which should make a lot more clear your entity does. I did following renames:

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

If enable is asserted and count_up is true, the result (r) will be incremented on a rising clock edge. If count_up is false, the result will be decremented if enable is true on a rising clock edge.

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;

Be careful when using this code snippet:

  • This architecture seems to be using deprecated libraries: what does adding 1 to a std_logic_vector mean? Please use the signed datatype instead. This way it is predictable what will happen if you decrement zero.
  • This entity will not warn you for overflow
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文