-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtb_top.vhd
145 lines (118 loc) · 4.03 KB
/
tb_top.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
-- Main testbench for the HyperRAM controller.
-- This closely mimics the MEGA65 top level file, except that
-- clocks are generated directly, instead of via MMCM.
--
-- Created by Michael Jørgensen in 2022 (mjoergen.github.io/HyperRAM).
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity tb_top is
end entity tb_top;
architecture simulation of tb_top is
constant C_DELAY : time := 1 ns;
signal sys_clk : std_logic := '1';
signal sys_reset : std_logic := '1';
signal sys_resetn : std_logic;
signal sys_csn : std_logic;
signal sys_ck : std_logic;
signal sys_rwds : std_logic;
signal sys_dq : std_logic_vector(7 downto 0);
signal sys_rwds_in : std_logic;
signal sys_dq_in : std_logic_vector(7 downto 0);
signal sys_rwds_out : std_logic;
signal sys_dq_out : std_logic_vector(7 downto 0);
signal sys_rwds_oe : std_logic;
signal sys_dq_oe : std_logic;
-- HyperRAM simulation device interface
signal hr_resetn : std_logic;
signal hr_csn : std_logic;
signal hr_ck : std_logic;
signal hr_rwds : std_logic;
signal hr_dq : std_logic_vector(7 downto 0);
component s27kl0642 is
port (
dq7 : inout std_logic;
dq6 : inout std_logic;
dq5 : inout std_logic;
dq4 : inout std_logic;
dq3 : inout std_logic;
dq2 : inout std_logic;
dq1 : inout std_logic;
dq0 : inout std_logic;
rwds : inout std_logic;
csneg : in std_logic;
ck : in std_logic;
ckn : in std_logic;
resetneg : in std_logic
);
end component s27kl0642;
begin
---------------------------------------------------------
-- Generate clock and reset
---------------------------------------------------------
sys_clk <= not sys_clk after 5 ns;
sys_reset <= '1', '0' after 1000 ns;
--------------------------------------------------------
-- Instantiate DUT
--------------------------------------------------------
top_inst : entity work.top
port map (
clk => sys_clk,
reset => sys_reset,
hr_resetn => sys_resetn,
hr_csn => sys_csn,
hr_ck => sys_ck,
hr_rwds => sys_rwds,
hr_dq => sys_dq,
kb_io0 => open,
kb_io1 => open,
kb_io2 => '0',
hdmi_data_p => open,
hdmi_data_n => open,
hdmi_clk_p => open,
hdmi_clk_n => open
); -- top_inst
---------------------------------------------------------
-- Connect controller to device (with delay)
---------------------------------------------------------
hr_resetn <= sys_resetn after C_DELAY;
hr_csn <= sys_csn after C_DELAY;
hr_ck <= sys_ck after C_DELAY;
wiredelay2_rwds_inst : entity work.wiredelay2
generic map (
G_DELAY => C_DELAY
)
port map (
a => sys_rwds,
b => hr_rwds
); -- wiredelay2_rwds_inst
dq_delay_gen : for i in 0 to 7 generate
wiredelay2_dq_inst : entity work.wiredelay2
generic map (
G_DELAY => C_DELAY
)
port map (
a => sys_dq(i),
b => hr_dq(i)
); -- wiredelay2_dq_inst
end generate dq_delay_gen;
---------------------------------------------------------
-- Instantiate HyperRAM simulation model
---------------------------------------------------------
s27kl0642_inst : component s27kl0642
port map (
dq7 => hr_dq(7),
dq6 => hr_dq(6),
dq5 => hr_dq(5),
dq4 => hr_dq(4),
dq3 => hr_dq(3),
dq2 => hr_dq(2),
dq1 => hr_dq(1),
dq0 => hr_dq(0),
rwds => hr_rwds,
csneg => hr_csn,
ck => hr_ck,
ckn => not hr_ck,
resetneg => hr_resetn
); -- s27kl0642_inst
end architecture simulation;