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

Subversion Repositories or1k_soc_on_altera_embedded_dev_kit

[/] [or1k_soc_on_altera_embedded_dev_kit/] [trunk/] [soc/] [rtl/] [mmc_sd/] [RTL/] [spiMasterWishBoneBI.v] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 xianfeng
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// spiMasterWishBoneBI.v                                        ////
4
////                                                              ////
5
//// This file is part of the spiMaster opencores effort.
6
//// <http://www.opencores.org/cores//>                           ////
7
////                                                              ////
8
//// Module Description:                                          ////
9
////  Control WB access to fifos and control and status registers 
10
////                                                              ////
11
//// To Do:                                                       ////
12
//// 
13
////                                                              ////
14
//// Author(s):                                                   ////
15
//// - Steve Fielding, sfielding@base2designs.com                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2008 Steve Fielding 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
//
44
`include "timescale.v"
45
`include "spiMaster_defines.v"
46
 
47
 
48
module spiMasterWishBoneBI (
49
  clk, rst,
50
  address, dataIn, dataOut, writeEn,
51
  strobe_i,
52
  ack_o,
53
  ctrlStsRegSel,
54
  rxFifoSel, txFifoSel,
55
  dataFromCtrlStsReg,
56
  dataFromRxFifo,
57
  dataFromTxFifo
58
  );
59
input clk;
60
input rst;
61
input [7:0] address;
62
input [7:0] dataIn;
63
output [7:0] dataOut;
64
input strobe_i;
65
output ack_o;
66
input writeEn;
67
output ctrlStsRegSel;
68
output rxFifoSel;
69
output txFifoSel;
70
input [7:0] dataFromCtrlStsReg;
71
input [7:0] dataFromRxFifo;
72
input [7:0] dataFromTxFifo;
73
 
74
 
75
wire clk;
76
wire rst;
77
wire [7:0] address;
78
wire [7:0] dataIn;
79
reg [7:0] dataOut;
80
wire writeEn;
81
wire strobe_i;
82
reg ack_o;
83
reg ctrlStsRegSel;
84
reg rxFifoSel;
85
reg txFifoSel;
86
wire [7:0] dataFromCtrlStsReg;
87
wire [7:0] dataFromRxFifo;
88
wire [7:0] dataFromTxFifo;
89
 
90
//internal wires and regs
91
reg ack_delayed;
92
reg ack_immediate;
93
 
94
//address decode and data mux
95
always @(address or
96
  dataFromCtrlStsReg or
97
  dataFromRxFifo or
98
  dataFromTxFifo)
99
begin
100
  ctrlStsRegSel <= 1'b0;
101
  rxFifoSel <= 1'b0;
102
  txFifoSel <= 1'b0;
103
  case (address & `ADDRESS_DECODE_MASK)
104
    `CTRL_STS_REG_BASE : begin
105
      ctrlStsRegSel <= 1'b1;
106
      dataOut <= dataFromCtrlStsReg;
107
    end
108
    `RX_FIFO_BASE : begin
109
      rxFifoSel <= 1'b1;
110
      dataOut <= dataFromRxFifo;
111
    end
112
    `TX_FIFO_BASE : begin
113
      txFifoSel <= 1'b1;
114
      dataOut <= dataFromTxFifo;
115
    end
116
    default:
117
      dataOut <= 8'h00;
118
  endcase
119
end
120
 
121
//delayed ack
122
always @(posedge clk) begin
123
  ack_delayed <= strobe_i;
124
end
125
 
126
//immediate ack
127
always @(strobe_i) begin
128
  ack_immediate <= strobe_i;
129
end
130
 
131
//select between immediate and delayed ack
132
always @(writeEn or address or ack_delayed or ack_immediate) begin
133
  if (writeEn == 1'b0 &&
134
      (address == `RX_FIFO_BASE + `FIFO_DATA_REG ||
135
       address == `TX_FIFO_BASE + `FIFO_DATA_REG) )
136
  begin
137
    ack_o <= ack_delayed & ack_immediate;
138
  end
139
  else
140
  begin
141
    ack_o <= ack_immediate;
142
  end
143
end
144
 
145
endmodule

powered by: WebSVN 2.1.0

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