-
Notifications
You must be signed in to change notification settings - Fork 1
/
scratch_isim_tb.vhd
172 lines (149 loc) · 4.59 KB
/
scratch_isim_tb.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
--------------------------------------------------------------------------------
-- Company: OPL Aerospatiale AG
-- Engineer: Owen Lynn <lynn0p@hotmail.com>
--
-- Create Date: 01:02:17 08/25/2009
-- Design Name:
-- Module Name: scratch_isim_tb.vhd
-- Project Name: SDRAM_TB
-- Target Device:
-- Tool versions:
-- Description:
--
-- VHDL Test Bench Created by ISE for module: scratch
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
-- Copyright (c) 2009 Owen Lynn <lynn0p@hotmail.com>
-- Released under the GNU Lesser General Public License, Version 3
--
-- Notes:
-- This testbench has been automatically generated using types std_logic and
-- std_logic_vector for the ports of the unit under test. Xilinx recommends
-- that these types always be used for the top-level I/O of a design in order
-- to guarantee that the testbench will bind correctly to the post-implementation
-- simulation model.
--------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.all;
USE ieee.numeric_std.ALL;
library UNISIM;
use UNISIM.VComponents.all;
ENTITY scratch_isim_tb IS
port(
debug_reg : out std_logic_vector(7 downto 0)
);
END scratch_isim_tb;
ARCHITECTURE behavior OF scratch_isim_tb IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT scratch
PORT(
clk : IN std_logic;
clke : in std_logic;
rst : IN std_logic;
led : OUT std_logic_vector(7 downto 0);
dram_clkp : OUT std_logic;
dram_clkn : OUT std_logic;
dram_clke : OUT std_logic;
dram_cs : out std_logic;
dram_cmd : OUT std_logic_vector(2 downto 0);
dram_bank : OUT std_logic_vector(1 downto 0);
dram_addr : OUT std_logic_vector(12 downto 0);
dram_dm : OUT std_logic_vector(1 downto 0);
dram_dqs : INOUT std_logic_vector(1 downto 0);
dram_dq : INOUT std_logic_vector(15 downto 0);
debug_reg : out std_logic_vector(7 downto 0)
);
END COMPONENT;
component ddr
port(
Clk : in std_logic;
Clk_n : in std_logic;
Cke : in std_logic;
Cs_n : in std_logic;
Ras_n : in std_logic;
Cas_n : in std_logic;
We_n : in std_logic;
Ba : in std_logic_vector(1 downto 0);
Addr : in std_logic_vector(12 downto 0);
Dm : in std_logic_vector(1 downto 0);
Dq : inout std_logic_vector(15 downto 0);
Dqs : inout std_logic_vector(1 downto 0)
);
end component;
--Inputs
signal clk : std_logic := '0';
signal rst : std_logic := '0';
--BiDirs
signal dram_dqs : std_logic_vector(1 downto 0);
signal dram_dq : std_logic_vector(15 downto 0);
--Outputs
signal led : std_logic_vector(7 downto 0);
signal dram_clkp : std_logic;
signal dram_clkn : std_logic;
signal dram_clke : std_logic;
signal dram_cs : std_logic;
signal dram_cmd : std_logic_vector(2 downto 0);
signal dram_bank : std_logic_vector(1 downto 0);
signal dram_addr : std_logic_vector(12 downto 0);
signal dram_dm : std_logic_vector(1 downto 0);
--signal debug_reg : std_logic_vector(7 downto 0);
signal debug_wait : std_logic_vector(15 downto 0);
-- Clock period definitions
constant clk_period : time := 20.0 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: scratch PORT MAP (
clk => clk,
clke => '1',
rst => rst,
led => led,
dram_clkp => dram_clkp,
dram_clkn => dram_clkn,
dram_clke => dram_clke,
dram_cs => dram_cs,
dram_cmd => dram_cmd,
dram_bank => dram_bank,
dram_addr => dram_addr,
dram_dm => dram_dm,
dram_dqs => dram_dqs,
dram_dq => dram_dq,
debug_reg => debug_reg
);
DRAM_CHIP: ddr
port map(
Clk => dram_clkp,
Clk_n => dram_clkn,
Cke => dram_clke,
Cs_n => dram_cs,
Ras_n => dram_cmd(0),
Cas_n => dram_cmd(1),
We_n => dram_cmd(2),
Ba => dram_bank,
Addr => dram_addr,
Dm => dram_dm,
Dq => dram_dq,
Dqs => dram_dqs
);
-- Clock process definitions
clk_process :process
begin
clk <= '0';
wait for clk_period/2;
clk <= '1';
wait for clk_period/2;
end process;
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100ms.
wait for 100ms;
wait for clk_period*10;
-- insert stimulus here
wait;
end process;
END;