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

Subversion Repositories or1k

[/] [or1k/] [branches/] [mp3_stable/] [mp3/] [rtl/] [verilog/] [mem_if/] [flash_top.v] - Blame information for rev 1781

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

Line No. Rev Author Line
1 266 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  MP3 demo Flash interface                                    ////
4
////                                                              ////
5
////  This file is part of the MP3 demo application               ////
6
////  http://www.opencores.org/cores/or1k/mp3/                    ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Connects MP3 demo tp Flash found on XSV board.              ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   - nothing really                                           ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Lior Shtram, lior.shtram@flextronicssemi.com          ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2001 Authors                                   ////
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
// CVS Revision History
45
//
46
// $Log: not supported by cvs2svn $
47
//
48
 
49
// synopsys translate_off
50
`include "timescale.v"
51
// synopsys translate_on
52
 
53
module flash_top (
54
  clk, rstn,
55
 
56
  wb_dat_i, wb_dat_o, wb_adr_i, wb_sel_i, wb_we_i, wb_cyc_i,
57
  wb_stb_i, wb_ack_o, wb_err_o,
58
 
59
  flash_rstn, cen, oen, wen, rdy, d, a, a_oe
60
);
61
 
62
input   clk;
63
input   rstn;
64
 
65
input [31:0]  wb_dat_i;
66
output [31:0] wb_dat_o;
67
input [31:0]  wb_adr_i;
68
input [3:0] wb_sel_i;
69
input   wb_we_i;
70
input   wb_cyc_i;
71
input   wb_stb_i;
72
output    wb_ack_o;
73
output    wb_err_o;
74
 
75
output    flash_rstn;
76
output    oen;
77
output    cen;
78
output    wen;
79
input   rdy;
80
inout [7:0] d;
81
output [20:0] a;
82
output  a_oe;
83
 
84
reg [4:0] counter;
85
reg [31:0]  data_sr;
86
reg   f_ack;
87
reg [3:0] middle_tphqv;
88
 
89
always @(posedge clk or negedge rstn)
90
begin
91
  if(!rstn)
92
    counter <= 5'h0;
93
  else
94
  if(!wb_cyc_i | (counter == 5'h10) | (|middle_tphqv))
95
    counter <= #1 5'h0;
96
  else
97
    counter <= #1 counter + 1;
98
end
99
 
100
 
101
always @(posedge clk or negedge rstn)
102
begin
103
  if(!rstn)
104
    f_ack <= 1'h0;
105
  else
106
  if(counter == 5'h0f && !(|middle_tphqv))
107
    f_ack <= #1 1'h1;
108
  else
109
    f_ack <= #1 1'h0;
110
end
111
 
112
 
113
assign wb_ack_o = f_ack;
114
 
115
assign flash_rstn = rstn;
116
assign a = { ~wb_adr_i[20], wb_adr_i[19:2], counter[3:2] };
117
assign a_oe = (wb_cyc_i &! (|middle_tphqv));
118
assign wb_dat_o = data_sr;
119
assign oen = |middle_tphqv;
120
assign wen = 1'b1;
121
/* SIMON */
122
//assign cen = |middle_tphqv | (counter[1:0] == 2'b01);
123
assign cen = |middle_tphqv | (counter[1:0] == 2'b01) | (counter[4:0] == 5'b0);
124
assign wb_err_o = 1'b0;
125
 
126
 
127
// synopsys translate_off
128
integer fflash;
129
initial fflash = $fopen("flash.log");
130
always @(posedge clk)
131
        if (wb_cyc_i & !(|middle_tphqv)) begin // wb_ack_o should be qualified with wb_stb_i as well however OR1200 doesn't do this currently
132
                if (wb_stb_i & wb_we_i) begin
133
//      $fdisplay(fflash, "%t Trying to write into flash at %h", $time, wb_adr_i);
134
//      #100 $finish;
135
                end else if (wb_ack_o)
136
                        $fdisplay(fflash, "%t [%h] -> read %h", $time, wb_adr_i, wb_dat_o);
137
        end
138
// synopsys translate_on
139
 
140
always @(posedge clk or negedge rstn)
141
        if (!rstn)
142
                middle_tphqv <= #1 4'hf;
143
        else if (middle_tphqv)
144
                middle_tphqv <= #1 middle_tphqv - 1;
145
 
146
always @(posedge clk or negedge rstn)
147
begin
148
  if (!rstn) data_sr <= 32'b0;
149
  else
150
  if (counter[1:0] == 2'h3)
151
    begin
152
      case (counter[3:2])
153
        2'h0 : data_sr[31:24] <= #1 d;
154
        2'h1 : data_sr[23:16] <= #1 d;
155
        2'h2 : data_sr[15:8]  <= #1 d;
156
        2'h3 : data_sr[7:0]   <= #1 d;
157
        default : data_sr <= 32'bx;
158
      endcase
159
    end
160
end
161
 
162
endmodule

powered by: WebSVN 2.1.0

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