I'm a newbie and I'm trying to implement in VHDL a shift register for a divisor component. The shift register has to take a 15 bit input and shift it to the right every clock cycle, while chaining a '0' on the most significant bit. I,ve wrote this code
------- SHIFT RIGHT ----------------------------------
> library IEEE; use IEEE.STD_LOGIC_1164.ALL; use ieee.numeric_std.all; > > entity shift_right is port( in_shift_right: in std_logic_vector(14 > downto 0); > clk_shift_right, rst_shift_right : in std_logic; > out_shift_right : out std_logic_vector (14 downto 0) ); end shift_right; > > architecture behavioral of shift_right is begin > process(clk_shift_right, rst_shift_right, in_shift_right ) variable > tmp : std_logic_vector(14 downto 0); begin > if rising_edge (clk_shift_right) then elsif rst_shift_right = '1' then > tmp := (others => '0'); > elsif rising_edge(clk_shift_right) then > tmp:='0'&in_shift_right(14 downto 1); > end if; > out_shift_right<=tmp; end process; end behavioral; This is the result on the waveform tested with Quartus' grafic tool:
This in not what i'm looking for, in fact in only works for the first clock cycle. Although i've found the following code online
> library IEEE; > use IEEE.STD_LOGIC_1164.ALL; > > entity shift is > port( > clk:in std_logic; > rst:in std_logic; > sin:in std_logic; > pin:in std_logic_vector(7 downto 0); > mode:in std_logic_vector(1 downto 0); > sout:out std_logic; > pout:out std_logic_vector(7 downto 0) > ); > end shift; > > > architecture Behavioral of shift is > signal temp:std_logic_vector(7 downto 0); > > > begin > process(rst,clk,sin,mode,pin) > > begin > > if rst='1' then > sout<='0'; > pout<="00000000"; > temp<="00000000"; > > > elsif(clk'event and clk='1')then > > case mode is > --SISO > when "00"=> > temp(6 downto 0)<= temp(7 downto 1); > temp(7)<=sin; > sout<=temp(0); > > --SIPO > when"01"=> > temp(6 downto 0)<= temp(7 downto 1); > temp(7)<=sin; > pout<=temp; > > --PIPO > when"10"=> > temp<=pin; > pout<=temp; > > > when others=> > null; > > end case; > > end if; > > end process; > > end Behavioral; IT actually works as i want, but, as you can see from the waveform, it only works when the mode chosen on "case" it's '01', but only if this comes after the '10' mode. I also can't understand why it works only after a clock cycle delay, that I highlighted in the picture:
Really thank to anyone could help me

