首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >串入串出加法器的制作

串入串出加法器的制作
EN

Stack Overflow用户
提问于 2019-03-18 02:55:41
回答 1查看 57关注 0票数 0

我对时序逻辑和组件感到困惑(我是新手)。我有这些组件,但我对如何在进程中使用它们感到困惑。我需要帮助理解时序逻辑是如何与组件一起工作的,而且我不确定我的输入/输出向量是否正确。我在移位寄存器的输入和输出方面遇到了问题,比如如果x(0) <= sin是正确的调用。

我必须设计这个:(https://i.stack.imgur.com/mwVdw.jpg)

这是我的主文件

代码语言:javascript
复制
use IEEE.STD_LOGIC_1164.ALL;

entity sa_top is
  port( 
        x:      in STD_LOGIC_VECTOR(7 downto 0);
        y:      in STD_LOGIC_VECTOR(7 downto 0);
        clk:    in STD_LOGIC;
        rst:    in STD_LOGIC;
        s:      out STD_LOGIC_VECTOR(7 downto 0)
       );
end sa_top;

architecture Behavioral of sa_top is

-- shift register
component sr is
    port( 
          sin:  in STD_LOGIC;
          sout: out STD_LOGIC;
          clk:  in STD_LOGIC;
          rst:  in STD_LOGIC
         );
end component sr;

-- d flip/flop
component dff is 
    port( 
           d:   in STD_LOGIC;
           q:   in STD_LOGIC;
           clk: in STD_LOGIC;
           rst: in STD_LOGIC
           );
end component dff;

-- full adder
component fa is
    port( 
            a:     in STD_LOGIC;
            b:     in STD_LOGIC;
            cin:   in STD_LOGIC;
            sum:   out STD_LOGIC;
            cout:  out STD_LOGIC
         );
end component fa;

signal xi, yi, si: std_logic;
signal xo, yo, so: std_logic;


signal s_temp: std_logic;
signal carry: std_logic;

begin
xi <= x(0);
yi <= y(0);


inp_x_instance:  sr port map(sin => xi, sout => xo, clk => clk, rst => rst);
inp_y_instance:  sr port map(sin => yi, sout => yo, clk => clk, rst => rst);

adder_instace:   fa port map(a => xo, b=> yo, cin => carry, sum => si, cout => carry);

op_s_instance:   sr port map(sin => si, sout => so, clk => clk, rst => rst);

--df_instance: dff port map(d => s_temp, q => s_temp, clk => clk, rst => rst);

    process(clk, s_temp) is
    begin
        if rst = '1' then
            s <= (others=>'0');
        elsif rising_edge(clk) then
            s(0) <= so;
         end if;
    end process;
end Behavioral;```
EN

回答 1

Stack Overflow用户

发布于 2019-03-20 15:22:53

我认为你所做的是正确的,你可能唯一感到困惑的是实际的移位本身,你需要将它从左移1到其他的位。它可能看起来像这样:

代码语言:javascript
复制
s(7 downto 1) <= s(6 downto 0);

因此,最后一段代码应该如下所示:(请注意,我已经从进程的敏感度列表中删除了s_temp )

代码语言:javascript
复制
process(clk) is
begin
    if rst = '1' then
        s <= (others=>'0');
    elsif rising_edge(clk) then
        s(7 downto 1) <= s(6 downto 0);
        s(0) <= so;
     end if;
end process;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55210748

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档