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

Subversion Repositories uart2spi

[/] [uart2spi/] [trunk/] [rtl/] [spi/] [spi_core.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Tubo 8051 cores SPI Interface Module                        ////
4
////                                                              ////
5
////  This file is part of the Turbo 8051 cores project           ////
6
////  http://www.opencores.org/cores/turbo8051/                   ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Turbo 8051 definitions.                                     ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////    nothing                                                   ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Dinesh Annayya, dinesha@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
module spi_core (
44
 
45
               clk,
46
               reset_n,
47
 
48
        // Reg Bus Interface Signal
49
             reg_cs,
50
             reg_wr,
51
             reg_addr,
52
             reg_wdata,
53
             reg_be,
54
 
55
            // Outputs
56
            reg_rdata,
57
            reg_ack,
58
 
59
          // line interface
60
               sck                ,
61
               so                 ,
62
               si                 ,
63
               cs_n
64
 
65
           );
66
 
67
input               clk                           ;
68
input               reset_n                       ;
69
 
70
 
71
//---------------------------------
72
// Reg Bus Interface Signal
73
//---------------------------------
74
input               reg_cs                        ;
75
input               reg_wr                        ;
76
input [3:0]         reg_addr                      ;
77
input [31:0]        reg_wdata                     ;
78
input [3:0]         reg_be                        ;
79
 
80
// Outputs
81
output [31:0]       reg_rdata                     ;
82
output              reg_ack                       ;
83
 
84
//-------------------------------------------
85
// Line Interface
86
//-------------------------------------------
87
 
88
output              sck                           ; // clock out
89
output              so                            ; // serial data out
90
input               si                            ; // serial data in
91
output [3:0]        cs_n                          ; // cs_n
92
 
93
//------------------------------------
94
// Wires
95
//------------------------------------
96
 
97
wire [7:0]          byte_in                       ;
98
wire [7:0]          byte_out                      ;
99
 
100
 
101
wire  [1:0]         cfg_tgt_sel                   ;
102
 
103
wire                cfg_op_req                    ; // SPI operation request
104
wire  [1:0]         cfg_op_type                   ; // SPI operation type
105
wire  [1:0]         cfg_transfer_size             ; // SPI transfer size
106
wire  [5:0]         cfg_sck_period                ; // sck clock period
107
wire  [4:0]         cfg_sck_cs_period             ; // cs setup/hold period
108
wire  [7:0]         cfg_cs_byte                   ; // cs bit information
109
wire  [31:0]        cfg_datain                    ; // data for transfer
110
wire  [31:0]        cfg_dataout                   ; // data for received
111
wire                hware_op_done                 ; // operation done
112
 
113
spi_if  u_spi_if
114
          (
115
          . clk                         (clk                          ),
116
          . reset_n                     (reset_n                      ),
117
 
118
           // towards ctrl i/f
119
          . sck_pe                      (sck_pe                       ),
120
          . sck_int                     (sck_int                      ),
121
          . cs_int_n                    (cs_int_n                     ),
122
          . byte_in                     (byte_in                      ),
123
          . load_byte                   (load_byte                    ),
124
          . byte_out                    (byte_out                     ),
125
          . shift_out                   (shift_out                    ),
126
          . shift_in                    (shift_in                     ),
127
 
128
          . cfg_tgt_sel                 (cfg_tgt_sel                  ),
129
 
130
          . sck                         (sck                          ),
131
          . so                          (so                           ),
132
          . si                          (si                           ),
133
          . cs_n                        (cs_n                         )
134
           );
135
 
136
 
137
spi_ctl  u_spi_ctrl
138
       (
139
          . clk                         (clk                          ),
140
          . reset_n                     (reset_n                      ),
141
 
142
          . cfg_op_req                  (cfg_op_req                   ),
143
          . cfg_op_type                 (cfg_op_type                  ),
144
          . cfg_transfer_size           (cfg_transfer_size            ),
145
          . cfg_sck_period              (cfg_sck_period               ),
146
          . cfg_sck_cs_period           (cfg_sck_cs_period            ),
147
          . cfg_cs_byte                 (cfg_cs_byte                  ),
148
          . cfg_datain                  (cfg_datain                   ),
149
          . cfg_dataout                 (cfg_dataout                  ),
150
          . op_done                     (hware_op_done                ),
151
 
152
          . sck_int                     (sck_int                      ),
153
          . cs_int_n                    (cs_int_n                     ),
154
          . sck_pe                      (sck_pe                       ),
155
          . sck_ne                      (sck_ne                       ),
156
          . shift_out                   (shift_out                    ),
157
          . shift_in                    (shift_in                     ),
158
          . load_byte                   (load_byte                    ),
159
          . byte_out                    (byte_out                     ),
160
          . byte_in                     (byte_in                      )
161
 
162
         );
163
 
164
 
165
 
166
 
167
spi_cfg u_cfg (
168
 
169
          . mclk                        (clk                          ),
170
          . reset_n                     (reset_n                      ),
171
 
172
        // Reg Bus Interface Signal
173
          . reg_cs                      (reg_cs                       ),
174
          . reg_wr                      (reg_wr                       ),
175
          . reg_addr                    (reg_addr                     ),
176
          . reg_wdata                   (reg_wdata                    ),
177
          . reg_be                      (reg_be                       ),
178
 
179
            // Outputs
180
          . reg_rdata                   (reg_rdata                    ),
181
          . reg_ack                     (reg_ack                      ),
182
 
183
 
184
           // configuration signal
185
          . cfg_tgt_sel                 (cfg_tgt_sel                  ),
186
          . cfg_op_req                  (cfg_op_req                   ), // SPI operation request
187
          . cfg_op_type                 (cfg_op_type                  ), // SPI operation type
188
          . cfg_transfer_size           (cfg_transfer_size            ), // SPI transfer size
189
          . cfg_sck_period              (cfg_sck_period               ), // sck clock period
190
          . cfg_sck_cs_period           (cfg_sck_cs_period            ), // cs setup/hold period
191
          . cfg_cs_byte                 (cfg_cs_byte                  ), // cs bit information
192
          . cfg_datain                  (cfg_datain                   ), // data for transfer
193
          . cfg_dataout                 (cfg_dataout                  ), // data for received
194
          . hware_op_done               (hware_op_done                )  // operation done
195
 
196
        );
197
 
198
endmodule

powered by: WebSVN 2.1.0

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