Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
480 views
in Technique[技术] by (71.8m points)

vector - Shift register for std_logic_vector in VHDL

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...