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

Subversion Repositories s6soc

[/] [s6soc/] [trunk/] [rtl/] [spio.v] - Blame information for rev 30

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

Line No. Rev Author Line
1 7 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    spio.v
4
//
5
// Project:     CMod S6 System on a Chip, ZipCPU demonstration project
6
//
7
// Purpose:     
8
//
9 8 dgisselq
//      With the USB cord on top, the board facing you, LED[0] is on the left.
10
//
11 7 dgisselq
// Creator:     Dan Gisselquist, Ph.D.
12
//              Gisselquist Technology, LLC
13
//
14
////////////////////////////////////////////////////////////////////////////////
15
//
16
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
17
//
18
// This program is free software (firmware): you can redistribute it and/or
19
// modify it under the terms of  the GNU General Public License as published
20
// by the Free Software Foundation, either version 3 of the License, or (at
21
// your option) any later version.
22
//
23
// This program is distributed in the hope that it will be useful, but WITHOUT
24
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
25
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
26
// for more details.
27
//
28
// You should have received a copy of the GNU General Public License along
29
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
30
// target there if the PDF file isn't present.)  If not, see
31
// <http://www.gnu.org/licenses/> for a copy.
32
//
33
// License:     GPL, v3, as defined and found on www.gnu.org,
34
//              http://www.gnu.org/licenses/gpl.html
35
//
36
//
37
////////////////////////////////////////////////////////////////////////////////
38
//
39
//
40
 
41 2 dgisselq
module  spio(i_clk, i_wb_cyc, i_wb_stb, i_wb_we, i_wb_data, o_wb_data,
42
        o_kp_col, i_kp_row, i_btn, o_led,
43
        o_kp_int, o_btn_int);
44
        //
45
        input                   i_clk;
46
        //
47
        input                   i_wb_cyc, i_wb_stb, i_wb_we;
48
        input           [31:0]   i_wb_data;
49
        output  wire    [31:0]   o_wb_data;
50
        //
51
        output  reg     [3:0]    o_kp_col;
52
        input           [3:0]    i_kp_row;
53
        input           [1:0]    i_btn;
54
        output  reg     [3:0]    o_led;
55
        output  reg             o_kp_int, o_btn_int;
56
 
57
        initial o_kp_col = 4'h0;
58
        initial o_led    = 4'h0;
59
        always @(posedge i_clk)
60
                if ((i_wb_cyc)&&(i_wb_stb)&&(i_wb_we))
61
                begin
62
                        o_kp_col <= ((o_kp_col)&(~i_wb_data[11:8]))
63
                                        |((i_wb_data[15:12])&(i_wb_data[11:8]));
64
                        // o_led <= ((o_led)&(~i_wb_data[7:4]))
65
                                        // |((i_wb_data[3:0])&(i_wb_data[7:4]));
66
                        o_led[0] <= (i_wb_data[4])?i_wb_data[0]:o_led[0];
67
                        o_led[1] <= (i_wb_data[5])?i_wb_data[1]:o_led[1];
68
                        o_led[2] <= (i_wb_data[6])?i_wb_data[2]:o_led[2];
69
                        o_led[3] <= (i_wb_data[7])?i_wb_data[3]:o_led[3];
70
                end
71
 
72
        reg     [3:0]    x_kp_row, r_kp_row;
73
        reg     [1:0]    x_btn, r_btn;
74
 
75
        always @(posedge i_clk)
76
        begin
77
                x_kp_row <= i_kp_row;
78
                x_btn    <= i_btn;
79
                r_kp_row <= x_kp_row;
80
                r_btn    <= x_btn;
81
                o_kp_int <= ~(&r_kp_row);
82
                o_btn_int <= |(r_btn);
83
        end
84
 
85
        assign  o_wb_data = { 16'h00, o_kp_col, r_kp_row, 2'b00, r_btn, o_led };
86
 
87
endmodule

powered by: WebSVN 2.1.0

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