-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFFs.vhdl
121 lines (100 loc) · 2.66 KB
/
FFs.vhdl
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
-----------------------------------------Flip Flops--------------------------------------
-----------------------------------------------------------------------------------------
-----------------------------------------3 BIT FF ---------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity FF3 is
port(D: in std_logic_vector(2 downto 0);
EN: in std_logic;
RST: in std_logic;
CLK: in std_logic;
Q: out std_logic_vector(2 downto 0));
end entity FF3;
architecture Behav of FF3 is
begin
process(D,En,CLK,rst)
begin
if rst = '1' then
Q <= (others =>'0');
elsif CLK'event and (CLK = '0') then
if EN = '1' then
Q <= D;
end if;
end if;
end process;
end architecture;
-----------------------------------------------------------------------------------------
-----------------------------------------1 BIT FF ---------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity FF1 is
port(D: in std_logic;
EN: in std_logic;
RST: in std_logic;
CLK: in std_logic;
Q: out std_logic);
end entity FF1;
architecture Behav of FF1 is
begin
process(D,En,CLK,rst)
begin
if rst = '1' then
Q <= '0';
elsif CLK'event and (CLK = '0') then
if EN = '1' then
Q <= D;
end if;
end if;
end process;
end architecture;
-----------------------------------------------------------------------------------------
-----------------------------------------16 BIT FF --------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity FF16 is
port(D: in std_logic_vector(15 downto 0);
EN: in std_logic;
RST: in std_logic;
CLK: in std_logic;
Q: out std_logic_vector(15 downto 0));
end entity FF16;
architecture Behav of FF16 is
begin
process(D,En,CLK,rst)
begin
if rst = '1' then
Q <= (others =>'0');
elsif CLK'event and (CLK = '0') then
if EN = '1' then
Q <= D;
end if;
end if;
end process;
end architecture;
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity FFX is
generic(N: integer; default: std_logic := '0');
port(D: in std_logic_vector(N-1 downto 0);
EN: in std_logic;
RST: in std_logic;
CLK: in std_logic;
Q: out std_logic_vector(N-1 downto 0));
end entity FFX;
architecture Behav of FFX is
begin
process(D,En,CLK,rst)
begin
if rst = '1' then
Q <= (others =>default);
elsif CLK'event and (CLK = '0') then
if EN = '1' then
Q <= D;
end if;
end if;
end process;
end architecture;