-
Notifications
You must be signed in to change notification settings - Fork 4
/
echo.vhd
97 lines (74 loc) · 1.8 KB
/
echo.vhd
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
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
USE IEEE.STD_LOGIC_SIGNED.all;
entity echo is
generic (
DELAY : natural := 4800
);
port (
clk : in std_logic;
ce : in std_logic;
data_in : in std_logic_vector(31 downto 0);
data_out : out std_logic_vector(31 downto 0)
);
end entity echo;
architecture Behavioral of echo is
component D_FF_VHDL is
port
(
clk : in std_logic;
rst : in std_logic;
pre : in std_logic;
ce : in std_logic;
d : in std_logic_vector(31 downto 0);
q : out std_logic_vector(31 downto 0)
);
end component D_FF_VHDL;
type vector32 is array (natural range <>) of std_logic_vector(31 downto 0);
signal s_signal : vector32(DELAY downto 0);
begin
s_signal(0) <= data_in;
data_out <= s_signal(DELAY);
GEN_REG:
for I in 0 to DELAY-1 generate
REG: D_FF_VHDL
port map (
clk => clk,
rst => '0',
pre => '0',
ce => ce,
d => s_signal(I),
q => s_signal(I+1)
);
end generate;
end Behavioral;
----------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity D_FF_VHDL is
port
(
clk : in std_logic;
rst : in std_logic;
pre : in std_logic;
ce : in std_logic;
d : in std_logic_vector(31 downto 0);
q : out std_logic_vector(31 downto 0)
);
end entity D_FF_VHDL;
architecture Behavioral of D_FF_VHDL is
begin
process (clk) is
begin
if rising_edge(clk) then
if (rst='1') then
q <= (others => '0');
elsif (pre='1') then
q <= (others => '1');
elsif (ce='1') then
q <= d;
end if;
end if;
end process;
end architecture Behavioral;