From: Tiago Mück Date: Thu, 28 May 2020 17:31:36 +0000 (-0500) Subject: mem-ruby: additional WriteMask methods X-Git-Tag: develop-gem5-snapshot~663 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fd4ae25626b2119795fae8f4b5a5b076611033ef;p=gem5.git mem-ruby: additional WriteMask methods Change-Id: Ib5d5f892075b38f46d1d802c043853f56e19ea12 Signed-off-by: Tiago Mück Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/31257 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power Tested-by: kokoro --- diff --git a/src/mem/ruby/common/WriteMask.hh b/src/mem/ruby/common/WriteMask.hh index 6a0a041e7..6e3ea2982 100644 --- a/src/mem/ruby/common/WriteMask.hh +++ b/src/mem/ruby/common/WriteMask.hh @@ -1,4 +1,16 @@ /* + * Copyright (c) 2020 ARM Limited + * All rights reserved. + * + * The license below extends only to copyright in the software and shall + * not be construed as granting a license to any other intellectual + * property including but not limited to intellectual property relating + * to a hardware implementation of the functionality of the software + * licensed hereunder. You may use the software subject to the license + * terms below provided that you ensure that this notice is replicated + * unmodified and in its entirety in all distributions of the software, + * modified or unmodified, in source code or in binary form. + * * Copyright (c) 2012-15 Advanced Micro Devices, Inc. * All rights reserved. * @@ -69,18 +81,18 @@ class WriteMask } bool - test(int offset) + test(int offset) const { assert(offset < mSize); return mMask[offset]; } void - setMask(int offset, int len) + setMask(int offset, int len, bool val = true) { assert(mSize >= (offset + len)); for (int i = 0; i < len; i++) { - mMask[offset + i] = true; + mMask[offset + i] = val; } } void @@ -163,6 +175,33 @@ class WriteMask } } + void + setInvertedMask(const WriteMask & writeMask) + { + assert(mSize == writeMask.mSize); + for (int i = 0; i < mSize; i++) { + mMask[i] = !writeMask.mMask.at(i); + } + } + + int + firstBitSet(bool val, int offset = 0) const + { + for (int i = offset; i < mSize; ++i) + if (mMask[i] == val) + return i; + return mSize; + } + + int + count(int offset = 0) const + { + int count = 0; + for (int i = offset; i < mSize; ++i) + count += mMask[i]; + return count; + } + void print(std::ostream& out) const; void diff --git a/src/mem/ruby/protocol/RubySlicc_Exports.sm b/src/mem/ruby/protocol/RubySlicc_Exports.sm index ea61350ff..1b67dc603 100644 --- a/src/mem/ruby/protocol/RubySlicc_Exports.sm +++ b/src/mem/ruby/protocol/RubySlicc_Exports.sm @@ -58,7 +58,16 @@ structure(WriteMask, external="yes", desc="...") { bool isFull(); bool isOverlap(WriteMask); void orMask(WriteMask); + void setInvertedMask(WriteMask); void fillMask(); + void setMask(int,int); + bool getMask(int,int); + void setMask(int,int,bool); + int firstBitSet(bool); + int firstBitSet(bool,int); + int count(); + int count(int); + bool test(int); } structure(DataBlock, external = "yes", desc="..."){