RubySlicc_Util.hh (9171:ae88ecf37145) | RubySlicc_Util.hh (9302:c2e70a9bc340) |
---|---|
1/* 2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 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; --- 21 unchanged lines hidden (view full) --- 30 * These are the functions that exported to slicc from ruby. 31 */ 32 33#ifndef __MEM_RUBY_SLICC_INTERFACE_RUBYSLICCUTIL_HH__ 34#define __MEM_RUBY_SLICC_INTERFACE_RUBYSLICCUTIL_HH__ 35 36#include <cassert> 37 | 1/* 2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 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; --- 21 unchanged lines hidden (view full) --- 30 * These are the functions that exported to slicc from ruby. 31 */ 32 33#ifndef __MEM_RUBY_SLICC_INTERFACE_RUBYSLICCUTIL_HH__ 34#define __MEM_RUBY_SLICC_INTERFACE_RUBYSLICCUTIL_HH__ 35 36#include <cassert> 37 |
38#include "debug/RubySlicc.hh" |
|
38#include "mem/ruby/common/Address.hh" 39#include "mem/ruby/common/Global.hh" 40#include "mem/ruby/slicc_interface/RubySlicc_ComponentMapping.hh" 41#include "mem/ruby/system/System.hh" 42 43inline int 44random(int n) 45{ --- 78 unchanged lines hidden (view full) --- 124} 125 126inline int 127mod(int val, int mod) 128{ 129 return val % mod; 130} 131 | 39#include "mem/ruby/common/Address.hh" 40#include "mem/ruby/common/Global.hh" 41#include "mem/ruby/slicc_interface/RubySlicc_ComponentMapping.hh" 42#include "mem/ruby/system/System.hh" 43 44inline int 45random(int n) 46{ --- 78 unchanged lines hidden (view full) --- 125} 126 127inline int 128mod(int val, int mod) 129{ 130 return val % mod; 131} 132 |
133/** 134 * This function accepts an address, a data block and a packet. If the address 135 * range for the data block contains the address which the packet needs to 136 * read, then the data from the data block is written to the packet. True is 137 * returned if the data block was read, otherwise false is returned. 138 */ 139inline bool 140testAndRead(Address addr, DataBlock& blk, Packet *pkt) 141{ 142 Address pktLineAddr(pkt->getAddr()); 143 pktLineAddr.makeLineAddress(); 144 145 Address lineAddr = addr; 146 lineAddr.makeLineAddress(); 147 148 if (pktLineAddr == lineAddr) { 149 uint8_t *data = pkt->getPtr<uint8_t>(true); 150 unsigned int size_in_bytes = pkt->getSize(); 151 unsigned startByte = pkt->getAddr() - lineAddr.getAddress(); 152 153 for (unsigned i = 0; i < size_in_bytes; ++i) { 154 data[i] = blk.getByte(i + startByte); 155 } 156 return true; 157 } 158 return false; 159} 160 161/** 162 * This function accepts an address, a data block and a packet. If the address 163 * range for the data block contains the address which the packet needs to 164 * write, then the data from the packet is written to the data block. True is 165 * returned if the data block was written, otherwise false is returned. 166 */ 167inline bool 168testAndWrite(Address addr, DataBlock& blk, Packet *pkt) 169{ 170 Address pktLineAddr(pkt->getAddr()); 171 pktLineAddr.makeLineAddress(); 172 173 Address lineAddr = addr; 174 lineAddr.makeLineAddress(); 175 176 if (pktLineAddr == lineAddr) { 177 uint8_t *data = pkt->getPtr<uint8_t>(true); 178 unsigned int size_in_bytes = pkt->getSize(); 179 unsigned startByte = pkt->getAddr() - lineAddr.getAddress(); 180 181 for (unsigned i = 0; i < size_in_bytes; ++i) { 182 blk.setByte(i + startByte, data[i]); 183 } 184 return true; 185 } 186 return false; 187} 188 |
|
132#endif // __MEM_RUBY_SLICC_INTERFACE_RUBYSLICCUTIL_HH__ | 189#endif // __MEM_RUBY_SLICC_INTERFACE_RUBYSLICCUTIL_HH__ |