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

Subversion Repositories oms8051mini

[/] [oms8051mini/] [trunk/] [rtl/] [spi/] [spi_core.v] - Blame information for rev 18

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

Line No. Rev Author Line
1 2 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OMS 8051 cores SPI Interface Module                         ////
4
////                                                              ////
5
////  This file is part of the OMS 8051 cores project             ////
6
////  http://www.opencores.org/cores/oms8051/                     ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  OMS 8051 definitions.                                       ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////    nothing                                                   ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Dinesh Annayya, dinesha@opencores.org                 ////
16
////                                                              ////
17
////  Revision : Nov 26, 2016                                      //// 
18
////                                                              ////
19
//////////////////////////////////////////////////////////////////////
20
////                                                              ////
21
//// Copyright (C) 2000 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
module spi_core (
46
 
47 11 dinesha
               clk                  ,
48
               reset_n              ,
49 2 dinesha
 
50
        // Reg Bus Interface Signal
51 11 dinesha
               reg_cs               ,
52
               reg_wr               ,
53
               reg_addr             ,
54
               reg_wdata            ,
55
               reg_be               ,
56 2 dinesha
 
57
            // Outputs
58 11 dinesha
               reg_rdata            ,
59
               reg_ack              ,
60 2 dinesha
 
61
          // line interface
62 11 dinesha
               sck                  ,
63
               so                   ,
64
               si                   ,
65 2 dinesha
               cs_n
66 11 dinesha
           );
67 2 dinesha
 
68 11 dinesha
 
69 2 dinesha
 
70
input               clk                           ;
71
input               reset_n                       ;
72
 
73
 
74
//---------------------------------
75
// Reg Bus Interface Signal
76
//---------------------------------
77
input               reg_cs                        ;
78
input               reg_wr                        ;
79
input [3:0]         reg_addr                      ;
80 11 dinesha
input [7:0]         reg_wdata                     ;
81
input               reg_be                        ;
82 2 dinesha
 
83
// Outputs
84 11 dinesha
output [7:0]        reg_rdata                     ;
85 2 dinesha
output              reg_ack                       ;
86
 
87
//-------------------------------------------
88
// Line Interface
89
//-------------------------------------------
90
 
91
output              sck                           ; // clock out
92
output              so                            ; // serial data out
93
input               si                            ; // serial data in
94
output [3:0]        cs_n                          ; // cs_n
95
 
96
//------------------------------------
97
// Wires
98
//------------------------------------
99
 
100
wire [7:0]          byte_in                       ;
101
wire [7:0]          byte_out                      ;
102
 
103
 
104
wire  [1:0]         cfg_tgt_sel                   ;
105
 
106
wire                cfg_op_req                    ; // SPI operation request
107
wire  [1:0]         cfg_op_type                   ; // SPI operation type
108
wire  [1:0]         cfg_transfer_size             ; // SPI transfer size
109
wire  [5:0]         cfg_sck_period                ; // sck clock period
110
wire  [4:0]         cfg_sck_cs_period             ; // cs setup/hold period
111
wire  [7:0]         cfg_cs_byte                   ; // cs bit information
112
wire  [31:0]        cfg_datain                    ; // data for transfer
113
wire  [31:0]        cfg_dataout                   ; // data for received
114
wire                hware_op_done                 ; // operation done
115
 
116 11 dinesha
spi_if  u_spi_if (
117 2 dinesha
          . clk                         (clk                          ),
118
          . reset_n                     (reset_n                      ),
119
 
120
           // towards ctrl i/f
121
          . sck_pe                      (sck_pe                       ),
122
          . sck_int                     (sck_int                      ),
123
          . cs_int_n                    (cs_int_n                     ),
124
          . byte_in                     (byte_in                      ),
125
          . load_byte                   (load_byte                    ),
126
          . byte_out                    (byte_out                     ),
127
          . shift_out                   (shift_out                    ),
128
          . shift_in                    (shift_in                     ),
129
 
130
          . cfg_tgt_sel                 (cfg_tgt_sel                  ),
131
 
132
          . sck                         (sck                          ),
133
          . so                          (so                           ),
134
          . si                          (si                           ),
135
          . cs_n                        (cs_n                         )
136 11 dinesha
 
137 2 dinesha
           );
138
 
139
 
140
spi_ctl  u_spi_ctrl
141
       (
142
          . clk                         (clk                          ),
143
          . reset_n                     (reset_n                      ),
144
 
145
          . cfg_op_req                  (cfg_op_req                   ),
146
          . cfg_op_type                 (cfg_op_type                  ),
147
          . cfg_transfer_size           (cfg_transfer_size            ),
148
          . cfg_sck_period              (cfg_sck_period               ),
149
          . cfg_sck_cs_period           (cfg_sck_cs_period            ),
150
          . cfg_cs_byte                 (cfg_cs_byte                  ),
151
          . cfg_datain                  (cfg_datain                   ),
152
          . cfg_dataout                 (cfg_dataout                  ),
153
          . op_done                     (hware_op_done                ),
154
 
155
          . sck_int                     (sck_int                      ),
156
          . cs_int_n                    (cs_int_n                     ),
157
          . sck_pe                      (sck_pe                       ),
158
          . sck_ne                      (sck_ne                       ),
159
          . shift_out                   (shift_out                    ),
160
          . shift_in                    (shift_in                     ),
161
          . load_byte                   (load_byte                    ),
162
          . byte_out                    (byte_out                     ),
163
          . byte_in                     (byte_in                      )
164
 
165
         );
166
 
167
 
168
 
169
 
170
spi_cfg u_cfg (
171
 
172
          . mclk                        (clk                          ),
173
          . reset_n                     (reset_n                      ),
174
 
175
        // Reg Bus Interface Signal
176
          . reg_cs                      (reg_cs                       ),
177
          . reg_wr                      (reg_wr                       ),
178
          . reg_addr                    (reg_addr                     ),
179
          . reg_wdata                   (reg_wdata                    ),
180
          . reg_be                      (reg_be                       ),
181
 
182
            // Outputs
183
          . reg_rdata                   (reg_rdata                    ),
184
          . reg_ack                     (reg_ack                      ),
185
 
186
 
187
           // configuration signal
188
          . cfg_tgt_sel                 (cfg_tgt_sel                  ),
189
          . cfg_op_req                  (cfg_op_req                   ), // SPI operation request
190
          . cfg_op_type                 (cfg_op_type                  ), // SPI operation type
191
          . cfg_transfer_size           (cfg_transfer_size            ), // SPI transfer size
192
          . cfg_sck_period              (cfg_sck_period               ), // sck clock period
193
          . cfg_sck_cs_period           (cfg_sck_cs_period            ), // cs setup/hold period
194
          . cfg_cs_byte                 (cfg_cs_byte                  ), // cs bit information
195
          . cfg_datain                  (cfg_datain                   ), // data for transfer
196
          . cfg_dataout                 (cfg_dataout                  ), // data for received
197
          . hware_op_done               (hware_op_done                )  // operation done
198
 
199
        );
200
 
201
endmodule

powered by: WebSVN 2.1.0

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