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

Subversion Repositories spislave

[/] [spislave/] [trunk/] [spislave/] [rtl/] [verilog/] [spigpio.v] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 siva12
////////////////////////////////////////////////////////////////// ////
2
////                                                              ////
3
//// SPI SLAVE IP Core                                            ////
4
////                                                              ////
5
//// This file is part of the spislave project                     ////
6
//// http://www.opencores.org/project,spislave                    ////
7
////                                                              ////
8
//// Description                                                  ////
9
//// Implementation of spislave IP core according to              ////
10
//// spislave IP core specification document.                     ////
11
////                                                              ////
12
//// To Do:                                                       ////
13
////   -                                                          ////
14
////                                                              ////
15
//// Author(s):                                                   ////
16 13 siva12
////      - Sivakumar.B , email: siva@zilogic.com                 ////
17 10 siva12
////                      email: siva12@opencores.org             ////
18
////        Engineer  Zilogic systems,chennai. www.zilogic.com    ////
19 13 siva12
////                                                              ////
20 5 siva12
//////////////////////////////////////////////////////////////////////
21
////                                                              ////
22 13 siva12
//// Copyright (C) 2009 Zilogic Systems and OPENCORES.ORG         ////
23 5 siva12
////                                                              ////
24
//// This source file may be used and distributed without         ////
25
//// restriction provided that this copyright statement is not    ////
26 13 siva12
//// removed from the file and that any derivative work contains  ////
27 5 siva12
//// the original copyright notice and the associated disclaimer. ////
28
////                                                              ////
29
//// This source file is free software; you can redistribute it   ////
30
//// and/or modify it under the terms of the GNU Lesser General   ////
31
//// Public License as published by the Free Software Foundation; ////
32
//// either version 2.1 of the License, or (at your option) any   ////
33
//// later version.                                               ////
34
////                                                              ////
35
//// This source is distributed in the hope that it will be       ////
36
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
37
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
38
//// PURPOSE. See the GNU Lesser General Public License for more ////
39
//// details.                                                     ////
40
////                                                              ////
41
//// You should have received a copy of the GNU Lesser General    ////
42
//// Public License along with this source; if not, download it   ////
43
//// from http://www.opencores.org/lgpl.shtml                     ////
44
////                                                              ////
45
//////////////////////////////////////////////////////////////////////
46
////       RTL program for SPI GPIO -- shift 8 bit register       ////  
47 4 siva12
 
48
`define         P0_P9_OP        8'b10101010 //0xAA
49
`define         P0_P3_OP        8'b11111111 //0xFF
50
`define         P4_P7_OP        8'b11111110 //0xFE
51
 
52
module spigpio(clk, cs, sr_in, gpioout, sr_out);
53
 
54
        input clk, cs;
55
        input sr_in;
56
        output sr_out;
57
        output [7:0] gpioout;
58
 
59
        reg [7:0] gpioout;
60
        reg sr_out;
61
 
62
        wire rw;
63
        reg [7:0] sr;
64
 
65
        assign rw = sr[7];
66
 
67
        always@(posedge clk )
68
        begin
69
                if (cs == 1'b0)
70
                begin
71
                        sr_out <= sr[7];
72
                        sr[7:1] <= sr[6:0];
73
                        sr[0] <= sr_in;
74
                end
75
 
76
                if (cs == 1'b1)
77
                begin
78
 
79
                        if (rw == 1'b1)
80
                        begin
81
 
82
                                case (sr)
83
                                `P0_P9_OP : gpioout[7:0] <= { sr[0], sr[1], sr[2], sr[3],
84
                                                              sr[4], sr[5], sr[6], sr[7]};
85
                                `P0_P3_OP : gpioout[3:0] <= {sr[0], sr[1], sr[2], sr[3]};
86
                                `P4_P7_OP : gpioout[7:4] <= { sr[4], sr[5], sr[6], sr[7]};
87
                                default   : gpioout[0] <= sr[0];
88
                                endcase
89
                        end
90
                end
91
        end
92
endmodule

powered by: WebSVN 2.1.0

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