1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
| library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity piso_struct is
Port ( din : in STD_LOGIC_VECTOR (3 downto 0);
dout : out STD_LOGIC;
clk : in STD_LOGIC;
reset : in STD_LOGIC;
load : in STD_LOGIC);
end piso_struct;
architecture Behavioral of piso_struct is
COMPONENT dff
PORT(
din : IN std_logic;
load : IN std_logic;
reset : IN std_logic;
clk : IN std_logic;
dout : OUT std_logic
);
END COMPONENT;
signal temp:std_logic_vector(3 downto 0):=X"0";
begin
if (load='1') generate
Inst_dff1: dff PORT MAP(
din => din(0),
load => load,
reset => reset,
dout => temp(0),
clk => clk
);
Inst_dff2: dff PORT MAP(
din => din(1),
load => load,
reset => reset,
dout => temp(1),
clk => clk
);
Inst_dff3: dff PORT MAP(
din => din(2),
load => load,
reset => reset,
dout => temp(2),
clk => clk
);
Inst_dff4: dff PORT MAP(
din => din(3),
load => load,
reset => reset,
dout => temp(3),
clk => clk
);
end generate;
if (load='0') generate
nst_dff1: dff PORT MAP(
din => temp(0),
load => load,
reset => reset,
dout => temp(1),
clk => clk
);
Inst_dff2: dff PORT MAP(
din => temp(1),
load => load,
reset => reset,
dout => temp(2),
clk => clk
);
Inst_dff3: dff PORT MAP(
din => temp(2),
load => load,
reset => reset,
dout => temp(3),
clk => clk
);
end generate;
dout<= temp(3);
end Behavioral; |