Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / bl / lib / utl / src / BL_ThinFieldObj.h
/*
* ========== Copyright Header Begin ==========================================
*
* OpenSPARC T2 Processor File: BL_ThinFieldObj.h
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
*
* The above named program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License version 2 as published by the Free Software Foundation.
*
* The above named program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ========== Copyright Header End ============================================
*/
#ifndef __BL_ThinFieldObj_h__
#define __BL_ThinFieldObj_h__
/************************************************************************
**
** Copyright (C) 2002, Sun Microsystems, Inc.
**
** Sun considers its source code as an unpublished, proprietary
** trade secret and it is available only under strict license provisions.
** This copyright notice is placed here only to protect Sun in the event
** the source is deemed a published work. Disassembly, decompilation,
** or other means of reducing the object code to human readable form
** is prohibited by the license agreement under which this code is
** provided to the user or company in possession of this copy."
**
*************************************************************************/
#include "BL_Types.h"
/**
* This class is used to represent objects that have fields
* For example, this class would be appropriate to represetn control or status
* registers or TTEs.
*/
template <
uint64_t mask, // Which bits are implemented as read/write
uint64_t rw1c, // Which bits are implemented as read/write-1-clear
uint64_t bits, // Which bits are physically implemented
uint64_t init> // The initial power-on-reset value
class BL_ThinFieldObj {
public:
BL_ThinFieldObj() :
data(0) { }
BL_ThinFieldObj& operator=( const BL_ThinFieldObj& obj )
{
data = obj.data;
return *this;
}
bool operator==( const BL_ThinFieldObj& obj ) const { return data == obj.data; }
/**
* Return the field's size in bits
*
* @param field The number of this field
* @return The field's size in bits
* @see MM_McmTteTag::FieldT
*/
virtual uint32_t getSize( uint_t field ) const { return 0; }
/**
* Return the field's offset in the BL_ThinFieldObj
*
* @param field The number of this field
* @return The field's offset
* @see MM_McmTteTag::FieldT
*/
virtual uint32_t getOffset( uint_t field ) const { return 0; }
/**
* Return a string representation of the field name
*
* @param field The number of this field
* @return The name of the field
* @see MM_McmTteTag::FieldT
*/
virtual const char* getName() const { return "register with -f option in xml2reg"; }
/**
* Return a string representation of the field name
*
* @param field The number of this field
* @return The name of the field
* @see MM_McmTteTag::FieldT
*/
virtual const char* getName( uint_t field ) const { return "register with -f option in xml2reg"; }
uint64_t getNative() const { return get(); }
void setNative( uint64_t value ) { set(value); }
void setNotify( uint64_t value ) { set_notify(value); }
void setNativeHW( uint64_t value ) { set_phys_masked(value); }
// The above getNative(), setNative(), and setNativeHW() will be depricated and are going to
// be replaced with the methods get(), set(), set_unmasked()
// get() returns the value of the field object.
uint64_t get() const { return data; }
// set() sets the value of the field object, respecting RO and RW1C fields.
void set( uint64_t v ) { data = (v & mask) | (data & ~(mask | (v & rw1c))); }
// set_notify() is as set() and notifies the simulator that the value has changed.
// This method is primarily for front-end access since Riesling is wide open.
void set_notify( uint64_t v ) { call->call(this,(v & mask) | (data & ~(mask | (v & rw1c)))); }
// set_data() sets the full 64bits of the field objects.
void set_data( uint64_t value ) { data = value; }
// set_phys_masked() sets the RO, RW, and RW1C fields of the field object. This
// method respects the reserved fields.
void set_phys_masked( uint64_t value ) { data = (value & bits); }
uint64_t get_mask() const { return mask; }
uint64_t get_rw1c_mask() const { return rw1c; }
uint64_t get_phys_mask() const { return bits; }
uint64_t get_init() const { return init; }
void snapshot( SS_SnapShot &ss, const char* prefix="" )
{
sprintf(ss.tag,"%s.data",prefix); ss.val(&data);
}
protected:
uint64_t data; // Thew current contents of the register
};
#endif /* __BL_ThinFieldObj_h__ */