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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [rtl/] [ioslave.v] - Blame information for rev 86

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

Line No. Rev Author Line
1 2 dgisselq
///////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    ioslave
4
//
5
// Project:     XuLA2 board
6
//
7
// Purpose:     This handles a bunch of small, simple I/O registers.  To be
8
//              included here, the I/O register must take exactly a single
9
//      clock to access and never stall.
10
//
11
//      Particular peripherals include:
12
//              - the interrupt controller
13
//              - Realtime Clock
14
//              - Realtime clock Date
15
//              - A bus error register--records the address of the last
16
//                      bus error.  Cannot be written to, save by a bus error.
17
//      Other peripherals have been removed due to a lack of bus address space.
18
//
19
//
20
// Creator:     Dan Gisselquist, Ph.D.
21
//              Gisselquist Technology, LLC
22
//
23
///////////////////////////////////////////////////////////////////////////
24
//
25
// Copyright (C) 2015, Gisselquist Technology, LLC
26
//
27
// This program is free software (firmware): you can redistribute it and/or
28
// modify it under the terms of  the GNU General Public License as published
29
// by the Free Software Foundation, either version 3 of the License, or (at
30
// your option) any later version.
31
//
32
// This program is distributed in the hope that it will be useful, but WITHOUT
33
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
34
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
35
// for more details.
36
//
37
// License:     GPL, v3, as defined and found on www.gnu.org,
38
//              http://www.gnu.org/licenses/gpl.html
39
//
40
//
41
///////////////////////////////////////////////////////////////////////////
42
//
43
//
44
`include "builddate.v"
45
module  ioslave(i_clk,
46
                // Wishbone control
47
                i_wb_cyc, i_wb_stb, i_wb_we, i_wb_addr, i_wb_data,
48
                        o_wb_ack, o_wb_stall, o_wb_data,
49
                // GPIO wires
50
                i_gpio,
51
                o_gpio,
52
                // Other registers
53
                i_bus_err_addr,
54
                brd_interrupts, o_ints_to_zip_cpu, o_interrupt);
55
        parameter       NGPO=15, NGPI=15;
56
        input                   i_clk;
57
        // Wishbone control
58
        //      inputs...
59
        input                   i_wb_cyc, i_wb_stb, i_wb_we;
60
        input           [4:0]    i_wb_addr;
61
        input           [31:0]   i_wb_data;
62
        //      outputs...
63
        output  reg             o_wb_ack;
64
        output  wire            o_wb_stall;
65
        output  wire    [31:0]   o_wb_data;
66
        // GPIO
67
        input   [(NGPI-1):0]     i_gpio;
68
        output wire [(NGPO-1):0] o_gpio;
69
        // Other registers
70
        input           [31:0]   i_bus_err_addr;
71 74 dgisselq
        input           [6:0]    brd_interrupts;
72
        output  wire    [8:0]    o_ints_to_zip_cpu;
73 2 dgisselq
        output  wire            o_interrupt;
74
 
75
 
76 74 dgisselq
        wire    i_sdcard_int, i_uart_tx_int, i_uart_rx_int, i_pwm_int,
77
                i_scop_int, i_flash_int;
78
        assign  i_sdcard_int  = brd_interrupts[6];
79 2 dgisselq
        assign  i_uart_tx_int = brd_interrupts[5];
80
        assign  i_uart_rx_int = brd_interrupts[4];
81
        assign  i_pwm_int     = brd_interrupts[3];
82
        assign  i_scop_int    = brd_interrupts[2];
83
        assign  i_flash_int   = brd_interrupts[1];
84
 
85
        // reg          [31:0]  pwrcount;
86
        // reg          [31:0]  rtccount;
87 31 dgisselq
        wire            [31:0]   ictrl_data, gpio_data, date_data, timer_data;
88 2 dgisselq
 
89
        reg     [31:0]   r_wb_data;
90
        reg             r_wb_addr;
91
        always @(posedge i_clk)
92
        begin
93
                r_wb_addr <= i_wb_addr[4];
94
                // if ((i_wb_cyc)&&(i_wb_stb)&&(i_wb_we)&&(~i_wb_addr[4]))
95
                // begin
96
                        // casez(i_wb_addr[3:0])
97
                        // // 4'h0: begin end // Reset register
98
                        // // 4'h1: begin end // Status/Control register
99
                        // // 4'h2: begin end // Reset register
100
                        // // 4'h3: begin end // Interrupt Control register
101
                        // // 4'h4: // R/O Power count
102
                        // // 4'h5: // RTC count
103
                        // default: begin end
104
                        // endcase
105
                // end else
106
                if ((i_wb_cyc)&&(i_wb_stb)&&(~i_wb_we))
107
                begin
108
                        casez(i_wb_addr[3:0])
109 31 dgisselq
                        4'h01: r_wb_data <= `DATESTAMP;
110
                        4'h02: r_wb_data <= ictrl_data;
111
                        4'h03: r_wb_data <= i_bus_err_addr;
112
                        4'h04: r_wb_data <= timer_data;
113 2 dgisselq
                        4'h05: r_wb_data <= date_data;
114
                        4'h06: r_wb_data <= gpio_data;
115
                        default: r_wb_data <= 32'h0000;
116
                        endcase
117
                end
118
        end
119
 
120 31 dgisselq
        // The Zip Timer
121
        wire            tm_int, tm_ack, tm_stall;
122
        ziptimer        timer(i_clk, 1'b0, 1'b1,
123
                                (i_wb_cyc),(i_wb_stb)&&(i_wb_addr==5'h04),
124
                                        i_wb_we, i_wb_data,
125
                                tm_ack, tm_stall, timer_data, tm_int);
126
 
127 2 dgisselq
        // The interrupt controller
128
        wire            ck_int;
129 31 dgisselq
        wire    [8:0]    interrupt_vector;
130
        assign  interrupt_vector = { tm_int,
131 2 dgisselq
                        i_uart_tx_int, i_uart_rx_int, i_pwm_int, gpio_int,
132
                        i_scop_int, i_flash_int, ck_int, brd_interrupts[0] };
133 31 dgisselq
        icontrol #(9)   intcontroller(i_clk, 1'b0,
134 2 dgisselq
                                ((i_wb_cyc)&&(i_wb_stb)&&(i_wb_we)
135 31 dgisselq
                                        &&(i_wb_addr==5'h2)), i_wb_data,
136 2 dgisselq
                                ictrl_data, interrupt_vector,
137
                                o_interrupt);
138
 
139
        /*
140
        // The ticks since power up register
141
        initial pwrcount = 32'h00;
142
        always @(posedge i_clk)
143
                if (~ (&pwrcount))
144
                        pwrcount <= pwrcount+1;
145
 
146
        // The time since power up register
147
        reg     [15:0]  subrtc;
148
        reg             subpps;
149
        initial rtccount = 32'h00;
150
        initial subrtc = 16'h00;
151
        always @(posedge i_clk)
152
                { subpps, subrtc } <= subrtc + 16'd43;
153
        always @(posedge i_clk)
154
                rtccount <= rtccount + ((subpps)? 32'h1 : 32'h0);
155
        */
156
 
157
        //
158
        // GPIO controller
159
        //
160
        wire    gpio_int;
161
        wbgpio  #(NGPI, NGPO)
162
                gpiodev(i_clk, i_wb_cyc, (i_wb_stb)&&(i_wb_addr[4:0]==5'h6),
163
                        i_wb_we, i_wb_data, gpio_data, i_gpio, o_gpio,gpio_int);
164
 
165
        //
166
        // 4'b1xxx
167
        // BUS access to a real time clock (not calendar, just clock)
168
        //
169
        //
170
        wire    [31:0]   ck_data;
171
        wire            ck_ppd;
172 9 dgisselq
        rtclight
173 18 dgisselq
                // #(32'h3ba6fe)        //  72 MHz clock        (2^48 / 72e6)
174
                // #(32'h388342)        //  76 MHz clock        (2^48 / 76e6)
175
                #(32'h35afe5)   //  80 MHz clock
176 9 dgisselq
                // #(32'h2eaf36)        //  92 MHz clock
177
                // #(32'h2af31d)        // 100 MHz clock
178 2 dgisselq
                theclock(i_clk, i_wb_cyc, (i_wb_stb)&&(i_wb_addr[4]),
179
                                i_wb_we, i_wb_addr[2:0], i_wb_data,
180
                        ck_data, ck_int, ck_ppd);
181
 
182
        wire            date_ack, date_stall;
183
        rtcdate thedate(i_clk, ck_ppd,
184
                        i_wb_cyc, (i_wb_stb)&&(i_wb_addr[3:0]==4'h5),
185
                                i_wb_we, i_wb_data,
186
                        date_ack, date_stall, date_data);
187
 
188
        always @(posedge i_clk)
189
                o_wb_ack <= (i_wb_stb)&&(i_wb_cyc);
190
        assign  o_wb_stall = 1'b0;
191
 
192
        assign  o_wb_data = (r_wb_addr)? ck_data : r_wb_data;
193
 
194
        //
195
        //
196 74 dgisselq
        assign  o_ints_to_zip_cpu = { i_sdcard_int,
197
                        i_uart_tx_int, i_uart_rx_int,
198 2 dgisselq
                        i_pwm_int, gpio_int, i_scop_int, i_flash_int,
199
                        ck_int, o_interrupt };
200
endmodule

powered by: WebSVN 2.1.0

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