VHDL语言基础-时序逻辑电路-寄存器

目录

寄存器的设计:

多位寄存器:      

多位寄存器的VHDL描述:

移位寄存器:

串进并出的移位寄存器的VHDL描述:


寄存器的设计:

多位寄存器:      

一个D触发器就是一位寄存器,如果需要多位寄存器,就要用多个D触发器构成。

多位寄存器的VHDL描述:

Entity reg  is

      generic( n: natural :=4 );                            --实体类属中的常数

        port (  D: in std_logic_vector(n-1 downto 0);

                 clock, reset : in std_logic;

                 Q: out std_logic_vector (n-1 downto 0) );

End reg ;

Architecture behav of reg is

Begin

     process(clock, reset)

     begin

         if (reset=‘0’)  then Q<=( others=>‘0’);       --表示Q赋全‘0 

         elsif rising_edge(clock) then

             Q<=D;

         end if;

       end process;

End  behav ;


移位寄存器:

我们这里讨论的是串进并出的移位寄存器,即串行输入,在时钟的边沿移位进寄存器,形成并行输出

串进并出的移位寄存器的VHDL描述:

Entity   sipo is

       generic( n : natural :=8);

       port ( a : in std_logic ;

                 q: out std_logic_vector(n-1 downto 0);

                 clk : in std_logic );

End sipo;

Architecture behav of sipo is

Begin

    process(clk)

        variable reg : std_logic_vector(n-1 downto 0);

     begin

         if  rising_edge(clk)  then

              reg : = reg ( n-2 downto 0) & a ;   --左移移位寄存器;

                                      -- reg : = a & reg (n-1 downto 1); 右移移位寄存器

          end if ;

          q<= reg ;

    end  process;

End  behav;

 输入8位数据11100100,从仿真波形可以看出,8位数据是从低位左移存储到寄存器中的。

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Vizio<

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值