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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_5/] [or1200/] [rtl/] [verilog/] [or1200_sb_fifo.v] - Blame information for rev 1056

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

Line No. Rev Author Line
1 977 lampret
//////////////////////////////////////////////////////////////////////
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: not supported by cvs2svn $
47 994 lampret
// Revision 1.1  2002/08/18 19:53:08  lampret
48
// Added store buffer.
49 977 lampret
//
50 994 lampret
//
51 977 lampret
 
52
// synopsys translate_off
53
`include "timescale.v"
54
// synopsys translate_on
55
`include "or1200_defines.v"
56
 
57
module or1200_sb_fifo(
58
        clk_i, rst_i, dat_i, wr_i, rd_i, dat_o, full_o, empty_o
59
);
60
 
61 994 lampret
parameter dw = 68;
62
parameter fw = `OR1200_SB_LOG;
63
parameter fl = `OR1200_SB_ENTRIES;
64 977 lampret
 
65
//
66
// FIFO signals
67
//
68
input                   clk_i;  // Clock
69
input                   rst_i;  // Reset
70
input   [dw-1:0] dat_i;  // Input data bus
71
input                   wr_i;   // Write request
72
input                   rd_i;   // Read request
73
output                  dat_o;  // Output data bus
74
output                  full_o; // FIFO full
75
output                  empty_o;// FIFO empty
76
 
77
//
78
// Internal regs
79
//
80
reg     [dw:0]           mem [fl-1:0];
81
reg     [dw-1:0] dat_o;
82
reg     [fw+1:0] cntr;
83
reg     [fw-1:0] wr_pntr;
84
reg     [fw-1:0] rd_pntr;
85
reg                     empty_o;
86
reg                     full_o;
87
 
88
always @(posedge clk_i or posedge rst_i)
89
        if (rst_i) begin
90
                full_o <= #1 1'b0;
91
                empty_o <= #1 1'b1;
92
                wr_pntr <= #1 {fw{1'b0}};
93
                rd_pntr <= #1 {fw{1'b0}};
94
                cntr <= #1 {fw+2{1'b0}};
95
                dat_o <= #1 {dw{1'b0}};
96
        end
97 994 lampret
        else if (wr_i && rd_i) begin            // FIFO Read and Write
98 977 lampret
                mem[wr_pntr] <= #1 dat_i;
99
                if (wr_pntr >= fl-1)
100
                        wr_pntr <= #1 {fw{1'b0}};
101
                else
102
                        wr_pntr <= #1 wr_pntr + 1'b1;
103 994 lampret
                if (empty_o) begin
104 977 lampret
                        dat_o <= #1 dat_i;
105 994 lampret
                end
106
                else begin
107 977 lampret
                        dat_o <= #1 mem[rd_pntr];
108 994 lampret
                end
109 977 lampret
                if (rd_pntr >= fl-1)
110
                        rd_pntr <= #1 {fw{1'b0}};
111
                else
112
                        rd_pntr <= #1 rd_pntr + 1'b1;
113
        end
114
        else if (wr_i && !full_o) begin         // FIFO Write
115
                mem[wr_pntr] <= #1 dat_i;
116
                cntr <= #1 cntr + 1'b1;
117
                empty_o <= #1 1'b0;
118 994 lampret
                if (cntr >= (fl-1)) begin
119 977 lampret
                        full_o <= #1 1'b1;
120
                        cntr <= #1 fl;
121
                end
122
                if (wr_pntr >= fl-1)
123
                        wr_pntr <= #1 {fw{1'b0}};
124
                else
125
                        wr_pntr <= #1 wr_pntr + 1'b1;
126
        end
127
        else if (rd_i && !empty_o) begin        // FIFO Read
128
                dat_o <= #1 mem[rd_pntr];
129
                cntr <= #1 cntr - 1'b1;
130
                full_o <= #1 1'b0;
131 994 lampret
                if (cntr <= 1) begin
132 977 lampret
                        empty_o <= #1 1'b1;
133
                        cntr <= #1 {fw+2{1'b0}};
134
                end
135
                if (rd_pntr >= fl-1)
136
                        rd_pntr <= #1 {fw{1'b0}};
137
                else
138
                        rd_pntr <= #1 rd_pntr + 1'b1;
139
        end
140
 
141
endmodule

powered by: WebSVN 2.1.0

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