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

Subversion Repositories s6soc

[/] [s6soc/] [trunk/] [rtl/] [alttop.v] - Blame information for rev 16

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

Line No. Rev Author Line
1 5 dgisselq
`timescale 10ns / 100ps
2
////////////////////////////////////////////////////////////////////////////////
3
//
4
// Filename:    alttop.v
5
//
6
// Project:     CMod S6 System on a Chip, ZipCPU demonstration project
7
//
8
// Purpose:     This is an alternate toplevel configuration for the CMod S6
9
//              project.  Basically, the CMod S6 has so little logic within
10
//      it, that there's no logic available for in situ reprogramming.  This
11
//      toplevel file serves that purpose: It provides full configuration
12
//      access, via the UART port, for the flash (read and write), and full
13
//      test level access for all of the devices on the board.  What it
14
//      doesn't have, however, is the ZipCPU.  (I had to give up something to
15
//      get the logic back for this purpose!)
16
//
17
// Creator:     Dan Gisselquist, Ph.D.
18
//              Gisselquist Technology, LLC
19
//
20
////////////////////////////////////////////////////////////////////////////////
21
//
22
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
23
//
24
// This program is free software (firmware): you can redistribute it and/or
25
// modify it under the terms of  the GNU General Public License as published
26
// by the Free Software Foundation, either version 3 of the License, or (at
27
// your option) any later version.
28
//
29
// This program is distributed in the hope that it will be useful, but WITHOUT
30
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
31
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
32
// for more details.
33
//
34
// You should have received a copy of the GNU General Public License along
35
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
36
// target there if the PDF file isn't present.)  If not, see
37
// <http://www.gnu.org/licenses/> for a copy.
38
//
39
// License:     GPL, v3, as defined and found on www.gnu.org,
40
//              http://www.gnu.org/licenses/gpl.html
41
//
42
//
43
////////////////////////////////////////////////////////////////////////////////
44
//
45
//
46
module alttop(i_clk_8mhz,
47
                o_qspi_cs_n, o_qspi_sck, io_qspi_dat,
48
                i_btn, o_led, o_pwm, o_pwm_shutdown_n, o_pwm_gain,
49 13 dgisselq
                        i_uart, o_uart, o_uart_cts, i_uart_rts,
50 5 dgisselq
                i_kp_row, o_kp_col,
51
                i_gpio, o_gpio,
52 8 dgisselq
                io_scl, io_sda,
53
                i_depp_astb_n, i_depp_dstb_n, i_depp_write_n, io_depp_data,
54
                        o_depp_wait
55
                );
56 5 dgisselq
        input           i_clk_8mhz;
57
        //
58
        // Quad SPI Flash
59
        output  wire            o_qspi_cs_n;
60
        output  wire            o_qspi_sck;
61
        inout   wire    [3:0]    io_qspi_dat;
62
        //
63
        // General purpose I/O
64
        input           [1:0]    i_btn;
65
        output  wire    [3:0]    o_led;
66
        output  wire            o_pwm, o_pwm_shutdown_n, o_pwm_gain;
67
        //
68
        // and our serial port
69
        input           i_uart;
70
        output  wire    o_uart;
71
        //      and it's associated control wires
72 13 dgisselq
        output  wire    o_uart_cts;
73
        input           i_uart_rts;
74 5 dgisselq
        // Our keypad
75
        input           [3:0]    i_kp_row;
76
        output  wire    [3:0]    o_kp_col;
77
        // and our GPIO
78
        input           [15:2]  i_gpio;
79
        output  wire    [15:2]  o_gpio;
80
        // and our I2C port
81
        inout                   io_scl, io_sda;
82 8 dgisselq
        // Finally, the DEPP interface ... if so enabled
83
        input                   i_depp_astb_n, i_depp_dstb_n, i_depp_write_n;
84
        inout           [7:0]    io_depp_data;
85
        output  wire    o_depp_wait;
86 5 dgisselq
 
87
        //
88
        // Clock management
89
        //
90
        //      Generate a usable clock for the rest of the board to run at.
91
        //
92
        wire    ck_zero_0, clk_s;
93
 
94
        // Clock frequency = (20 / 2) * 8Mhz = 80 MHz
95
        // Clock period = 12.5 ns
96
        DCM_SP #(
97
                .CLKDV_DIVIDE(2.0),
98
                .CLKFX_DIVIDE(2),               // Here's the divide by two
99
                .CLKFX_MULTIPLY(20),            // and here's the multiply by 20
100
                .CLKIN_DIVIDE_BY_2("FALSE"),
101
                .CLKIN_PERIOD(125.0),
102
                .CLKOUT_PHASE_SHIFT("NONE"),
103
                .CLK_FEEDBACK("1X"),
104
                .DESKEW_ADJUST("SYSTEM_SYNCHRONOUS"),
105
                .DLL_FREQUENCY_MODE("LOW"),
106
                .DUTY_CYCLE_CORRECTION("TRUE"),
107
                .PHASE_SHIFT(0),
108
                .STARTUP_WAIT("TRUE")
109
        ) u0(   .CLKIN(i_clk_8mhz),
110
                .CLK0(ck_zero_0),
111
                .CLKFB(ck_zero_0),
112
                .CLKFX(clk_s),
113
                .PSEN(1'b0),
114
                .RST(1'b0));
115
 
116
        //
117
        // The UART serial interface
118
        //
119
        //      Perhaps this should be part of our simulation model as well.
120
        //      For historical reasons, internal to Gisselquist Technology,
121
        //      this has remained separate from the simulation, allowing the
122
        //      simulation to bypass whether or not these two functions work.
123
        //
124
        wire            rx_stb, tx_stb;
125
        wire    [7:0]    rx_data, tx_data;
126
        wire            tx_busy;
127
        wire    [29:0]   uart_setup;
128
 
129
        wire    rx_break, rx_parity_err, rx_frame_err, rx_ck_uart, tx_break;
130
        assign  tx_break = 1'b0;
131 8 dgisselq
        rxuart  rcvuart(clk_s, 1'b0, uart_setup,
132 5 dgisselq
                        i_uart, rx_stb, rx_data,
133
                        rx_break, rx_parity_err, rx_frame_err, rx_ck_uart);
134
        txuart  tcvuart(clk_s, reset_s, uart_setup, tx_break, tx_stb, tx_data,
135 13 dgisselq
                        o_uart, tx_busy);
136 5 dgisselq
 
137
 
138
        //
139
        // ALT-BUSMASTER
140
        //
141
        //      Busmaster is so named because it contains the wishbone
142
        //      interconnect that all of the internal devices are hung off of.
143
        //      To reconfigure this device for another purpose, usually
144
        //      the busmaster module (i.e. the interconnect) is all that needs
145
        //      to be changed: either to add more devices, or to remove them.
146
        //
147
        //      This is an alternate version of the busmaster interface,
148
        //      offering no ZipCPU and access to reprogramming via the flash.
149
        //
150
        wire    [3:0]    qspi_dat;
151
        wire    [1:0]    qspi_bmod;
152
        wire    [15:0]   w_gpio;
153 8 dgisselq
        wire    [7:0]    w_depp_data;
154 5 dgisselq
 
155 8 dgisselq
`ifndef BYPASS_LOGIC
156 13 dgisselq
        altbusmaster    slavedbus(clk_s, 1'b0,
157 5 dgisselq
                // External ... bus control (if enabled)
158 8 dgisselq
                // DEPP I/O Control
159
                i_depp_astb_n, i_depp_dstb_n, i_depp_write_n,
160
                        io_depp_data, w_depp_data, o_depp_wait,
161
                // External UART interface
162 13 dgisselq
                rx_stb, rx_data, tx_stb, tx_data, tx_busy, w_uart_cts,
163 5 dgisselq
                // SPI/SD-card flash
164
                o_qspi_cs_n, o_qspi_sck, qspi_dat, io_qspi_dat, qspi_bmod,
165
                // Board lights and switches
166
                i_btn, o_led, o_pwm, { o_pwm_shutdown_n, o_pwm_gain },
167
                // Keypad connections
168
                i_kp_row, o_kp_col,
169
                // UART control
170
                uart_setup,
171
                // GPIO lines
172
                { i_gpio, io_scl, io_sda }, w_gpio
173
                );
174 13 dgisselq
        assign  o_uart_cts = (w_uart_cts)&&(i_uart_rts);
175 5 dgisselq
 
176
        //
177
        // Quad SPI support
178
        //
179
        //      Supporting a Quad SPI port requires knowing which direction the
180
        //      wires are going at each instant, whether the device is in full
181
        //      Quad mode in, full quad mode out, or simply the normal SPI
182
        //      port with one wire in and one wire out.  This utilizes our
183
        //      control wires (qspi_bmod) to set the output lines appropriately.
184
        //
185
        assign io_qspi_dat = (~qspi_bmod[1])?({2'b11,1'bz,qspi_dat[0]})
186
                                :((qspi_bmod[0])?(4'bzzzz):(qspi_dat[3:0]));
187
 
188 8 dgisselq
`else
189
        reg     [26:0]   r_counter;
190
        always @(posedge clk_s)
191
                r_counter <= r_counter+1;
192
        assign  o_led[0] = r_counter[26];
193
        assign  o_led[1] = r_counter[25];
194
        assign  o_led[2] = r_counter[24];
195
        assign  o_led[3] = r_counter[23];
196
        // assign       o_led[0] = 1'b1;
197
        // assign       o_led[1] = 1'b0;
198
        // assign       o_led[2] = 1'b1;
199
        // assign       o_led[3] = 1'b0;
200
 
201
        assign  w_gpio = 16'h3;
202
        assign  o_pwm = 1'b0;
203
        assign  o_pwm_shutdown_n = 1'b0;
204
        assign  o_pwm_gain = 1'b0;
205
 
206
        assign  o_depp_wait = (~i_depp_astb_n);
207
        assign  w_depp_data = 8'h00;
208
        assign  io_qspi_dat = 4'bzzzz;
209
        assign  o_qspi_cs_n = 1'b1;
210
        assign  o_qspi_sck = 1'b1;
211
 
212
        assign  uart_setup = 30'h080002b6;
213
 
214 13 dgisselq
        assign  o_uart_cts = 1'b1;
215 8 dgisselq
`endif
216 5 dgisselq
        //
217
        // I2C support
218
        //
219
        //      Supporting I2C requires a couple quick adjustments to our
220
        //      GPIO lines.  Specifically, we'll allow that when the output
221
        //      (i.e. w_gpio) pins are high, then the I2C lines float.  They
222
        //      will be (need to be) pulled up by a resistor in order to 
223
        //      match the I2C protocol, but this change makes them look/act
224
        //      more like GPIO pins.
225
        //
226
        assign  io_sda = (w_gpio[0]) ? 1'bz : 1'b0;
227
        assign  io_scl = (w_gpio[1]) ? 1'bz : 1'b0;
228
        assign  o_gpio[15:2] = w_gpio[15:2];
229
 
230 8 dgisselq
        //
231
        // DEPP return data support
232
        //
233
        assign io_depp_data = (~i_depp_write_n)? 8'bzzzz_zzzz : w_depp_data;
234
 
235 5 dgisselq
endmodule

powered by: WebSVN 2.1.0

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