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

Subversion Repositories noc

[/] [noc/] [src/] [fifo.cc] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 imori
#include <systemc>
2
#include <iostream>
3
#include "fifo.h"
4
using namespace sc_core;
5
using namespace std;
6
 
7
void virtual_fifo::receive_fifo(){
8
 
9
        while(true){
10
                if(x_to_fifo_sel.read() == 1){                  //select fifo.
11
                        if(fifo.num_free() > 0){
12
                                fifo.write(data_in.read());
13
                        }
14
                }
15
                else if(x_to_fifo_sel.read() == 2){             //select fifo1.
16
                        if(fifo1.num_free() > 0){
17
                                fifo1.write(data_in.read());
18
                        }
19
                }
20
                else if(x_to_fifo_sel.read() == 3){             //select fifo2.
21
                        if(fifo2.num_free() > 0){
22
                                fifo2.write(data_in.read());
23
                        }
24
                }
25
#ifdef FIFO_DEBUG
26
                if(fifo.num_free() == 0){
27
                        fifo.print(cout);
28
                        cout << endl;
29
                }
30
#endif
31
                wait();
32
        }
33
}
34
 
35
void virtual_fifo::transfer_fifo(){
36
        bool temp;
37
 
38
        while(true){
39
                if(fifo_to_x_sel.read() == 1){                  //select fifo.
40
                        if(fifo.num_free() < FIFO_DEEP){
41
                                temp = fifo.read();
42
                                data_out.write(temp);
43
                        }
44
                }
45
                else if(fifo_to_x_sel.read() == 2){             //select fifo1.
46
                        if(fifo1.num_free() < FIFO_DEEP){
47
                                temp = fifo1.read();
48
                                data_out.write(temp);
49
                        }
50
                }
51
                else if(fifo_to_x_sel.read() == 3){             //select fifo1.
52
                        if(fifo2.num_free() < FIFO_DEEP){
53
                                temp = fifo2.read();
54
                                data_out.write(temp);
55
                        }
56
                }
57
                wait();
58
        }
59
}
60
 
61
void virtual_fifo :: full_signal(){
62
        sc_uint<3>      full_state = 0;
63
 
64
        full.write(0x00);
65
 
66
        while(true){
67
                //full signal.
68
                if(fifo.num_free() == 0){
69
                        full_state |= 0x01;
70
                        full.write(full_state);
71
                }
72
                else if(fifo.num_free() > 0){
73
                        full_state &= ~0x01;
74
                        full.write(full_state);
75
                }
76
                if(fifo1.num_free() == 0){
77
                        full_state |= 0x02;
78
                        full.write(full_state);
79
                }
80
                else if(fifo1.num_free() > 0){
81
                        full_state &= ~0x02;
82
                        full.write(full_state);
83
                }
84
                if(fifo2.num_free() == 0){
85
                        full_state |= 0x04;
86
                        full.write(full_state);
87
                }
88
                else if(fifo2.num_free() > 0){
89
                        full_state &= ~0x04;
90
                        full.write(full_state);
91
                }
92
#ifdef FIFO_DEBUG
93
//              cout << "full signal: " << full_state << endl;
94
#endif
95
                wait(1,SC_NS);
96
        }
97
}
98
 
99
void virtual_fifo :: empty_signal(){
100
        sc_uint<3> empty_state = 7;
101
 
102
        empty.write(0x07);
103
 
104
        while(true){
105
                //empty signal.
106
                if(fifo.num_free() == FIFO_DEEP){
107
                        empty_state |= 0x01;
108
                        empty.write(empty_state);
109
                }
110
                else if(fifo.num_free() < FIFO_DEEP){
111
                        empty_state &= ~0x01;
112
                        empty.write(empty_state);
113
                }
114
                if(fifo1.num_free() == FIFO_DEEP){
115
                        empty_state |= 0x02;
116
                        empty.write(empty_state);
117
                }
118
                else if(fifo1.num_free() < FIFO_DEEP){
119
                        empty_state &= ~0x02;
120
                        empty.write(empty_state);
121
                }
122
                if(fifo2.num_free() == FIFO_DEEP){
123
                        empty_state |= 0x04;
124
                        empty.write(empty_state);
125
                }
126
                else if(fifo2.num_free() < FIFO_DEEP){
127
                        empty_state &= ~0x04;
128
                        empty.write(empty_state);
129
                }
130
#ifdef FIFO_DEBUG
131
//              cout << "empty signal: " << empty_state << endl;
132
#endif
133
                wait(1,SC_NS);
134
        }
135
}

powered by: WebSVN 2.1.0

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