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

Subversion Repositories sdram_controller

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

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
 
61
        signal op      : std_logic_vector(1 downto 0);
62
        signal addr    : std_logic_vector(25 downto 0);
63
        signal op_ack  : std_logic;
64
        signal busy_n  : std_logic;
65
        signal data_i  : std_logic_vector(7 downto 0);
66 6 lynn0p
        signal debug   : std_logic_vector(7 downto 0);
67 4 lynn0p
 
68
begin
69
 
70
        BUFG_CLK: BUFG
71
        port map(
72
                O => clk_bufd,
73
                I => clk
74
        );
75
 
76
        SDRAM: entity work.sdram_controller
77
        port map(
78
                clk50mhz => clk_bufd,
79
                en => '1',
80
           reset => rst,
81
           op => op,
82
           addr => addr,
83
           op_ack => op_ack,
84
           busy_n => busy_n,
85
           data_o => led,
86
           data_i => data_i,
87
 
88
                dram_clkp => dram_clkp,
89
                dram_clkn => dram_clkn,
90
                dram_clke => dram_clke,
91
                dram_cs => dram_cs,
92
                dram_cmd => dram_cmd,
93
                dram_bank => dram_bank,
94
                dram_addr => dram_addr,
95
                dram_dm => dram_dm,
96
                dram_dqs => dram_dqs,
97
                dram_dq => dram_dq,
98
 
99
                debug_reg => debug
100
        );
101
 
102
        debug_reg <= debug;
103
 
104
        process(clk_bufd, clke)
105
        begin
106
                if (clke = '0') then
107
                        dram_driver_state <= STATE0;
108
                elsif (rising_edge(clk_bufd)) then
109
                        case dram_driver_state is
110
                                when STATE0 =>
111
                                        if (busy_n = '1') then
112
                                                dram_driver_state <= STATE1;
113
                                        end if;
114
 
115
                                when STATE1 =>
116
                                        addr <= "01000000000000000000000111";
117 6 lynn0p
                                        data_i <= "11111111";
118 4 lynn0p
                                        op <= "10";
119
                                        if (op_ack = '1') then
120
                                                dram_driver_state <= STATE2;
121
                                        end if;
122
 
123
                                when STATE2 =>
124
                                        op <= "00";
125
                                        if (busy_n = '1') then
126
                                                dram_driver_state <= STATE3;
127
                                        end if;
128
 
129
                                when STATE3 =>
130
                                        addr <= "01000000000000000000000111";
131
                                        op <= "01";
132
                                        if (op_ack = '1') then
133
                                                dram_driver_state <= STATE4;
134
                                        end if;
135
 
136
                                when STATE4 =>
137
                                        op <= "00";
138
                                        if (busy_n = '1') then
139
                                                dram_driver_state <= STATE5;
140
                                        end if;
141
 
142
                                when STATE5 =>
143
                                        dram_driver_state <= STATE5;
144
                        end case;
145
                end if;
146
        end process;
147
 
148
 
149
end impl;

powered by: WebSVN 2.1.0

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