OpenCores
URL https://opencores.org/ocsvn/sdram_controller/sdram_controller/trunk

Subversion Repositories sdram_controller

[/] [sdram_controller/] [trunk/] [scratch.vhd] - Blame information for rev 4

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 lynn0p
----------------------------------------------------------------------------------
2
-- Company: OPL Aerospatiale AG
3
-- Engineer: Owen Lynn <lynn0p@hotmail.com>
4
-- 
5
-- Create Date:    23:22:19 07/27/2009 
6
-- Design Name: 
7
-- Module Name:    scratch - impl 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: Testbench for the DDR SDRAM controller. Sends a write command, sends a read 
12
--  and outputs to the led on the Spartan3e Starter Board
13
--
14
-- Dependencies: 
15
--
16
-- Revision: 
17
-- Revision 0.01 - File Created
18
-- Additional Comments: 
19
--  Copyright (c) 2009 Owen Lynn <lynn0p@hotmail.com>
20
--  Released under the GNU Lesser General Public License, Version 3
21
--
22
----------------------------------------------------------------------------------
23
library IEEE;
24
use IEEE.STD_LOGIC_1164.ALL;
25
use IEEE.STD_LOGIC_ARITH.ALL;
26
use IEEE.STD_LOGIC_UNSIGNED.ALL;
27
library UNISIM;
28
use UNISIM.VComponents.all;
29
 
30
 
31
entity scratch is
32
        port(         clk : in  std_logic;
33
                     clke : in  std_logic;
34
                      rst : in  std_logic;
35
                 led : out std_logic_vector( 7 downto 0 );
36
 
37
                        -- SDRAM pins out
38
                          dram_clkp   : out   std_logic;
39
                          dram_clkn   : out   std_logic;
40
                          dram_clke   : out   std_logic;
41
                          dram_cs     : out   std_logic;
42
                          dram_cmd    : out   std_logic_vector(2 downto 0);
43
                          dram_bank   : out   std_logic_vector(1 downto 0);
44
                          dram_addr   : out   std_logic_vector(12 downto 0);
45
                          dram_dm     : out   std_logic_vector(1 downto 0);
46
                          dram_dqs    : inout std_logic_vector(1 downto 0);
47
                          dram_dq     : inout std_logic_vector(15 downto 0);
48
 
49
                        -- debug signals
50
                          debug_reg   : out std_logic_vector(7 downto 0)
51
                          );
52
end scratch;
53
 
54
architecture impl of scratch is
55
 
56
        type DRAM_DRIVER_STATES is ( STATE0, STATE1, STATE2, STATE3, STATE4, STATE5 );
57
        signal dram_driver_state : DRAM_DRIVER_STATES := STATE0;
58
 
59
        signal clk_bufd  : std_logic;
60
        signal clk133mhz : std_logic;
61
        signal dcm_locked : std_logic;
62
 
63
        signal op      : std_logic_vector(1 downto 0);
64
        signal addr    : std_logic_vector(25 downto 0);
65
        signal op_ack  : std_logic;
66
        signal busy_n  : std_logic;
67
        signal data_o  : std_logic_vector(7 downto 0);
68
        signal data_i  : std_logic_vector(7 downto 0);
69
        signal debug   : std_logic_vector(7 downto 0);
70
 
71
        signal reg0 : std_logic_vector(7 downto 0) := x"55";
72
 
73
begin
74
 
75
        BUFG_CLK: BUFG
76
        port map(
77
                O => clk_bufd,
78
                I => clk
79
        );
80
 
81
        SDRAM: entity work.sdram_controller
82
        port map(
83
                clk50mhz => clk_bufd,
84
                en => '1',
85
           reset => rst,
86
           op => op,
87
           addr => addr,
88
           op_ack => op_ack,
89
           busy_n => busy_n,
90
           data_o => led,
91
           data_i => data_i,
92
 
93
                dram_clkp => dram_clkp,
94
                dram_clkn => dram_clkn,
95
                dram_clke => dram_clke,
96
                dram_cs => dram_cs,
97
                dram_cmd => dram_cmd,
98
                dram_bank => dram_bank,
99
                dram_addr => dram_addr,
100
                dram_dm => dram_dm,
101
                dram_dqs => dram_dqs,
102
                dram_dq => dram_dq,
103
 
104
                debug_reg => debug
105
        );
106
 
107
        debug_reg <= debug;
108
 
109
        process(clk_bufd, clke)
110
        begin
111
                if (clke = '0') then
112
                        dram_driver_state <= STATE0;
113
                elsif (rising_edge(clk_bufd)) then
114
                        case dram_driver_state is
115
                                when STATE0 =>
116
                                        if (busy_n = '1') then
117
                                                dram_driver_state <= STATE1;
118
                                        end if;
119
 
120
                                when STATE1 =>
121
                                        addr <= "01000000000000000000000111";
122
                                        data_i <= "10101010";
123
                                        op <= "10";
124
                                        if (op_ack = '1') then
125
                                                dram_driver_state <= STATE2;
126
                                        end if;
127
 
128
                                when STATE2 =>
129
                                        op <= "00";
130
                                        if (busy_n = '1') then
131
                                                dram_driver_state <= STATE3;
132
                                        end if;
133
 
134
                                when STATE3 =>
135
                                        addr <= "01000000000000000000000111";
136
                                        op <= "01";
137
                                        if (op_ack = '1') then
138
                                                dram_driver_state <= STATE4;
139
                                        end if;
140
 
141
                                when STATE4 =>
142
                                        op <= "00";
143
                                        if (busy_n = '1') then
144
                                                dram_driver_state <= STATE5;
145
                                        end if;
146
 
147
                                when STATE5 =>
148
                                        dram_driver_state <= STATE5;
149
                        end case;
150
                end if;
151
        end process;
152
 
153
 
154
end impl;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.