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

Subversion Repositories openarty

[/] [openarty/] [trunk/] [rtl/] [wbgpio.v] - Blame information for rev 50

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 36 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    wbgpio.v
4
//
5 50 dgisselq
// Project:     OpenArty, an entirely open SoC based upon the Arty platform
6 36 dgisselq
//
7
// Purpose:     A General Purpose Input/Output controller.  This controller 
8
//              allows a user to read the current state of the 16-GPIO input
9
//      pins, or to set the state of the 16-GPIO output pins. Specific numbers
10
//      of pins are configurable from 1-16.
11
//
12
//      Unlike other controllers, this controller offers no capability to
13
//      change input/output direction, or to implement pull-up or pull-down
14
//      resistors.  It simply changes and adjusts the values going out the
15
//      output pins, while allowing a user to read the values on the input
16
//      pins.
17
//
18
//      Any change of an input pin value will result in the generation of an
19
//      interrupt signal.
20
//
21
// Creator:     Dan Gisselquist, Ph.D.
22
//              Gisselquist Technology, LLC
23
//
24
////////////////////////////////////////////////////////////////////////////////
25
//
26
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
27
//
28
// This program is free software (firmware): you can redistribute it and/or
29
// modify it under the terms of  the GNU General Public License as published
30
// by the Free Software Foundation, either version 3 of the License, or (at
31
// your option) any later version.
32
//
33
// This program is distributed in the hope that it will be useful, but WITHOUT
34
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
35
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
36
// for more details.
37
//
38
// You should have received a copy of the GNU General Public License along
39 50 dgisselq
// with this program.  (It's in the $(ROOT)/doc directory.  Run make with no
40 36 dgisselq
// target there if the PDF file isn't present.)  If not, see
41
// <http://www.gnu.org/licenses/> for a copy.
42
//
43
// License:     GPL, v3, as defined and found on www.gnu.org,
44
//              http://www.gnu.org/licenses/gpl.html
45
//
46
//
47
////////////////////////////////////////////////////////////////////////////////
48
//
49
//
50
module wbgpio(i_clk, i_wb_cyc, i_wb_stb, i_wb_we, i_wb_data, o_wb_data,
51
                i_gpio, o_gpio, o_int);
52
        parameter       NIN=16, NOUT=16, DEFAULT=16'h00;
53
        input                   i_clk;
54
        //
55
        input                   i_wb_cyc, i_wb_stb, i_wb_we;
56
        input           [31:0]   i_wb_data;
57
        output  wire    [31:0]   o_wb_data;
58
        //
59
        input           [(NIN-1):0]      i_gpio;
60
        output  reg     [(NOUT-1):0]     o_gpio;
61
        //
62
        output  reg             o_int;
63
 
64
        // 9LUT's, 16 FF's
65
        always @(posedge i_clk)
66
                if ((i_wb_stb)&&(i_wb_we))
67
                        o_gpio <= ((o_gpio)&(~i_wb_data[(NOUT+16-1):16]))
68
                                |((i_wb_data[(NOUT-1):0])&(i_wb_data[(NOUT+16-1):16]));
69
 
70 50 dgisselq
        reg     [(NIN-1):0]      x_gpio, q_gpio, r_gpio;
71 36 dgisselq
        // 3 LUTs, 33 FF's
72
        always @(posedge i_clk)
73
        begin
74
                x_gpio <= i_gpio;
75 50 dgisselq
                q_gpio <= x_gpio;
76
                r_gpio <= q_gpio;
77 36 dgisselq
                o_int  <= (x_gpio != r_gpio);
78
        end
79
 
80
        assign  o_wb_data = { {(16-NIN){1'b0}}, r_gpio,
81
                                        {(16-NOUT){1'b0}}, o_gpio };
82
endmodule

powered by: WebSVN 2.1.0

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