I am trying to create a 4-bit SISO register in VHDL, and this is my main code:
library ieee;
use ieee.std_logic_1164.all;
entity right_shift_siso_reg_4 is
port(
D_in : in std_logic;
clk : in std_logic;
D_out : out std_logic
);
end right_shift_siso_reg_4;
architecture structural of right_shift_siso_reg_4 is
signal Q0, Q1, Q2: std_logic;
component d_flip_flop is
port(
D : in std_logic;
clk : in std_logic;
Q : out std_logic;
Q_bar : out std_logic
);
end component;
begin
dff0: d_flip_flop port map(D=>D_in, clk=>clk, Q=>Q0);
dff1: d_flip_flop port map(D=>Q0, clk=>clk, Q=>Q1);
dff2: d_flip_flop port map(D=>Q1, clk=>clk, Q=>Q2);
dff3: d_flip_flop port map(D=>Q2, clk=>clk, Q=>D_out);
end structural;
And this is the code for the component d_flip_flop that above program uses:
library ieee;
use ieee.std_logic_1164.all;
entity d_flip_flop is
port(
D : in std_logic;
clk : in std_logic;
Q : out std_logic;
Q_bar : out std_logic
);
end d_flip_flop;
architecture behavioral of d_flip_flop is
begin
process(clk, D)
begin
if(clk'event and clk = '1') then
Q <= D; --at rising clk. pulse if D=1, Q=1 & if D=0, Q=0
Q_bar <= NOT D;
end if;
end process;
end behavioral;
The code runs, but the output simulation that I've received seems to have problems.

As far as I know, the output signal received should be same as the input signal except it comes out shifted (probably by T=3 in this case). But if you look at the result here that is not the case (the 1st high input runs for T= 5units, but the 1st high output runs for T = 6units).
What is the problem here?
Your design doesn't look like having any problem. I wrote a testbench and tried it out myself. Here is the testbench
The output is the same as yours. If you look at the output of each DFF module, you will see that the first one doesn't work properly. It assigns the input to the output directly.
However, when I tried to create another signal at the top module and assigned the
D_into it first, the problem is solved. Check out the little modification on the code below.The waveforms of the test result are as below.
It's been a long time since I work on digital design. That's all from me, try to advance yourself, my friend :)