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

Subversion Repositories xulalx25soc

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

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
        input           [5:0]    brd_interrupts;
72
        output  wire    [7:0]    o_ints_to_zip_cpu;
73
        output  wire            o_interrupt;
74
 
75
 
76
        wire    i_uart_rx_int, i_uart_tx_int, i_scop_int, i_flash_int,i_pwm_int;
77
        assign  i_uart_tx_int = brd_interrupts[5];
78
        assign  i_uart_rx_int = brd_interrupts[4];
79
        assign  i_pwm_int     = brd_interrupts[3];
80
        assign  i_scop_int    = brd_interrupts[2];
81
        assign  i_flash_int   = brd_interrupts[1];
82
 
83
        // reg          [31:0]  pwrcount;
84
        // reg          [31:0]  rtccount;
85 31 dgisselq
        wire            [31:0]   ictrl_data, gpio_data, date_data, timer_data;
86 2 dgisselq
 
87
        reg     [31:0]   r_wb_data;
88
        reg             r_wb_addr;
89
        always @(posedge i_clk)
90
        begin
91
                r_wb_addr <= i_wb_addr[4];
92
                // if ((i_wb_cyc)&&(i_wb_stb)&&(i_wb_we)&&(~i_wb_addr[4]))
93
                // begin
94
                        // casez(i_wb_addr[3:0])
95
                        // // 4'h0: begin end // Reset register
96
                        // // 4'h1: begin end // Status/Control register
97
                        // // 4'h2: begin end // Reset register
98
                        // // 4'h3: begin end // Interrupt Control register
99
                        // // 4'h4: // R/O Power count
100
                        // // 4'h5: // RTC count
101
                        // default: begin end
102
                        // endcase
103
                // end else
104
                if ((i_wb_cyc)&&(i_wb_stb)&&(~i_wb_we))
105
                begin
106
                        casez(i_wb_addr[3:0])
107 31 dgisselq
                        4'h01: r_wb_data <= `DATESTAMP;
108
                        4'h02: r_wb_data <= ictrl_data;
109
                        4'h03: r_wb_data <= i_bus_err_addr;
110
                        4'h04: r_wb_data <= timer_data;
111 2 dgisselq
                        4'h05: r_wb_data <= date_data;
112
                        4'h06: r_wb_data <= gpio_data;
113
                        default: r_wb_data <= 32'h0000;
114
                        endcase
115
                end
116
        end
117
 
118 31 dgisselq
        // The Zip Timer
119
        wire            tm_int, tm_ack, tm_stall;
120
        ziptimer        timer(i_clk, 1'b0, 1'b1,
121
                                (i_wb_cyc),(i_wb_stb)&&(i_wb_addr==5'h04),
122
                                        i_wb_we, i_wb_data,
123
                                tm_ack, tm_stall, timer_data, tm_int);
124
 
125 2 dgisselq
        // The interrupt controller
126
        wire            ck_int;
127 31 dgisselq
        wire    [8:0]    interrupt_vector;
128
        assign  interrupt_vector = { tm_int,
129 2 dgisselq
                        i_uart_tx_int, i_uart_rx_int, i_pwm_int, gpio_int,
130
                        i_scop_int, i_flash_int, ck_int, brd_interrupts[0] };
131 31 dgisselq
        icontrol #(9)   intcontroller(i_clk, 1'b0,
132 2 dgisselq
                                ((i_wb_cyc)&&(i_wb_stb)&&(i_wb_we)
133 31 dgisselq
                                        &&(i_wb_addr==5'h2)), i_wb_data,
134 2 dgisselq
                                ictrl_data, interrupt_vector,
135
                                o_interrupt);
136
 
137
        /*
138
        // The ticks since power up register
139
        initial pwrcount = 32'h00;
140
        always @(posedge i_clk)
141
                if (~ (&pwrcount))
142
                        pwrcount <= pwrcount+1;
143
 
144
        // The time since power up register
145
        reg     [15:0]  subrtc;
146
        reg             subpps;
147
        initial rtccount = 32'h00;
148
        initial subrtc = 16'h00;
149
        always @(posedge i_clk)
150
                { subpps, subrtc } <= subrtc + 16'd43;
151
        always @(posedge i_clk)
152
                rtccount <= rtccount + ((subpps)? 32'h1 : 32'h0);
153
        */
154
 
155
        //
156
        // GPIO controller
157
        //
158
        wire    gpio_int;
159
        wbgpio  #(NGPI, NGPO)
160
                gpiodev(i_clk, i_wb_cyc, (i_wb_stb)&&(i_wb_addr[4:0]==5'h6),
161
                        i_wb_we, i_wb_data, gpio_data, i_gpio, o_gpio,gpio_int);
162
 
163
        //
164
        // 4'b1xxx
165
        // BUS access to a real time clock (not calendar, just clock)
166
        //
167
        //
168
        wire    [31:0]   ck_data;
169
        wire            ck_ppd;
170 9 dgisselq
        rtclight
171 18 dgisselq
                // #(32'h3ba6fe)        //  72 MHz clock        (2^48 / 72e6)
172
                // #(32'h388342)        //  76 MHz clock        (2^48 / 76e6)
173
                #(32'h35afe5)   //  80 MHz clock
174 9 dgisselq
                // #(32'h2eaf36)        //  92 MHz clock
175
                // #(32'h2af31d)        // 100 MHz clock
176 2 dgisselq
                theclock(i_clk, i_wb_cyc, (i_wb_stb)&&(i_wb_addr[4]),
177
                                i_wb_we, i_wb_addr[2:0], i_wb_data,
178
                        ck_data, ck_int, ck_ppd);
179
 
180
        wire            date_ack, date_stall;
181
        rtcdate thedate(i_clk, ck_ppd,
182
                        i_wb_cyc, (i_wb_stb)&&(i_wb_addr[3:0]==4'h5),
183
                                i_wb_we, i_wb_data,
184
                        date_ack, date_stall, date_data);
185
 
186
        always @(posedge i_clk)
187
                o_wb_ack <= (i_wb_stb)&&(i_wb_cyc);
188
        assign  o_wb_stall = 1'b0;
189
 
190
        assign  o_wb_data = (r_wb_addr)? ck_data : r_wb_data;
191
 
192
        //
193
        //
194
        assign  o_ints_to_zip_cpu = { i_uart_tx_int, i_uart_rx_int,
195
                        i_pwm_int, gpio_int, i_scop_int, i_flash_int,
196
                        ck_int, o_interrupt };
197
endmodule

powered by: WebSVN 2.1.0

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