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

Subversion Repositories xulalx25soc

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

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

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

powered by: WebSVN 2.1.0

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