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

Subversion Repositories ht_tunnel

[/] [ht_tunnel/] [tags/] [START/] [bench/] [core/] [PacketContainer.cpp] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 acastong
//PacketContainer.cpp
2
 
3
/* ***** BEGIN LICENSE BLOCK *****
4
 * Version: MPL 1.1
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version
7
 * 1.1 (the "License"); you may not use this file except in compliance with
8
 * the License. You may obtain a copy of the License at
9
 * http://www.mozilla.org/MPL/
10
 *
11
 * Software distributed under the License is distributed on an "AS IS" basis,
12
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13
 * for the specific language governing rights and limitations under the
14
 * License.
15
 *
16
 * The Original Code is HyperTransport Tunnel IP Core.
17
 *
18
 * The Initial Developer of the Original Code is
19
 * Ecole Polytechnique de Montreal.
20
 * Portions created by the Initial Developer are Copyright (C) 2005
21
 * the Initial Developer. All Rights Reserved.
22
 *
23
 * Contributor(s):
24
 *   Ami Castonguay <acastong@grm.polymtl.ca>
25
 *
26
 * Alternatively, the contents of this file may be used under the terms
27
 * of the Polytechnique HyperTransport Tunnel IP Core Source Code License
28
 * (the  "PHTICSCL License", see the file PHTICSCL.txt), in which case the
29
 * provisions of PHTICSCL License are applicable instead of those
30
 * above. If you wish to allow use of your version of this file only
31
 * under the terms of the PHTICSCL License and not to allow others to use
32
 * your version of this file under the MPL, indicate your decision by
33
 * deleting the provisions above and replace them with the notice and
34
 * other provisions required by the PHTICSCL License. If you do not delete
35
 * the provisions above, a recipient may use your version of this file
36
 * under either the MPL or the PHTICSCL License."
37
 *
38
 * ***** END LICENSE BLOCK ***** */
39
 
40
#include "InfoPacket.h"
41
#include "PacketContainer.h"
42
 
43
 
44
PacketContainer::PacketContainer() : bufferedBitVector(){
45
        //Default to nop packet
46
        defaultPacket = true;
47
        pkt = new NopPacket();
48
 
49
}
50
 
51
PacketContainer::PacketContainer(ControlPacket* pkt_ref): defaultPacket(false),
52
                                                                bufferedBitVector(){
53
        if(pkt_ref == NULL){
54
                pkt = new NopPacket();
55
                defaultPacket = true;
56
                return;
57
        }
58
        pkt = pkt_ref;
59
        bufferedBitVector = pkt->getVector();
60
}
61
 
62
bool PacketContainer::isValidPacket() const {return !defaultPacket;}
63
 
64
PacketContainer::PacketContainer(const PacketContainer &container){
65
        pkt = container->getCopy();
66
}
67
 
68
 
69
PacketContainer& PacketContainer::operator=(const PacketContainer &container){
70
        if(pkt == container.pkt) return *this;
71
        delete pkt;
72
        pkt = container->getCopy();
73
        bufferedBitVector = pkt->getVector();
74
        return *this;
75
}
76
 
77
PacketContainer& PacketContainer::operator=(const ControlPacket &new_pkt){
78
        if(pkt == &new_pkt) return *this;
79
        delete pkt;
80
        pkt = new_pkt.getCopy();
81
        bufferedBitVector = pkt->getVector();
82
        return *this;
83
}
84
 
85
void PacketContainer::takeControl(ControlPacket *new_pkt){
86
        if(pkt == new_pkt) return;
87
        delete pkt;
88
        pkt = new_pkt;
89
        bufferedBitVector = pkt->getVector();
90
}
91
 
92
ControlPacket* PacketContainer::giveControl(){
93
        ControlPacket* temp = pkt;
94
        pkt =  new NopPacket();
95
        defaultPacket = true;
96
        return temp;
97
}
98
 
99
bool PacketContainer::operator== (const PacketContainer & test) const{
100
        return (*pkt == *test);
101
}
102
 
103
//function to allow the ControlPacket to be used as an sc_signal
104
void sc_trace(sc_trace_file *tf, const PacketContainer& v,
105
const sc_string& NAME) {
106
        sc_trace(tf,v.bufferedBitVector, NAME);
107
}
108
 
109
 
110
PacketContainer::~PacketContainer(){
111
        delete pkt;
112
}
113
 
114
ostream &operator<<(ostream& out, const PacketContainer & c){
115
        out << (*c);
116
        return out;
117
}

powered by: WebSVN 2.1.0

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