How about a binary number system like this? When counting with a very high bus speed, the transistors do not overheat and therefore limit clock speed.
The solution uses both base-2 and base-1 binary to make a number.
((base-2 binary number)*size_of_in_bits(base-1 binary number)) + base-1 binary number
so for a 16 bit bus, with the high byte binary base-2, and the low byte binary base-1, the maximum count would be
((2^8)-1)*8)+8) = 2048
The solution to the EEPROM life problem could be:
Using a EEPROM that only changes the required cells when writing new data to maximise life.
4 bytes (32bit) for the base-2 part of the number, and 13 bytes (100 bit) for the base-1 part of the number.
((32 bit base-2 binary number) x 100) + (100 bit binary base-1 tally counter)
The maximum count would be (((2^32)-1) *100)+100) = 429,496,729,700
This method should get the maximum life from the EEPROM or FLASH memory, for FLASH memory the base-1 number should be stored inverted, because the erased state is logic 1.
The EEPROM can, read, increment, write, a number 2 orders of magnitude bigger, achieving a count of 1 million instead of ten thousand.
Send me a email and I can give you the program, it works in MVS 2013 console.
lion@palmbeach.freeserve.co.uk
/* a www.goatelectronics.com solution */
/* This program is designed to test eeprom life, writing to the same page and cells */
/* 32 bit base-2 binary number + 100 bit base-1 binary number make the number*/
/* byte 0 - Most significant byte , binary base-2 number */
/* byte 1 - */
/* byte 2 - */
/* byte 3 - Least significant byte, binary base-2 number */
/* byte 4 - 8 bit CRC suffix for 32bit number, to be done later */
/* byte 5 - count 0 to 8 of binary base-1 number */
/* byte 6 - count 9 to 16 of binary base-1 number*/
/* byte 7 - count 17 to 24 of ... */
/* byte 8 - count 25 to 32 */
/* byte 9 - count 33 to 40 */
/* byte 10 - count 41 to 48 */
/* byte 11 - count 49 to 56 */
/* byte 12 - count 57 to 64 */
/* byte 13 - count 65 to 72 */
/* byte 14 - count 73 to 80 */
/* byte 15 - count 81 to 88 */
/* byte 16 - count 89 to 96 */
/* byte 17 - count 97 to 100 */
#include "stdafx.h"
#include <iostream>
#include <conio.h>
using namespace std;
/* emulate the eeprom *here* , byte read and write */
unsigned char eeprom[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
unsigned int EEPROM_read (void)
{
unsigned char i_u8;
unsigned int value_u32, value_A_u32, value_B_u32, value_C_u32, value_D_u32 = 0;
unsigned int base_1_u32 = 0;
value_A_u32 = eeprom[0];
value_A_u32 = value_A_u32 << 24;
value_B_u32 = eeprom[1];
value_B_u32 = value_B_u32 << 16;
value_C_u32 = eeprom[2];
value_C_u32 = value_C_u32 << 8;
value_D_u32 = eeprom[3];
value_u32 = value_A_u32 | value_B_u32 | value_C_u32 | value_D_u32;
/* eeprom[4] reserved location for CRC checksum! */
value_u32 = value_u32 * 100;
for (i_u8 = 5; eeprom[i_u8] == 0xFF; i_u8++)
{
base_1_u32 = base_1_u32 + 8;
}
switch (eeprom[i_u8])
{
case 0x80: base_1_u32 = base_1_u32 + 1;
break;
case 0xC0: base_1_u32 = base_1_u32 + 2;
break;
case 0xE0: base_1_u32 = base_1_u32 + 3;
break;
case 0xF0: base_1_u32 = base_1_u32 + 4;
break;
case 0xF8: base_1_u32 = base_1_u32 + 5;
break;
case 0xFC: base_1_u32 = base_1_u32 + 6;
break;
case 0xFE: base_1_u32 = base_1_u32 + 7;
break;
default:; /*if here, faulty EEPROM with base-1 number*/
}
value_u32 = value_u32 + base_1_u32;
return (value_u32);
}
void EEPROM_write(unsigned int number_u32)
{
unsigned char i_u8, remainder_u8;
unsigned int value_u32;
value_u32 = number_u32;
value_u32 = value_u32 / 100;
eeprom[0] = (unsigned char)((value_u32 & 0xFF000000) >> 24);
eeprom[1] = (unsigned char)((value_u32 & 0x00FF0000) >> 16);
eeprom[2] = (unsigned char)((value_u32 & 0x0000FF00) >> 8);
eeprom[3] = (unsigned char)((value_u32 & 0x000000FF));
remainder_u8 = (unsigned char)(number_u32 % 100);
if (!remainder_u8)
{
for (i_u8 = 5; i_u8 < 18; i_u8++)
{
eeprom[i_u8] = 0x00;
}
}
for (i_u8 = 5; remainder_u8 >=8; i_u8++)
{
eeprom[i_u8] = 0xFF;
remainder_u8 = remainder_u8 - 8;
}
switch (remainder_u8)
{
case 1: eeprom[i_u8] = 0x80;
break;
case 2: eeprom[i_u8] = 0xC0;
break;
case 3: eeprom[i_u8] = 0xE0;
break;
case 4: eeprom[i_u8] = 0xF0;
break;
case 5: eeprom[i_u8] = 0xF8;
break;
case 6: eeprom[i_u8] = 0xFC;
break;
case 7: eeprom[i_u8] = 0xFE;
break;
default:; /**/
}
}
int _tmain(int argc, _TCHAR* argv[])
{
unsigned char i_u8;
unsigned int test_number_u32;
unsigned int loop_u32 = 0;
while (loop_u32 <0xFFFFFFFF)
{
test_number_u32 = EEPROM_read();
test_number_u32++;
EEPROM_write(test_number_u32);
for (i_u8 = 0; i_u8 < 18; i_u8++)
{
printf(" %x", eeprom[i_u8]);
}
printf(" \n");
loop_u32++;
}