SIPO 是如何运作的?

How does this SIPO Works?

我正在制作一个 UART 收发器,在接收器部分,我需要一个 SIPO 将串行数据转换为并行数据,网络搜索抛出了一个代码可以实现所需的功能,我无法做到了解此特定代码的工作原理,谷歌搜索无济于事。如果有人能指出这是如何工作的,我将不胜感激

library ieee;
use ieee.std_logic_1164.all;

entity RXN_CNTRL is 
  port(
    reset : in std_logic;
    clk : in std_logic;
    din : in std_logic;
    dout : out std_logic_vector(3 downto 0)
  );
end entity;

architecture behave of RXN_CNTRL is 
  signal s : std_logic_vector(3 downto 0) := "0000" ;
begin
  sipo : process (clk, reset)
  begin
    if (reset='1') then
      s <= "0000";
    elsif (rising_edge (clk)) then       
      s <= (din & s(3 downto 1));    
    end if;
  end process;

  dout <= s;

end architecture;

我无法理解这行 s <= (din & s(3 downto 1)); 作品。请澄清一下,我是 vhdl 的新手,想了解它是如何工作的。谢谢

在 VHDL 中 &concatenation 运算符。它用于通过 连接 将较小的数组和单个数组元素连接起来,即将它们连接在一起,从而从较小的数组和单个数组元素中生成更大的数组。所以,

 s <= (din & s(3 downto 1));

获取单个位 din 并将其连接到 s (s(3 downto 1)) 的最左边的 3 位以给出 s 的新值:

din  s(3)  s(2)  s(1)

因此,您可以看到 s 已向右移动一位,空 space 已被 din 填充 - 正是您想要的行为国家知识产权局。

在 VHDL 中,我建议始终使用 concatenationslicing 的组合(作为数组的一部分,例如 s(3 downto 1)) 用于实现移位寄存器等。内置运算符(sla 等)的行为很奇怪。

&是VHDL中的连接运算符。

所以这样做是将新收到的位(din)从左边移入s(处理s的最低位)。

假设 s 最初是“0000”。如果 din = '1',则 s <= din & s(3 downto 1) 获取 din ('1'),将 s(3 downto 1)("000") 连接到它并将结果分配给 s.通过这个s的最低位是'lost'。

我建议您通关直到您了解会发生什么。