VHDL Code For Right Shift Register

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

VHDL code for Right Shift register

Your vector is std_logic_vector(7 downto 0) Left to Right, corrrect. In your loop process, you are looping first with index value as 0. So, tmp(0+1) = tmp (0); will result in tmp(1) getting written with tmp(0). This will take the second from right location and load it with the right most location. I do not believe this will accomplish your desired shift to the right, it will move the right most value into all the locations to the left. You will then be loading the right most location with the SI value. Just draw out step by step what you are trying to do and you will see that you might want to; SO = tmp(0); for i in 1 to 7 loop tmp (i-1) = tmp(i); end loop; tmp(7) = SI; and also, where is tmp declared as a register, not just as a signal? Tmp needs to hold the value, right. I hope this helps.

library ieee; use ieee.std_logic_1164.all; entity shift is port(C, SI : in std_logic; SO : out std_logic); end shift; architecture archi of shift is signal tmp: std_logic_vector(7 downto 0); begin process (C) begin if (C'event and C='1') then for i in 0 to 6 loop tmp(i+1) = tmp(i); end loop; tmp(0) = SI; end if; end process; SO = tmp(7); end archi; Thanks a lot

You might also like