0
我試圖讓4位通用移位寄存器,我想加載4位,然後從CTRL移位操作的VHDL代碼。我不知道如何實現時鐘分頻器來在FPGA上運行輸出。如何實現時鐘分頻器通用移位寄存器
這裏是我到目前爲止的代碼:與enable
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity shift_register is
generic(N : integer := 4);
port(
clk, reset : in std_logic;
ctrl : in std_logic_vector(1 downto 0);
d : in std_logic_vector((N-1) downto 0);
q : out std_logic_vector((N-1) downto 0)
);
end shift_register;
architecture Behavioral of shift_register is
signal r_reg : std_logic_vector((N-1) downto 0);
signal r_next : std_logic_vector((N-1) downto 0);
begin
process(clk, reset)
begin
if(reset = '1') then
r_reg <= (others => '0');
elsif(clk'event and clk = '1') then
r_reg <= r_next;
end if;
end process;
with ctrl select
r_next <=
r_reg when "00", --do nothing
r_reg(N-2 downto 0) & d(0) when "01", --shift left
d(N-1) & r_reg(N-1 downto 1)when "10", --shift right
d when others; --load
q <= r_reg;
end Behavioral;
如何是與顯示移位寄存器的時鐘分頻器問題?你能更詳細地描述你想達到什麼嗎? – 2014-09-19 12:33:12
時鐘分頻器的跡象,沒有原始時鐘速率也不目標時鐘速率,比,目標設備/供應商的指示,... – user1155120 2014-09-19 12:37:52
@MortenZilmer我想要通過使用FPGA的開關加載某些輸入比特。 ctrl將選擇哪些位將會去。結果將顯示在fpga上的LED上。所以我只想實現一個每秒鐘都會改變的時鐘。 – user2466860 2014-09-19 12:39:14