VHDL 中 std_logic_vector 的移位寄存器 [英] Shift register for std_logic_vector in VHDL

查看:54
本文介绍了VHDL 中 std_logic_vector 的移位寄存器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我,如何制作 12 位 std_logic_vector 项目的移位寄存器?

Can someone advise me, how to make shift register of 12 bit std_logic_vector items?

推荐答案

看看下面的例子.VECTOR_WIDTH 是每个 std_logic_vector 中的位数(在您的情况下为 12).FIFO_DEPTH 是您想要的移位寄存器中的向量数.

Take a look at the example below. VECTOR_WIDTH is the number of bits in each std_logic_vector (12, in your case). FIFO_DEPTH is the number of vectors you want in your shift register.

library ieee;
use ieee.std_logic_1164.all;

entity vectors_fifo is
    generic (
        VECTOR_WIDTH: natural := 12;
        FIFO_DEPTH: natural := 100
    );
    port (
        clock: in std_logic;
        reset: in std_logic;
        input_vector: in std_logic_vector(VECTOR_WIDTH-1 downto 0);
        output_vector: out std_logic_vector(VECTOR_WIDTH-1 downto 0)
    );
end;

architecture rtl of vectors_fifo is
    type fifo_memory_type is array (natural range <>) of std_logic_vector;
    signal fifo_memory: fifo_memory_type(0 to FIFO_DEPTH-1)(VECTOR_WIDTH-1 downto 0);
begin
    process (clock, reset) begin
        if reset then
            fifo_memory <= (others => (others => '0'));
        elsif rising_edge(clock) then
            fifo_memory <= input_vector & fifo_memory(0 to FIFO_DEPTH-2);
        end if;
    end process;

    output_vector <= fifo_memory(FIFO_DEPTH-1);
end;

这篇关于VHDL 中 std_logic_vector 的移位寄存器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆