// ========== Copyright Header Begin ==========================================
// OpenSPARC T2 Processor File: BL_Hsiao_30_7_Synd.cc
// 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 ============================================
/************************************************************************
** Copyright (C) 2006, 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_Hsiao_30_7_Synd.h"
BL_EccBits
BL_Hsiao_30_7_Synd::Patterns::syndromes
[30];
BL_Hsiao_30_7_Synd::Patterns
BL_Hsiao_30_7_Synd::hsiao_30_7_patterns
;
BL_Hsiao_30_7_Synd::Patterns::Patterns()
// These syndromes are defined in PRM 1.3 Section 16.14.2
// Note they are written in base 2 so we use strtoul() to convert them.
syndromes
[0] = strtoul("1110000", NULL
, 2);
syndromes
[1] = strtoul("0001110", NULL
, 2);
syndromes
[2] = strtoul("1100001", NULL
, 2);
syndromes
[3] = strtoul("0011010", NULL
, 2);
syndromes
[4] = strtoul("1000101", NULL
, 2);
syndromes
[5] = strtoul("0110010", NULL
, 2);
syndromes
[6] = strtoul("0001101", NULL
, 2);
syndromes
[7] = strtoul("1101000", NULL
, 2);
syndromes
[8] = strtoul("0000111", NULL
, 2);
syndromes
[9] = strtoul("1010010", NULL
, 2);
syndromes
[10] = strtoul("0101001", NULL
, 2);
syndromes
[11] = strtoul("1010100", NULL
, 2);
syndromes
[12] = strtoul("0101010", NULL
, 2);
syndromes
[13] = strtoul("0010101", NULL
, 2);
syndromes
[14] = strtoul("1100010", NULL
, 2);
syndromes
[15] = strtoul("0011001", NULL
, 2);
syndromes
[16] = strtoul("1000110", NULL
, 2);
syndromes
[17] = strtoul("0100101", NULL
, 2);
syndromes
[18] = strtoul("0111000", NULL
, 2);
syndromes
[19] = strtoul("1001010", NULL
, 2);
syndromes
[20] = strtoul("0010110", NULL
, 2);
syndromes
[21] = strtoul("1010001", NULL
, 2);
syndromes
[22] = strtoul("0101100", NULL
, 2);
syndromes
[23] = strtoul("1001001", NULL
, 2);
syndromes
[24] = strtoul("0010011", NULL
, 2);
syndromes
[25] = strtoul("0100110", NULL
, 2);
syndromes
[26] = strtoul("1011000", NULL
, 2);
syndromes
[27] = strtoul("0110001", NULL
, 2);
syndromes
[28] = strtoul("1100100", NULL
, 2);
syndromes
[29] = strtoul("0001011", NULL
, 2);
// Convert the syndromes for each single bit error into the H matrix.
// Each pattern (there are 10) is multiplied by the data (a
// BL_Uint256) to generate one bit of ECC.
for (uint_t pattern_ndx
= 0; pattern_ndx
< 7; ++pattern_ndx
)
patterns
[6 - pattern_ndx
] = calc_pattern(pattern_ndx
);
// For Hsiao ECC, the check bits and the syndrome are calculated
// using the same algorithm.
// Check that inverting one data bit and calculating the resulting
// ECC matching the bit's syndrome.
for (uint_t syndrome_ndx
= 0; syndrome_ndx
< 30; ++syndrome_ndx
)
uint32_t data
= 1 << syndrome_ndx
;
if (calc_checks(7, patterns
, data
).get() != syndromes
[syndrome_ndx
].get())
"syndrome mismatch: ndx %d calc_check 0x%x syndrome 0x%x\n",
calc_checks(7, patterns
, data
).get(),
syndromes
[syndrome_ndx
].get());
uint64_t BL_Hsiao_30_7_Synd::Patterns::calc_pattern(uint_t pattern_ndx
)
for (uint_t ndx
= 0; ndx
< 30; ++ndx
)
if (syndromes
[ndx
].get() == 0)
fprintf(stderr
, "bad zero syndrome: %d\n", ndx
);
pattern
|= ((syndromes
[ndx
].get() >> pattern_ndx
) & 0x1ULL
)