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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [rtl/] [toplevel.v] - Blame information for rev 52

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

Line No. Rev Author Line
1 2 dgisselq
`timescale 10ns / 100ps
2
///////////////////////////////////////////////////////////////////////////
3
//
4
// Filename:    toplevel.v
5
//
6
// Project:     XuLA2 board
7
//
8
// Purpose:     This is the _top_level_ verilog file for the XuLA2-LX25
9
//              SoC project.  Everything else fits underneath here (logically).
10
//      This is also the only file that will not go through Verilator.  Specific
11
//      to this file are the Xilinx primitives necessary to build for the
12
//      XuLA2 board--with the only exception being the ICAPE_SPARTAN6 interface.
13
//
14
//
15
// Creator:     Dan Gisselquist, Ph.D.
16
//              Gisselquist Technology, LLC
17
//
18
///////////////////////////////////////////////////////////////////////////
19
//
20
// Copyright (C) 2015, Gisselquist Technology, LLC
21
//
22
// This program is free software (firmware): you can redistribute it and/or
23
// modify it under the terms of  the GNU General Public License as published
24
// by the Free Software Foundation, either version 3 of the License, or (at
25
// your option) any later version.
26
//
27
// This program is distributed in the hope that it will be useful, but WITHOUT
28
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
29
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
30
// for more details.
31
//
32
// License:     GPL, v3, as defined and found on www.gnu.org,
33
//              http://www.gnu.org/licenses/gpl.html
34
//
35
//
36
///////////////////////////////////////////////////////////////////////////
37
//
38
//
39
// `define      HELLO_WORLD
40
// `define      ECHO_TEST
41
//
42
module toplevel(i_clk_12mhz,
43
                i_ram_feedback_clk,
44
                o_sf_cs_n, o_sd_cs_n, o_spi_sck, o_spi_mosi, i_spi_miso,
45
                o_ram_clk, o_ram_cke, o_ram_cs_n, o_ram_ras_n, o_ram_cas_n,
46
                o_ram_we_n, o_ram_bs, o_ram_addr, o_ram_udqm, o_ram_ldqm,
47
                io_ram_data,
48
                i_gpio, o_gpio, o_pwm, i_rx_uart, o_tx_uart);
49
        input           i_clk_12mhz;
50
        input           i_ram_feedback_clk;
51
        //
52
        // SPI connection(s): Flash and SD Card
53
        output  wire    o_sf_cs_n;
54
        output  wire    o_sd_cs_n;
55
        output  wire    o_spi_sck;
56
        output  wire    o_spi_mosi;
57
        input           i_spi_miso;
58
        //
59
        // SD RAM
60
        output  wire    o_ram_clk, o_ram_cke;
61
        output  wire    o_ram_cs_n, o_ram_ras_n, o_ram_cas_n, o_ram_we_n;
62
        output  wire    [1:0]    o_ram_bs;
63
        output  wire    [12:0]   o_ram_addr;
64
        output  wire            o_ram_udqm, o_ram_ldqm;
65
        inout   wire    [15:0]   io_ram_data;
66
        //
67
        // General purpose I/O
68
        // output       [31:0]  io_chan;
69
        input           [13:0]   i_gpio;
70
        output  wire    [14:0]   o_gpio;
71
        output  wire            o_pwm;
72
        input                   i_rx_uart;
73
        output  wire            o_tx_uart;
74
 
75
/////
76
        wire    [7:0]    rx_data, tx_data;
77
        wire            rx_stb, tx_stb, tx_busy;
78
        wire            clk_s, reset_s, intermediate_clk, intermediate_clk_n,
79
                        ck_zero_0;
80
        wire    ck_zero_1;
81
 
82
        DCM_SP #(
83
                .CLKDV_DIVIDE(2.0),
84
                .CLKFX_DIVIDE(3),
85 18 dgisselq
                .CLKFX_MULTIPLY(20),
86 2 dgisselq
                .CLKIN_DIVIDE_BY_2("FALSE"),
87
                .CLKIN_PERIOD(83.333333),
88
                .CLKOUT_PHASE_SHIFT("NONE"),
89
                .CLK_FEEDBACK("1X"),
90
                .DESKEW_ADJUST("SYSTEM_SYNCHRONOUS"),
91
                .DLL_FREQUENCY_MODE("LOW"),
92
                .DUTY_CYCLE_CORRECTION("TRUE"),
93
                .PHASE_SHIFT(0),
94
                .STARTUP_WAIT("TRUE")
95
        ) u0(   .CLKIN(i_clk_12mhz),
96
                .CLK0(ck_zero_0),
97
                .CLKFB(ck_zero_0),
98
                .CLKFX(clk_s),
99
                // .CLKFX180(intermediate_clk_n),
100
                .PSEN(1'b0),
101
                .RST(1'b0));
102
 
103
        DCM_SP #(
104
                .CLKDV_DIVIDE(2),
105
                .CLKFX_MULTIPLY(2),
106
                .CLKFX_DIVIDE(2),
107
                .CLKOUT_PHASE_SHIFT("FIXED"),
108
                .CLK_FEEDBACK("1X"),
109
                .DESKEW_ADJUST("SYSTEM_SYNCHRONOUS"),
110
                .DLL_FREQUENCY_MODE("LOW"),
111
                .DUTY_CYCLE_CORRECTION("TRUE"),
112 48 dgisselq
                // At a clock of 80MHz ...
113 2 dgisselq
                //
114 48 dgisselq
                //      This clock needs to be delayed so that what takes
115
                //      place within the SDRAM takes place at the middle
116
                //      of the clock interval.  This is separate from all the
117
                //      rest of the logic in the FPGA where what takes place
118
                //      happens at the clock transition.
119 2 dgisselq
                //
120
                .PHASE_SHIFT(-45),
121
                .STARTUP_WAIT("TRUE")
122
        ) u1(   .CLKIN(clk_s),
123
                .CLK0(ck_zero_1),
124
                .CLKFB(ck_zero_1),
125
                .CLK180(intermediate_clk_n),
126
                .PSEN(1'b0),
127
                .RST(1'b0));
128
        assign  intermediate_clk = ck_zero_1;
129
 
130
        ODDR2 u2( .Q(o_ram_clk),
131
                .C0(intermediate_clk),
132
                .C1(intermediate_clk_n),
133
                .CE(1'b1), .D0(1'b1), .D1(1'b0), .R(1'b0), .S(1'b0));
134
 
135
        // Generate active-high reset.
136
        /*
137
        reg     r_reset;
138
        initial r_reset = 1'b1;
139
        always @(posedge i_clk_12mhz)
140
                r_reset <= 1'b0;
141
        */
142
        assign  reset_s = 1'b0;
143
 
144
        jtagser jtagtxrx(clk_s, rx_stb, rx_data, tx_stb, tx_data, tx_busy);
145
 
146
 
147
        wire    [15:0]   ram_data;
148
        wire            ram_drive_data;
149
        reg     [15:0]   r_ram_data;
150
 
151
        busmaster #(24,15,14)
152
                wbbus(clk_s, reset_s,
153
                        // External JTAG bus control
154
                        rx_stb, rx_data, tx_stb, tx_data, tx_busy,
155
                        // Board lights and switches ... none
156
                        // SPI/SD-card flash
157
                        o_sf_cs_n, o_sd_cs_n, o_spi_sck, o_spi_mosi, i_spi_miso,
158
                        // SDRAM interface
159
                        // o_ram_clk,   // SDRAM clock = clk_100mhz_s = clk_s
160
                        o_ram_cs_n,     // Chip select
161
                        o_ram_cke,      // Clock enable
162
                        o_ram_ras_n,    // Row address strobe
163
                        o_ram_cas_n,    // Column address strobe
164
                        o_ram_we_n,     // Write enable
165
                        o_ram_bs,       // Bank select
166
                        o_ram_addr,     // Address lines
167
                        ram_drive_data,
168
                        r_ram_data,     // Data lines (input)
169
                        ram_data,       // Data lines (output)
170
                        { o_ram_udqm, o_ram_ldqm },
171
                        // GPIO
172
                        i_gpio, o_gpio, o_pwm, i_rx_uart, o_tx_uart
173
                );
174
 
175
        assign io_ram_data = (ram_drive_data) ? ram_data : 16'bzzzz_zzzz_zzzz_zzzz;
176
 
177
        reg     [15:0]   r_ram_data_ext_clk;
178
        // always @(posedge intermediate_clk_n)
179
        always @(posedge clk_s)
180
                r_ram_data_ext_clk <= io_ram_data;
181
        always @(posedge clk_s)
182
                r_ram_data <= r_ram_data_ext_clk;
183
 
184
endmodule

powered by: WebSVN 2.1.0

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