Hello everybody.
I want to write code for a 16-bit register with parallel load / shift_R / shift_L / asynchronous_reset.
I have already written the code(below) ,but I have no idea if it's correct.I want your help !!!
I have an examination in a few days...
// 16-bit register -> asynchronous reset && parallel loading of D[0...15] inputs && right and left shift with serial input SI
Code:
========================================
What I have tried:
entity register_16 is
port(D_in : in std_logic_vector(15 downto 0); D_out : out std_logic_vector(15 downto 0); CLK , CLR , S1 , S0 : in std_logic );
end entity register_16;
architecture behave of register_16 is
begin
process(CLK , CLR , S)
if(CLR = '0') then -- asynchronous reset
D_out <= (D_out'range => '0');
elsif(CLK = '1' and CLK'event) then -- parallel load S1S0 => 00
if( (not S1 and not S0) = '1') then
D_out <= D_in;
elsif((not S1 and S0) = '1') then -- shift right S1S0 => 01
for i in 15 downto 1 loop
D_out(i - 1) <= D_in(i);
end loop;
elsif( (S1 and not S0) = '1') then -- shift left S1S0 => 10
for i in 0 downto 14 loop
D_out(i + 1) <= D_in(i);
end loop;
end if;
end if;
end process;
end behave;