libraryieee;useieee.std_logic_1164.all;--additional functionality of being able to shift both up and down--DIRUP=’1’ then DIN will shift into the least significant bit Y(0)-- If DIRUP=’0’ then DIN will shift into the most significant bit Y(7)entity shiftd isport(
din :instd_logic;-- DATA IN
en :instd_logic;-- CHIP ENABLE
clk :instd_logic;-- CLOCK
y :outstd_logic_vector(7downto0);-- SHIFTER OUTPUT
dirup :instd_logic);-- SHIFT DIRECTIONend shiftd;architecture shiftd_arch of shiftd is--SIGNALSsignal s_register :std_logic_vector(7downto0);--REGISTER CONTENTSbegin--PROCESS : SHIFT
shift :process(clk)beginif rising_edge(clk)and en='1' then-- FULLY SYNCHRONOUS AND ENABLEDif(dirup = '0')thenfor i in7downto1loop
s_register(i)<= s_register(i-1);-- SHIFT ALL BITS UP 1endloop;
s_register(0)<= din;-- INSERT DATA BIT IN LSBelseif(dirup = '1')thenfor j in1to7loop
s_register(j-1)<= s_register(j);-- SHIFT ALL BITS DOWN 1endloop;
s_register(7)<= din;-- INSERT DATA BIT IN LSB elsenull;endif;elsenull;--else null for original if statementendif;--for original if statementendprocess;
y <= s_register;-- WRITE REGISTER CONTENTS TO OUTPUTend shiftd_arch;