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

Subversion Repositories s6soc

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

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
                        i_uart, o_uart, i_uart_cts, o_uart_rts,
50
                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
        input           i_uart_cts;
73
        output  wire    o_uart_rts;
74
        // 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
                        o_uart, i_uart_cts, tx_busy);
136
 
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 5 dgisselq
        altbusmaster    slavedbus(clk_s, reset_s,
157
                // 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 5 dgisselq
                rx_stb, rx_data, tx_stb, tx_data, tx_busy, o_uart_rts,
163
                // 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
 
175
        //
176
        // Quad SPI support
177
        //
178
        //      Supporting a Quad SPI port requires knowing which direction the
179
        //      wires are going at each instant, whether the device is in full
180
        //      Quad mode in, full quad mode out, or simply the normal SPI
181
        //      port with one wire in and one wire out.  This utilizes our
182
        //      control wires (qspi_bmod) to set the output lines appropriately.
183
        //
184
        assign io_qspi_dat = (~qspi_bmod[1])?({2'b11,1'bz,qspi_dat[0]})
185
                                :((qspi_bmod[0])?(4'bzzzz):(qspi_dat[3:0]));
186
 
187 8 dgisselq
`else
188
        reg     [26:0]   r_counter;
189
        always @(posedge clk_s)
190
                r_counter <= r_counter+1;
191
        assign  o_led[0] = r_counter[26];
192
        assign  o_led[1] = r_counter[25];
193
        assign  o_led[2] = r_counter[24];
194
        assign  o_led[3] = r_counter[23];
195
        // assign       o_led[0] = 1'b1;
196
        // assign       o_led[1] = 1'b0;
197
        // assign       o_led[2] = 1'b1;
198
        // assign       o_led[3] = 1'b0;
199
 
200
        assign  w_gpio = 16'h3;
201
        assign  o_pwm = 1'b0;
202
        assign  o_pwm_shutdown_n = 1'b0;
203
        assign  o_pwm_gain = 1'b0;
204
 
205
        assign  o_depp_wait = (~i_depp_astb_n);
206
        assign  w_depp_data = 8'h00;
207
        assign  io_qspi_dat = 4'bzzzz;
208
        assign  o_qspi_cs_n = 1'b1;
209
        assign  o_qspi_sck = 1'b1;
210
 
211
        assign  uart_setup = 30'h080002b6;
212
 
213
        assign  o_uart_rts = 1'b1;
214
`endif
215 5 dgisselq
        //
216
        // I2C support
217
        //
218
        //      Supporting I2C requires a couple quick adjustments to our
219
        //      GPIO lines.  Specifically, we'll allow that when the output
220
        //      (i.e. w_gpio) pins are high, then the I2C lines float.  They
221
        //      will be (need to be) pulled up by a resistor in order to 
222
        //      match the I2C protocol, but this change makes them look/act
223
        //      more like GPIO pins.
224
        //
225
        assign  io_sda = (w_gpio[0]) ? 1'bz : 1'b0;
226
        assign  io_scl = (w_gpio[1]) ? 1'bz : 1'b0;
227
        assign  o_gpio[15:2] = w_gpio[15:2];
228
 
229 8 dgisselq
        //
230
        // DEPP return data support
231
        //
232
        assign io_depp_data = (~i_depp_write_n)? 8'bzzzz_zzzz : w_depp_data;
233
 
234 5 dgisselq
endmodule

powered by: WebSVN 2.1.0

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