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

Subversion Repositories spislave

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

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

powered by: WebSVN 2.1.0

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