OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [or1200/] [or1200_sb_fifo.v] - Blame information for rev 360

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 350 julius
//////////////////////////////////////////////////////////////////////
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 2.0  2010/06/30 11:00:00  ORSoC
48
// No update 
49
//
50
// Revision 1.3  2002/11/06 13:53:41  simons
51
// SB mem width fixed.
52
//
53
// Revision 1.2  2002/08/22 02:18:55  lampret
54
// Store buffer has been tested and it works. BY default it is still disabled until uClinux confirms correct operation on FPGA board.
55
//
56
// Revision 1.1  2002/08/18 19:53:08  lampret
57
// Added store buffer.
58
//
59
//
60
 
61
// synopsys translate_off
62
`include "timescale.v"
63
// synopsys translate_on
64
`include "or1200_defines.v"
65
 
66
module or1200_sb_fifo(
67
        clk_i, rst_i, dat_i, wr_i, rd_i, dat_o, full_o, empty_o
68
);
69
 
70
parameter dw = 68;
71
parameter fw = `OR1200_SB_LOG;
72
parameter fl = `OR1200_SB_ENTRIES;
73
 
74
//
75
// FIFO signals
76
//
77
input                   clk_i;  // Clock
78
input                   rst_i;  // Reset
79
input   [dw-1:0] dat_i;  // Input data bus
80
input                   wr_i;   // Write request
81
input                   rd_i;   // Read request
82
output [dw-1:0]  dat_o;  // Output data bus
83
output                  full_o; // FIFO full
84
output                  empty_o;// FIFO empty
85
 
86
//
87
// Internal regs
88
//
89
reg     [dw-1:0] mem [fl-1:0];
90
reg     [dw-1:0] dat_o;
91
reg     [fw+1:0] cntr;
92
reg     [fw-1:0] wr_pntr;
93
reg     [fw-1:0] rd_pntr;
94
reg                     empty_o;
95
reg                     full_o;
96
 
97 358 julius
always @(posedge clk_i or `OR1200_RST_EVENT rst_i)
98
        if (rst_i == `OR1200_RST_VALUE) begin
99 350 julius
                full_o <=  1'b0;
100
                empty_o <=  1'b1;
101
                wr_pntr <=  {fw{1'b0}};
102
                rd_pntr <=  {fw{1'b0}};
103
                cntr <=  {fw+2{1'b0}};
104
                dat_o <=  {dw{1'b0}};
105
        end
106
        else if (wr_i && rd_i) begin            // FIFO Read and Write
107
                mem[wr_pntr] <=  dat_i;
108
                if (wr_pntr >= fl-1)
109
                        wr_pntr <=  {fw{1'b0}};
110
                else
111
                        wr_pntr <=  wr_pntr + 1'b1;
112
                if (empty_o) begin
113
                        dat_o <=  dat_i;
114
                end
115
                else begin
116
                        dat_o <=  mem[rd_pntr];
117
                end
118
                if (rd_pntr >= fl-1)
119
                        rd_pntr <=  {fw{1'b0}};
120
                else
121
                        rd_pntr <=  rd_pntr + 1'b1;
122
        end
123
        else if (wr_i && !full_o) begin         // FIFO Write
124
                mem[wr_pntr] <=  dat_i;
125
                cntr <=  cntr + 1'b1;
126
                empty_o <=  1'b0;
127
                if (cntr >= (fl-1)) begin
128
                        full_o <=  1'b1;
129
                        cntr <=  fl;
130
                end
131
                if (wr_pntr >= fl-1)
132
                        wr_pntr <=  {fw{1'b0}};
133
                else
134
                        wr_pntr <=  wr_pntr + 1'b1;
135
        end
136
        else if (rd_i && !empty_o) begin        // FIFO Read
137
                dat_o <=  mem[rd_pntr];
138
                cntr <=  cntr - 1'b1;
139
                full_o <=  1'b0;
140
                if (cntr <= 1) begin
141
                        empty_o <=  1'b1;
142
                        cntr <=  {fw+2{1'b0}};
143
                end
144
                if (rd_pntr >= fl-1)
145
                        rd_pntr <=  {fw{1'b0}};
146
                else
147
                        rd_pntr <=  rd_pntr + 1'b1;
148
        end
149
 
150
endmodule

powered by: WebSVN 2.1.0

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