我用vhdl:编程了一个8位移位器
entity 8b is
port(s, clk : in std_logic; p : out std_logic_vector (7 downto 0));
end entity;
architecture arch of 8b is
Signal iq : std_logic_vector (7 downto 0);
begin
process(clk)
begin
if rising_edge(clk) then
iq(7) <= s;
iq(6 downto 0) <= iq(7 downto 1);
end if;
end process;
p <= iq;
end architecture;
这个想法是,我正在接受输入,并将其提供给我的第一个D-FF。然后在接下来的7个周期中,其他触发器获得其他串行输入,这些串行输入将提供给并行输出p。
然而,我不确定这个逻辑是否有缺陷,因为这是我们为这个练习得到的解决方案:
architecture behavior of 8b is
signal p_intern : std_logic_vector(7 downto 0);
begin
P <= p_intern;
process(CLK)
begin
if rising_edge(CLK) then
p_intern <= p_intern(6 downto 0) & S;
end if;
end process;
end architecture;
但我不了解p_intern <= p_inter(6 downto 0) & S;
部分。
有人能解释一下背后的逻辑吗?我的版本是否也有效?
这两种实现之间的唯一区别似乎是行
iq(7) <= s; iq(6 downto 0) <= iq(7 downto 1);
与。
p_intern <= p_intern(6 downto 0) & S;
并且CCD_ 2被命名为CCD_。为了进行比较,我们假设它们都被命名为iq
。
让我们看看他们在做什么:
第一个实现(您的(分配给iq
:的位置
7 6 5 ... 1 0
s iq(7) iq(6) ... iq(2) iq(1)
第二个实现(解决方案(分配
7 6 5 ... 1 0
iq(6) iq(5) iq(4) ... iq(0) s
其中CCD_ 6表示";将CCD_ 7连接到CCD_;。
因此,它们并不等价。您的实现从左起改变值,解决方案从右起改变值。哪一个是正确的取决于规范(大概解决方案是正确的(。