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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [rtl/] [wbgpio.v] - Blame information for rev 96

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

Line No. Rev Author Line
1 2 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    wbgpio.v
4
//
5
// Project:     XuLA2 board
6
//
7 7 dgisselq
// Purpose:     This extremely simple GPIO controller, although minimally 
8
//              featured, is designed to control up to sixteen general purpose
9
//      input and sixteen general purpose output lines of a module from a
10
//      single address on a 32-bit wishbone bus.
11 2 dgisselq
//
12 7 dgisselq
//      Input GPIO values are contained in the top 16-bits.  Any change in
13
//      input values will generate an interrupt.
14 2 dgisselq
//
15 7 dgisselq
//      Output GPIO values are contained in the bottom 16-bits.  To change an
16
//      output GPIO value, writes to this port must also set a bit in the
17
//      upper sixteen bits.  Hence, to set GPIO output zero, one would write
18
//      a 0x010001 to the port, whereas a 0x010000 would clear the bit.  This
19
//      interface makes it possible to change only the bit of interest, without
20
//      needing to capture and maintain the prior bit values--something that
21
//      might be difficult from a interrupt context within a CPU.
22
//      
23
//
24
//
25 2 dgisselq
// Creator:     Dan Gisselquist, Ph.D.
26
//              Gisselquist Technology, LLC
27
//
28
////////////////////////////////////////////////////////////////////////////////
29
//
30
// Copyright (C) 2015, Gisselquist Technology, LLC
31
//
32
// This program is free software (firmware): you can redistribute it and/or
33
// modify it under the terms of  the GNU General Public License as published
34
// by the Free Software Foundation, either version 3 of the License, or (at
35
// your option) any later version.
36
//
37
// This program is distributed in the hope that it will be useful, but WITHOUT
38
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
39
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
40
// for more details.
41
//
42
// License:     GPL, v3, as defined and found on www.gnu.org,
43
//              http://www.gnu.org/licenses/gpl.html
44
//
45
//
46
////////////////////////////////////////////////////////////////////////////////
47
//
48
//
49
module wbgpio(i_clk, i_wb_cyc, i_wb_stb, i_wb_we, i_wb_data, o_wb_data,
50
                i_gpio, o_gpio, o_int);
51
        parameter       NIN=16, NOUT=16, DEFAULT=16'h00;
52
        input                   i_clk;
53
        //
54
        input                   i_wb_cyc, i_wb_stb, i_wb_we;
55
        input           [31:0]   i_wb_data;
56
        output  wire    [31:0]   o_wb_data;
57
        //
58
        input           [(NIN-1):0]      i_gpio;
59
        output  reg     [(NOUT-1):0]     o_gpio;
60
        //
61
        output  reg             o_int;
62
 
63
        // 9LUT's, 16 FF's
64
        always @(posedge i_clk)
65
                if ((i_wb_cyc)&&(i_wb_stb)&&(i_wb_we))
66
                        o_gpio <= ((o_gpio)&(~i_wb_data[(NOUT+16-1):16]))
67
                                |((i_wb_data[(NOUT-1):0])&(i_wb_data[(NOUT+16-1):16]));
68
 
69
        reg     [(NIN-1):0]      x_gpio, r_gpio;
70
        // 3 LUTs, 33 FF's
71
        always @(posedge i_clk)
72
        begin
73
                x_gpio <= i_gpio;
74
                r_gpio <= x_gpio;
75
                o_int  <= (x_gpio != r_gpio);
76
        end
77
 
78
        assign  o_wb_data = { {(16-NIN){1'b0}}, r_gpio,
79
                                        {(16-NOUT){1'b0}}, o_gpio };
80
endmodule

powered by: WebSVN 2.1.0

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