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

Subversion Repositories ht_tunnel

[/] [ht_tunnel/] [trunk/] [bench/] [core/] [RequestPacket.cpp] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 acastong
//RequestPacket.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 "RequestPacket.h"
41
 
42
RequestPacket:: RequestPacket(const sc_bv<6> &command,
43
                              const sc_bv<4> &seqID,
44
                                          const sc_bv<5> &unitID,
45
                                          const bool passPW,
46
                                          const bool isocOrCompat,
47
                                          const sc_bv<5> srcTag,
48
                                          const sc_bv<4> count,
49
                                          const sc_bv<38> address)
50
{
51
        bv.range(5,0) = command;
52
        bv.range(7,6) = seqID.range(3,2);
53
        bv.range(14,13) = seqID.range(1,0);
54
        bv.range(12,8) = unitID;
55
        bv[15] = passPW;
56
        bv[21] = isocOrCompat;
57
        bv.range(20,16) = srcTag;
58
        bv.range(25,22) = count;
59
        bv.range(63,26) = address;
60
}
61
 
62
//If the packet is a packet that only contains 32 bits
63
bool RequestPacket::isDwordPacket() const{
64
        sc_bv<6> cmd = bv(5 , 0);
65
 
66
        if(cmd == "111100" || cmd == "111111" || cmd == "000010"){
67
                return true;
68
        }
69
        return false;
70
}
71
 
72
//If the packet has a data packet associated to it
73
bool RequestPacket::hasDataAssociated() const{
74
        if(bv(5 , 0) == "111101" ||
75
                bv(5 , 3) == "101" || bv(5 , 3) == "001")
76
        {
77
                return true;
78
        }
79
        return false;
80
}
81
 
82
//To get the virtual channel of the packet
83
VirtualChannel RequestPacket::getVirtualChannel() const{
84
        if(bv[5] == '1' && bv.range(4,0) != "11101") return VC_POSTED;
85
        return VC_NON_POSTED;
86
}
87
 
88
bool RequestPacket::isInAddressRange(const char * low, const char * high) const{
89
        //Start by converting the strings to uint
90
        sc_uint<40> low_uint(low);
91
        sc_uint<40> high_uint(high);
92
 
93
        //Call the function taking uints
94
        return isInAddressRange(low_uint,high_uint);
95
}
96
 
97
bool RequestPacket::isInAddressRange(const sc_bv<40> &low, const sc_bv<40> &high) const{
98
        //Start by converting the strings to uint
99
        sc_uint<40> low_uint(low);
100
        sc_uint<40> high_uint(high);
101
 
102
        //Call the function taking uints
103
        return isInAddressRange(low_uint,high_uint);
104
}
105
 
106
bool RequestPacket::isInAddressRange(const sc_uint<40> &low,
107
                                                                                 const sc_uint<40> &high) const{
108
        if(isDwordPacket()) return false;
109
        sc_uint<40> addr = getRequestAddr();
110
        return (addr >= low && addr < high);
111
}
112
 
113
sc_uint<40> RequestPacket::getRequestAddr() const{
114
        sc_uint<40> addr;
115
 
116
        //If the packet only has 32 bits, return an address
117
        //of only zeros since it does not have any address
118
        if(isDwordPacket())
119
                return addr;
120
 
121
        //Copy the standard range of addresses
122
        sc_bv<37> temp(bv.range(63,27));
123
        addr.range(39,3) = temp;
124
 
125
        //Copy the last bit of the address.  An exception is made for
126
        //the ATOMIC packet, that has this bit always at 0
127
        sc_bit temp2(bv[26]);
128
        if(bv(5 , 0) != "111101") addr.bit(2) = temp2;
129
 
130
        //Return the address
131
        return addr;
132
}
133
 
134
sc_uint<4> RequestPacket::getDataLengthm1() const {
135
        //If a byte read (cmd starts by 01 for read, and pkt[2] for byte
136
        if(bv[5] == false && bv[4] == true && bv[2] == true){
137
                return 0;
138
        }
139
        else{
140
                //DataLength is Doubleword
141
                return (sc_bv<4>)bv.range(25,22);;
142
        }
143
}
144
 
145
 
146
sc_bv<4> RequestPacket::getSeqID() const{
147
        sc_bv<4> temp;
148
        temp.range(3,2) = bv(7,6);
149
        temp.range(1,0) = bv(14,13);
150
        return temp;
151
}
152
 
153
bool RequestPacket::getPassPW() const{
154
        return (sc_bit)bv[15];
155
}
156
 
157
sc_bv<5> RequestPacket::getUnitID() const{
158
        return bv.range(12,8);
159
}
160
 
161
sc_bv<5> RequestPacket::getSrcTag() const{
162
        return bv.range(20,16);
163
}
164
 
165
bool RequestPacket::getCompatOrIsoc() const{
166
        return (sc_bit)bv[21];
167
}
168
 
169
bool RequestPacket::isChain() const{
170
        //if(posted && write && bit chain)
171
        if(bv.range(5 , 3) == "101" &&
172
           bv[19] == true) return true;
173
        return false;
174
}

powered by: WebSVN 2.1.0

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