shaiko
Advanced Member level 5
Efforts from a previous post yeilded this "smart" rx shift register.
It receives data serially through "input_bit" and shifts it conformally a "data_width" number of times either msb or lsb first controlled by "shift_direction".
Now, I want to design a tx shifter register on the same principles as the above.
This is how I see the entity...
Please help me write the VHDL process.
It receives data serially through "input_bit" and shifts it conformally a "data_width" number of times either msb or lsb first controlled by "shift_direction".
Code:
entity rx_shift_register is
port
(
clock : in std_logic ;
reset : in std_logic ;
shift_now : in std_logic ;
shift_direction : in std_logic ;
input_bit : in std_logic ;
data_width : in unsigned ( 3 downto 0 ) ;
data_out : buffer unsigned ( 7 downto 0 )
) ;
end entity rx_shift_register ;
architecture synthesizable_rx_shift_register of rx_shift_register is
begin
process ( clock , reset ) is
begin
if reset = '1' then
data_out <= ( others => '0' ) ;
elsif rising_edge ( clock ) then
if shift_now = '1' then
if shift_direction = '1' then
if data_width > 0 then
data_out ( 0 ) <= input_bit ;
for i in data_out ' length - 1 downto 1
loop
if i < data_width then
data_out ( i ) <= data_out ( i - 1 ) ;
end if;
end loop;
end if ;
else
for i in 0 to data_out ' length - 1
loop
if i = data_width - 1 then
data_out ( i ) <= input_bit ;
elsif ( i < data_width - 1 ) and ( i < data_out ' length - 1 ) then
data_out ( i ) <= data_out ( i + 1 ) ;
end if;
end loop;
end if ;
end if ;
end if ;
end process ;
end architecture synthesizable_rx_shift_register ;
Now, I want to design a tx shifter register on the same principles as the above.
This is how I see the entity...
Code:
entity tx_shift_register is
port
(
clock : in std_logic ;
reset : in std_logic ;
shift_now : in std_logic ;
shift_direction : in std_logic ;
data_width : in unsigned ( 3 downto 0 ) ;
data_in : in unsigned ( 7 downto 0 ) ;
output_bit : buffer std_logic ;
) ;
end entity rx_shift_register ;
Last edited: