RubySlicc_Util.hh (11209:d5a7a4da9f63) | RubySlicc_Util.hh (11307:bd7d06ea90f5) |
---|---|
1/* 2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood | 1/* 2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood |
3 * Copyright (c) 2013 Advanced Micro Devices, Inc. |
|
3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the --- 25 unchanged lines hidden (view full) --- 36#include <cassert> 37 38#include "debug/RubySlicc.hh" 39#include "mem/packet.hh" 40#include "mem/ruby/common/Address.hh" 41#include "mem/ruby/common/BoolVec.hh" 42#include "mem/ruby/common/DataBlock.hh" 43#include "mem/ruby/common/TypeDefines.hh" | 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer; 10 * redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the --- 25 unchanged lines hidden (view full) --- 37#include <cassert> 38 39#include "debug/RubySlicc.hh" 40#include "mem/packet.hh" 41#include "mem/ruby/common/Address.hh" 42#include "mem/ruby/common/BoolVec.hh" 43#include "mem/ruby/common/DataBlock.hh" 44#include "mem/ruby/common/TypeDefines.hh" |
45#include "mem/ruby/common/WriteMask.hh" |
|
44 45inline Cycles zero_time() { return Cycles(0); } 46 47inline NodeID 48intToID(int nodenum) 49{ 50 NodeID id = nodenum; 51 return id; --- 31 unchanged lines hidden (view full) --- 83 return 1024; 84} 85 86/** 87 * This function accepts an address, a data block and a packet. If the address 88 * range for the data block contains the address which the packet needs to 89 * read, then the data from the data block is written to the packet. True is 90 * returned if the data block was read, otherwise false is returned. | 46 47inline Cycles zero_time() { return Cycles(0); } 48 49inline NodeID 50intToID(int nodenum) 51{ 52 NodeID id = nodenum; 53 return id; --- 31 unchanged lines hidden (view full) --- 85 return 1024; 86} 87 88/** 89 * This function accepts an address, a data block and a packet. If the address 90 * range for the data block contains the address which the packet needs to 91 * read, then the data from the data block is written to the packet. True is 92 * returned if the data block was read, otherwise false is returned. |
93 * 94 * This is used during a functional access "search the world" operation. The 95 * functional access looks in every place that might hold a valid data block 96 * and, if it finds one, checks to see if it is holding the address the access 97 * is searching for. During the access check, the WriteMask could be in any 98 * state, including empty. |
|
91 */ 92inline bool 93testAndRead(Addr addr, DataBlock& blk, Packet *pkt) 94{ 95 Addr pktLineAddr = makeLineAddress(pkt->getAddr()); 96 Addr lineAddr = makeLineAddress(addr); 97 98 if (pktLineAddr == lineAddr) { --- 5 unchanged lines hidden (view full) --- 104 data[i] = blk.getByte(i + startByte); 105 } 106 return true; 107 } 108 return false; 109} 110 111/** | 99 */ 100inline bool 101testAndRead(Addr addr, DataBlock& blk, Packet *pkt) 102{ 103 Addr pktLineAddr = makeLineAddress(pkt->getAddr()); 104 Addr lineAddr = makeLineAddress(addr); 105 106 if (pktLineAddr == lineAddr) { --- 5 unchanged lines hidden (view full) --- 112 data[i] = blk.getByte(i + startByte); 113 } 114 return true; 115 } 116 return false; 117} 118 119/** |
120 * This function accepts an address, a data block, a write mask and a packet. 121 * If the valid address range for the data block contains the address which 122 * the packet needs to read, then the data from the data block is written to 123 * the packet. True is returned if any part of the data block was read, 124 * otherwise false is returned. 125 */ 126inline bool 127testAndReadMask(Addr addr, DataBlock& blk, WriteMask& mask, Packet *pkt) 128{ 129 Addr pktLineAddr = makeLineAddress(pkt->getAddr()); 130 Addr lineAddr = makeLineAddress(addr); 131 132 if (pktLineAddr == lineAddr) { 133 uint8_t *data = pkt->getPtr<uint8_t>(); 134 unsigned int size_in_bytes = pkt->getSize(); 135 unsigned startByte = pkt->getAddr() - lineAddr; 136 bool was_read = false; 137 138 for (unsigned i = 0; i < size_in_bytes; ++i) { 139 if (mask.test(i + startByte)) { 140 was_read = true; 141 data[i] = blk.getByte(i + startByte); 142 } 143 } 144 return was_read; 145 } 146 return false; 147} 148 149/** |
|
112 * This function accepts an address, a data block and a packet. If the address 113 * range for the data block contains the address which the packet needs to 114 * write, then the data from the packet is written to the data block. True is 115 * returned if the data block was written, otherwise false is returned. 116 */ 117inline bool 118testAndWrite(Addr addr, DataBlock& blk, Packet *pkt) 119{ --- 29 unchanged lines hidden --- | 150 * This function accepts an address, a data block and a packet. If the address 151 * range for the data block contains the address which the packet needs to 152 * write, then the data from the packet is written to the data block. True is 153 * returned if the data block was written, otherwise false is returned. 154 */ 155inline bool 156testAndWrite(Addr addr, DataBlock& blk, Packet *pkt) 157{ --- 29 unchanged lines hidden --- |