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/] [or1200/] [rtl/] [verilog/] [or1200_sb_fifo.v] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 xianfeng
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's Store Buffer FIFO                                  ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Implementation of store buffer FIFO.                        ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   - N/A                                                      ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Damjan Lampret, lampret@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2002 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
//
44
// CVS Revision History
45
//
46
// $Log: or1200_sb_fifo.v,v $
47
// Revision 1.3  2002/11/06 13:53:41  simons
48
// SB mem width fixed.
49
//
50
// Revision 1.2  2002/08/22 02:18:55  lampret
51
// Store buffer has been tested and it works. BY default it is still disabled until uClinux confirms correct operation on FPGA board.
52
//
53
// Revision 1.1  2002/08/18 19:53:08  lampret
54
// Added store buffer.
55
//
56
//
57
 
58
// synopsys translate_off
59
`include "timescale.v"
60
// synopsys translate_on
61
`include "or1200_defines.v"
62
 
63
module or1200_sb_fifo(
64
        clk_i, rst_i, dat_i, wr_i, rd_i, dat_o, full_o, empty_o
65
);
66
 
67
parameter dw = 68;
68
parameter fw = `OR1200_SB_LOG;
69
parameter fl = `OR1200_SB_ENTRIES;
70
 
71
//
72
// FIFO signals
73
//
74
input                   clk_i;  // Clock
75
input                   rst_i;  // Reset
76
input   [dw-1:0] dat_i;  // Input data bus
77
input                   wr_i;   // Write request
78
input                   rd_i;   // Read request
79
output [dw-1:0]  dat_o;  // Output data bus
80
output                  full_o; // FIFO full
81
output                  empty_o;// FIFO empty
82
 
83
//
84
// Internal regs
85
//
86
reg     [dw-1:0] mem [fl-1:0];
87
reg     [dw-1:0] dat_o;
88
reg     [fw+1:0] cntr;
89
reg     [fw-1:0] wr_pntr;
90
reg     [fw-1:0] rd_pntr;
91
reg                     empty_o;
92
reg                     full_o;
93
 
94
always @(posedge clk_i or posedge rst_i)
95
        if (rst_i) begin
96
                full_o <= #1 1'b0;
97
                empty_o <= #1 1'b1;
98
                wr_pntr <= #1 {fw{1'b0}};
99
                rd_pntr <= #1 {fw{1'b0}};
100
                cntr <= #1 {fw+2{1'b0}};
101
                dat_o <= #1 {dw{1'b0}};
102
        end
103
        else if (wr_i && rd_i) begin            // FIFO Read and Write
104
                mem[wr_pntr] <= #1 dat_i;
105
                if (wr_pntr >= fl-1)
106
                        wr_pntr <= #1 {fw{1'b0}};
107
                else
108
                        wr_pntr <= #1 wr_pntr + 1'b1;
109
                if (empty_o) begin
110
                        dat_o <= #1 dat_i;
111
                end
112
                else begin
113
                        dat_o <= #1 mem[rd_pntr];
114
                end
115
                if (rd_pntr >= fl-1)
116
                        rd_pntr <= #1 {fw{1'b0}};
117
                else
118
                        rd_pntr <= #1 rd_pntr + 1'b1;
119
        end
120
        else if (wr_i && !full_o) begin         // FIFO Write
121
                mem[wr_pntr] <= #1 dat_i;
122
                cntr <= #1 cntr + 1'b1;
123
                empty_o <= #1 1'b0;
124
                if (cntr >= (fl-1)) begin
125
                        full_o <= #1 1'b1;
126
                        cntr <= #1 fl;
127
                end
128
                if (wr_pntr >= fl-1)
129
                        wr_pntr <= #1 {fw{1'b0}};
130
                else
131
                        wr_pntr <= #1 wr_pntr + 1'b1;
132
        end
133
        else if (rd_i && !empty_o) begin        // FIFO Read
134
                dat_o <= #1 mem[rd_pntr];
135
                cntr <= #1 cntr - 1'b1;
136
                full_o <= #1 1'b0;
137
                if (cntr <= 1) begin
138
                        empty_o <= #1 1'b1;
139
                        cntr <= #1 {fw+2{1'b0}};
140
                end
141
                if (rd_pntr >= fl-1)
142
                        rd_pntr <= #1 {fw{1'b0}};
143
                else
144
                        rd_pntr <= #1 rd_pntr + 1'b1;
145
        end
146
 
147
endmodule

powered by: WebSVN 2.1.0

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