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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [orp/] [orp_soc/] [rtl/] [verilog/] [ssvga/] [ssvga_fifo.v] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 746 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Simple Small VGA IP Core                                    ////
4
////                                                              ////
5
////  This file is part of the Simple Small VGA project           ////
6
////                                                              ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  512 entry FIFO for storing line video data. It uses one     ////
10
////  clock for reading and writing.                              ////
11
////                                                              ////
12
////  To Do:                                                      ////
13
////   Nothing                                                    ////
14
////                                                              ////
15
////  Author(s):                                                  ////
16
////      - Damjan Lampret, lampret@opencores.org                 ////
17
////                                                              ////
18
//////////////////////////////////////////////////////////////////////
19
////                                                              ////
20
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
21
////                                                              ////
22
//// This source file may be used and distributed without         ////
23
//// restriction provided that this copyright statement is not    ////
24
//// removed from the file and that any derivative work contains  ////
25
//// the original copyright notice and the associated disclaimer. ////
26
////                                                              ////
27
//// This source file is free software; you can redistribute it   ////
28
//// and/or modify it under the terms of the GNU Lesser General   ////
29
//// Public License as published by the Free Software Foundation; ////
30
//// either version 2.1 of the License, or (at your option) any   ////
31
//// later version.                                               ////
32
////                                                              ////
33
//// This source is distributed in the hope that it will be       ////
34
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
35
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
36
//// PURPOSE.  See the GNU Lesser General Public License for more ////
37
//// details.                                                     ////
38
////                                                              ////
39
//// You should have received a copy of the GNU Lesser General    ////
40
//// Public License along with this source; if not, download it   ////
41
//// from http://www.opencores.org/lgpl.shtml                     ////
42
////                                                              ////
43
//////////////////////////////////////////////////////////////////////
44
//
45
// CVS Revision History
46
//
47
// $Log: not supported by cvs2svn $
48
// Revision 1.2  2002/02/01 15:24:46  mihad
49
// Repaired a few bugs, updated specification, added test bench files and design document
50
//
51
// Revision 1.1.1.1  2001/10/02 15:33:33  mihad
52
// New project directory structure
53
//
54
//
55
 
56
// synopsys translate_off
57
`include "timescale.v"
58
// synopsys translate_on
59
 
60
module ssvga_fifo(
61
        clk, rst, dat_i, wr_en, rd_en,
62
        dat_o, full, empty, ssvga_en
63
);
64
 
65
//
66
// I/O ports
67
//
68
input                   clk;            // Clock
69
input                   rst;            // Reset
70
input   [31:0]   dat_i;          // Input data
71
input                   wr_en;          // Write enable
72
input                   rd_en;          // Read enable
73
output  [7:0]    dat_o;          // Output data
74
output                  full;           // Full flag
75
output                  empty;          // Empty flag
76
input           ssvga_en ;  // vga enable
77
 
78
//
79
// Internal wires and regs
80
//
81
reg     [7:0]            wr_ptr;             // Write pointer
82
reg     [7:0]            wr_ptr_plus1;   // Write pointer
83
reg     [9:0]            rd_ptr;             // Read pointer
84
reg     [9:0]            rd_ptr_plus1;   // Read pointer plus1
85
wire                    rd_en_int;          // FIFO internal read enable
86
 
87
//
88
// Write pointer + 1
89
//
90
 
91
always @(posedge clk or posedge rst)
92
    if (rst)
93
                wr_ptr_plus1 <= #1 8'b0000_0001 ;
94
    else if (~ssvga_en)
95
        wr_ptr_plus1 <= #1 8'b0000_0001 ;
96
        else if (wr_en)
97
                wr_ptr_plus1 <= #1 wr_ptr_plus1 + 1;
98
 
99
//
100
// Write pointer
101
//
102
always @(posedge clk or posedge rst)
103
        if (rst)
104
                wr_ptr <= #1 8'b0000_0000;
105
    else if (~ssvga_en)
106
        wr_ptr <= #1 8'b0000_0000;
107
        else if (wr_en)
108
                wr_ptr <= #1 wr_ptr_plus1 ;
109
 
110
//
111
// Read pointer
112
//
113
always @(posedge clk or posedge rst)
114
        if (rst)
115
                rd_ptr <= #1 10'b00_0000_0000;
116
    else if (~ssvga_en)
117
        rd_ptr <= #1 10'b00_0000_0000;
118
        else if (rd_en_int)
119
                rd_ptr <= #1 rd_ptr_plus1 ;
120
 
121
always @(posedge clk or posedge rst)
122
        if (rst)
123
                rd_ptr_plus1 <= #1 10'b00_0000_0001;
124
    else if (~ssvga_en)
125
        rd_ptr_plus1 <= #1 10'b00_0000_0001;
126
        else if (rd_en_int)
127
                rd_ptr_plus1 <= #1 rd_ptr_plus1 + 1 ;
128
 
129
//
130
// Empty is asserted when both pointers match
131
//
132
assign empty = ( rd_ptr == {wr_ptr, 2'b00} ) ;
133
 
134
//
135
// Full is asserted when both pointers match
136
// and wr_ptr did increment in previous clock cycle
137
//
138
assign full = ( wr_ptr_plus1 == rd_ptr[9:2] ) ;
139
 
140
wire valid_pix = 1'b1 ;
141
 
142
//
143
// Read enable for FIFO
144
//
145
assign rd_en_int = rd_en & !empty & valid_pix;
146
 
147
wire [8:0] ram_pix_address = rd_en_int ? {rd_ptr_plus1[9:2], rd_ptr_plus1[0]} : {rd_ptr[9:2], rd_ptr[0]} ;
148
 
149
wire [7:0] dat_o_low ;
150
wire [7:0] dat_o_high ;
151
 
152
assign dat_o = rd_ptr[1] ? dat_o_high : dat_o_low ;
153
 
154
RAMB4_S8_S16 ramb4_s8_0(
155
        .CLKA(clk),
156
        .RSTA(rst),
157
        .ADDRA(ram_pix_address),
158
        .DIA(8'h00),
159
        .ENA(1'b1),
160
        .WEA(1'b0),
161
        .DOA(dat_o_low),
162
 
163
        .CLKB(clk),
164
        .RSTB(rst),
165
        .ADDRB(wr_ptr),
166
        .DIB(dat_i[15:0]),
167
        .ENB(1'b1),
168
        .WEB(wr_en),
169
        .DOB()
170
);
171
 
172
RAMB4_S8_S16 ramb4_s8_1(
173
        .CLKA(clk),
174
        .RSTA(rst),
175
        .ADDRA(ram_pix_address),
176
        .DIA(8'h00),
177
        .ENA(1'b1),
178
        .WEA(1'b0),
179
        .DOA(dat_o_high),
180
 
181
        .CLKB(clk),
182
        .RSTB(rst),
183
        .ADDRB(wr_ptr),
184
        .DIB(dat_i[31:16]),
185
        .ENB(1'b1),
186
        .WEB(wr_en),
187
        .DOB()
188
);
189
 
190
endmodule

powered by: WebSVN 2.1.0

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