Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / bl / lib / ecc / src / BL_BaseSynd.h
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: BL_BaseSynd.h
5* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
7*
8* The above named program is free software; you can redistribute it and/or
9* modify it under the terms of the GNU General Public
10* License version 2 as published by the Free Software Foundation.
11*
12* The above named program is distributed in the hope that it will be
13* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15* General Public License for more details.
16*
17* You should have received a copy of the GNU General Public
18* License along with this work; if not, write to the Free Software
19* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20*
21* ========== Copyright Header End ============================================
22*/
23/************************************************************************
24**
25** Copyright (C) 2006, Sun Microsystems, Inc.
26**
27** Sun considers its source code as an unpublished, proprietary
28** trade secret and it is available only under strict license provisions.
29** This copyright notice is placed here only to protect Sun in the event
30** the source is deemed a published work. Disassembly, decompilation,
31** or other means of reducing the object code to human readable form
32** is prohibited by the license agreement under which this code is
33** provided to the user or company in possession of this copy.
34**
35*************************************************************************/
36#ifndef __BL_BaseSynd_h__
37#define __BL_BaseSynd_h__
38#include "BL_BitUtility.h"
39
40class BL_BaseSynd
41{
42 public:
43
44 BL_BaseSynd(uint32_t syndrome) :
45 syndrome_(syndrome) {}
46
47 ~BL_BaseSynd() {}
48
49 /**
50 * Assignment operator
51 *
52 * @param rhs The right hand side of the assignment operator.
53 * @return The lvalue of the assignment.
54 */
55 const BL_BaseSynd & operator=( const BL_BaseSynd &rhs )
56 {
57 syndrome_ = rhs.syndrome_;
58 return *this;
59 }
60
61 uint32_t getSyndrome() const { return syndrome_; }
62
63 bool noError() const { return (syndrome_ == 0); }
64
65 virtual bool isDoubleBitError() const = 0;
66
67 virtual bool isSingleBitError() const = 0;
68
69 virtual bool isDataBitError() const = 0;
70
71 // Can only be called on data bit error, else exception.
72 virtual uint32_t getDataBit() const = 0;
73
74 virtual bool isCheckBitError() const = 0;
75
76 // Can only be called on check bit error, else exception.
77 virtual uint32_t getCheckBit() const = 0;
78
79 virtual bool isMultipleBitError() const = 0;
80
81 bool isUncorrectableError() const
82 {
83 return isDoubleBitError() || isMultipleBitError();
84 }
85
86
87 // Used to calculate the most significant bit of a syndrome
88 // as the parity of the data and check bits. Returns the
89 // completed syndrome.
90 static uint32_t maskedSyndrome(uint32_t syndrome, uint64_t data,
91 uint32_t ecc, uint32_t MSBShift)
92 {
93 syndrome %= (1<<MSBShift);
94 uint32_t parity = BL_BitUtility::calc_parity(data ^ ecc);
95 return syndrome | (parity<<MSBShift);
96 }
97
98 protected:
99 uint32_t syndrome_;
100};
101
102#endif