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

Subversion Repositories usb11

[/] [usb11/] [trunk/] [rtl/] [systemc/] [usb_fifo512x8.cpp] - Blame information for rev 15

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

Line No. Rev Author Line
1 2 alfoltran
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  USB FIFO                                                   ////
4
////                                                             ////
5
////  SystemC Version: usb_fifo512x8.cpp                         ////
6
////  Author: Alfredo Luiz Foltran Fialho                        ////
7
////          alfoltran@ig.com.br                                ////
8
////                                                             ////
9
////                                                             ////
10
/////////////////////////////////////////////////////////////////////
11
////                                                             ////
12
//// Verilog Version: generic_fifo_sc_a.v                        ////
13
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
14
////                         www.asics.ws                        ////
15
////                         rudi@asics.ws                       ////
16
////                                                             ////
17
//// This source file may be used and distributed without        ////
18
//// restriction provided that this copyright statement is not   ////
19
//// removed from the file and that any derivative work contains ////
20
//// the original copyright notice and the associated disclaimer.////
21
////                                                             ////
22
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
23
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
24
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
25
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
26
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
27
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
28
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
29
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
30
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
31
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
32
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
33
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
34
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
35
////                                                             ////
36
/////////////////////////////////////////////////////////////////////
37
 
38
#include "systemc.h"
39
#include "usb_fifo512x8.h"
40
 
41
void usb_fifo512x8::write_pointer_update(void) {
42
        if (!rst.read()) {
43
                wp.write(0);
44
        } else if (clr.read()) {
45
                wp.write(0);
46
        } else if (we.read()) {
47
                wp.write(wp_pl1.read());
48
        }
49
}
50
 
51
void usb_fifo512x8::read_pointer_update(void) {
52
        if (!rst.read()) {
53
                rp.write(0);
54
        } else if (clr.read()) {
55
                rp.write(0);
56
        } else if (re.read()) {
57
                rp.write(rp_pl1.read());
58
        }
59
}
60
 
61
void usb_fifo512x8::future_pointers_update(void) {
62
        wp_pl1.write(wp.read() + 1);
63
        wp_pl2.write(wp.read() + 2);
64
        rp_pl1.write(rp.read() + 1);
65
}
66
 
67
// Full & Empty Logic
68
// Guard Bit ...
69
void usb_fifo512x8::fe_gb_update(void) {
70
        if (!rst.read())
71
                gb.write(false);
72
        else if (clr.read())
73
                gb.write(false);
74
        else if ((wp_pl2.read() == rp.read()) && we.read())
75
                gb.write(true);
76
        else if ((wp.read() != rp.read()) && re.read())
77
                gb.write(false);
78
}
79
 
80
void usb_fifo512x8::fe_full_update(void) {
81
        if (!rst.read())
82
                full.write(false);
83
        else if (clr.read())
84
                full.write(false);
85
        else if (we.read() && ((wp_pl1.read() == rp.read()) && gb.read()) && !re.read())
86
                full.write(true);
87
        else if (re.read() && ((wp_pl1.read() != rp.read()) || !gb.read()) && !we.read())
88
                full.write(false);
89
}
90
 
91
void usb_fifo512x8::fe_empty_update(void) {
92
        if (!rst.read())
93
                empty.write(true);
94
        else if (clr.read())
95
                empty.write(true);
96
        else if (we.read() && ((wp.read() != rp_pl1.read()) || gb.read()) && !re.read())
97
                empty.write(false);
98
        else if (re.read() && ((wp.read() == rp_pl1.read()) && !gb.read()) && !we.read())
99
                empty.write(true);
100
}
101
 
102
void usb_fifo512x8::reset_update(void) {
103
        n_rst.write(!rst.read());
104
}
105
/*
106
usb_fifo512x8::~usb_fifo512x8(void) {
107
        if (i_ram)
108
                delete i_ram;
109
}
110
*/

powered by: WebSVN 2.1.0

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