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

Subversion Repositories openriscdevboard

[/] [openriscdevboard/] [trunk/] [cyc2-openrisc/] [rtl/] [spiMaster/] [spiTxRxData.v] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 sfielding
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// spiTxRxData.v                                                ////
4
////                                                              ////
5
//// This file is part of the spiMaster opencores effort.
6
//// <http://www.opencores.org/cores//>                           ////
7
////                                                              ////
8
//// Module Description:                                          ////
9
////  Mux access to SPI RX and TX data 
10
//// 
11
////  
12
//// 
13
////                                                              ////
14
//// To Do:                                                       ////
15
////   
16
////                                                              ////
17
//// Author(s):                                                   ////
18
//// - Steve Fielding, sfielding@base2designs.com                 ////
19
////                                                              ////
20
//////////////////////////////////////////////////////////////////////
21
////                                                              ////
22
//// Copyright (C) 2008 Steve Fielding and OPENCORES.ORG          ////
23
////                                                              ////
24
//// This source file may be used and distributed without         ////
25
//// restriction provided that this copyright statement is not    ////
26
//// removed from the file and that any derivative work contains  ////
27
//// 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
//`include "timescale.v"
47
 
48
module spiTxRxData (
49
  clk,
50
  rst,
51
 
52
  tx1DataIn,
53
  tx2DataIn,
54
  tx3DataIn,
55
  tx4DataIn,
56
  tx1DataWEn,
57
  tx2DataWEn,
58
  tx3DataWEn,
59
  tx4DataWEn,
60
 
61
  txDataOut,
62
  txDataFull,
63
  txDataFullClr,
64
 
65
  rx1DataRdyClr,
66
  rx2DataRdyClr,
67
  rx3DataRdyClr,
68
  rx4DataRdyClr,
69
 
70
  rxDataIn,
71
  rxDataOut,
72
  rxDataRdy,
73
  rxDataRdySet
74
);
75
 
76
input clk;
77
input rst;
78
 
79
input [7:0] tx1DataIn;
80
input [7:0] tx2DataIn;
81
input [7:0] tx3DataIn;
82
input [7:0] tx4DataIn;
83
input tx1DataWEn;
84
input tx2DataWEn;
85
input tx3DataWEn;
86
input tx4DataWEn;
87
 
88
output [7:0] txDataOut;
89
reg [7:0] txDataOut;
90
output txDataFull;
91
reg txDataFull;
92
input txDataFullClr;
93
 
94
input rx1DataRdyClr;
95
input rx2DataRdyClr;
96
input rx3DataRdyClr;
97
input rx4DataRdyClr;
98
 
99
input [7:0] rxDataIn;
100
output [7:0] rxDataOut;
101
reg [7:0] rxDataOut;
102
output rxDataRdy;
103
reg rxDataRdy;
104
input rxDataRdySet;
105
 
106
 
107
// --- Transmit control
108
always @(posedge clk) begin
109
  if (rst == 1'b1) begin
110
    txDataOut <= 8'h00;
111
    txDataFull <= 1'b0;
112
  end
113
  else begin
114
    if (tx1DataWEn == 1'b1) begin
115
      txDataOut <= tx1DataIn;
116
      txDataFull <= 1'b1;
117
    end
118
    else if (tx2DataWEn == 1'b1) begin
119
      txDataOut <= tx2DataIn;
120
      txDataFull <= 1'b1;
121
    end
122
    else if (tx3DataWEn == 1'b1) begin
123
      txDataOut <= tx3DataIn;
124
      txDataFull <= 1'b1;
125
    end
126
    else if (tx4DataWEn == 1'b1) begin
127
      txDataOut <= tx4DataIn;
128
      txDataFull <= 1'b1;
129
    end
130
    if (txDataFullClr == 1'b1)
131
      txDataFull <= 1'b0;
132
  end
133
end
134
 
135
// --- Receive control
136
always @(posedge clk) begin
137
  if (rst == 1'b1) begin
138
    rxDataOut <= 8'h00;
139
    rxDataRdy <= 1'b0;
140
  end
141
  else begin
142
    if (rx1DataRdyClr == 1'b1 || rx2DataRdyClr == 1'b1 || rx3DataRdyClr == 1'b1 || rx4DataRdyClr == 1'b1) begin
143
      rxDataRdy <= 1'b0;
144
    end
145
    if (rxDataRdySet == 1'b1) begin
146
      rxDataRdy <= 1'b1;
147
      rxDataOut <= rxDataIn;
148
    end
149
  end
150
end
151
 
152
endmodule
153
 

powered by: WebSVN 2.1.0

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