113219Sodanrc@yahoo.com.br/*
213219Sodanrc@yahoo.com.br * Copyright (c) 2018 Inria
313219Sodanrc@yahoo.com.br * Copyright (c) 2012-2014,2017 ARM Limited
413219Sodanrc@yahoo.com.br * All rights reserved.
513219Sodanrc@yahoo.com.br *
613219Sodanrc@yahoo.com.br * The license below extends only to copyright in the software and shall
713219Sodanrc@yahoo.com.br * not be construed as granting a license to any other intellectual
813219Sodanrc@yahoo.com.br * property including but not limited to intellectual property relating
913219Sodanrc@yahoo.com.br * to a hardware implementation of the functionality of the software
1013219Sodanrc@yahoo.com.br * licensed hereunder.  You may use the software subject to the license
1113219Sodanrc@yahoo.com.br * terms below provided that you ensure that this notice is replicated
1213219Sodanrc@yahoo.com.br * unmodified and in its entirety in all distributions of the software,
1313219Sodanrc@yahoo.com.br * modified or unmodified, in source code or in binary form.
1413219Sodanrc@yahoo.com.br *
1513219Sodanrc@yahoo.com.br * Copyright (c) 2003-2005,2014 The Regents of The University of Michigan
1613219Sodanrc@yahoo.com.br * All rights reserved.
1713219Sodanrc@yahoo.com.br *
1813219Sodanrc@yahoo.com.br * Redistribution and use in source and binary forms, with or without
1913219Sodanrc@yahoo.com.br * modification, are permitted provided that the following conditions are
2013219Sodanrc@yahoo.com.br * met: redistributions of source code must retain the above copyright
2113219Sodanrc@yahoo.com.br * notice, this list of conditions and the following disclaimer;
2213219Sodanrc@yahoo.com.br * redistributions in binary form must reproduce the above copyright
2313219Sodanrc@yahoo.com.br * notice, this list of conditions and the following disclaimer in the
2413219Sodanrc@yahoo.com.br * documentation and/or other materials provided with the distribution;
2513219Sodanrc@yahoo.com.br * neither the name of the copyright holders nor the names of its
2613219Sodanrc@yahoo.com.br * contributors may be used to endorse or promote products derived from
2713219Sodanrc@yahoo.com.br * this software without specific prior written permission.
2813219Sodanrc@yahoo.com.br *
2913219Sodanrc@yahoo.com.br * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3013219Sodanrc@yahoo.com.br * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3113219Sodanrc@yahoo.com.br * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3213219Sodanrc@yahoo.com.br * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3313219Sodanrc@yahoo.com.br * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3413219Sodanrc@yahoo.com.br * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3513219Sodanrc@yahoo.com.br * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3613219Sodanrc@yahoo.com.br * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3713219Sodanrc@yahoo.com.br * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3813219Sodanrc@yahoo.com.br * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3913219Sodanrc@yahoo.com.br * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4013219Sodanrc@yahoo.com.br *
4113219Sodanrc@yahoo.com.br * Authors: Daniel Carvalho
4213219Sodanrc@yahoo.com.br *          Erik Hallnor
4313219Sodanrc@yahoo.com.br */
4413219Sodanrc@yahoo.com.br
4513219Sodanrc@yahoo.com.br/**
4613219Sodanrc@yahoo.com.br * @file
4713219Sodanrc@yahoo.com.br * Definitions of a set associative indexing policy.
4813219Sodanrc@yahoo.com.br */
4913219Sodanrc@yahoo.com.br
5013219Sodanrc@yahoo.com.br#include "mem/cache/tags/indexing_policies/set_associative.hh"
5113219Sodanrc@yahoo.com.br
5213225Sodanrc@yahoo.com.br#include "mem/cache/replacement_policies/replaceable_entry.hh"
5313219Sodanrc@yahoo.com.br
5413219Sodanrc@yahoo.com.brSetAssociative::SetAssociative(const Params *p)
5513219Sodanrc@yahoo.com.br    : BaseIndexingPolicy(p)
5613219Sodanrc@yahoo.com.br{
5713219Sodanrc@yahoo.com.br}
5813219Sodanrc@yahoo.com.br
5913219Sodanrc@yahoo.com.bruint32_t
6013219Sodanrc@yahoo.com.brSetAssociative::extractSet(const Addr addr) const
6113219Sodanrc@yahoo.com.br{
6213219Sodanrc@yahoo.com.br    return (addr >> setShift) & setMask;
6313219Sodanrc@yahoo.com.br}
6413219Sodanrc@yahoo.com.br
6513219Sodanrc@yahoo.com.brAddr
6613219Sodanrc@yahoo.com.brSetAssociative::regenerateAddr(const Addr tag, const ReplaceableEntry* entry)
6713219Sodanrc@yahoo.com.br                                                                        const
6813219Sodanrc@yahoo.com.br{
6913219Sodanrc@yahoo.com.br    return (tag << tagShift) | (entry->getSet() << setShift);
7013219Sodanrc@yahoo.com.br}
7113219Sodanrc@yahoo.com.br
7213219Sodanrc@yahoo.com.brstd::vector<ReplaceableEntry*>
7313219Sodanrc@yahoo.com.brSetAssociative::getPossibleEntries(const Addr addr) const
7413219Sodanrc@yahoo.com.br{
7513219Sodanrc@yahoo.com.br    return sets[extractSet(addr)];
7613219Sodanrc@yahoo.com.br}
7713219Sodanrc@yahoo.com.br
7813219Sodanrc@yahoo.com.brSetAssociative*
7913219Sodanrc@yahoo.com.brSetAssociativeParams::create()
8013219Sodanrc@yahoo.com.br{
8113219Sodanrc@yahoo.com.br    return new SetAssociative(this);
8213219Sodanrc@yahoo.com.br}
83