Q1. Consider a RAM consisting of N memory locations. a) Assume that only problem
ID: 3676514 • Letter: Q
Question
Q1. Consider a RAM consisting of N memory locations.
a) Assume that only problem in its functioning may be that memory cells do not store the desired information (i.e. they get stuck for some reason). Suggest an algorithm in terms of “READ” and “WRITE” operations that would test that any cell can store the binary data. What is the complexity of such testing?
b) Assume now there is a problem in addressing i.e. a fault has occurred in the address decoder and as a result the same cell is always being addressed. In terms of problem (a) above, what would your algorithm now test the memory for?
Explanation / Answer
Answer:
a)Algorithm :
typedef unsigned char datum;
datum
testMemoryStorageLocation(volatile datum * address)
{
datum data;
for (data = 1; data != 0; data <<= 1)
{
*address = data;
if (*address != data)
{
return (data);
}
}
return (0);
}
b)Algorithm :
datum *
testAddressMemoryLocation(volatile datum * baseaddresslocation, unsigned long nBytes)
{
unsigned long maskaddresslocation = (nBytes/sizeof(datum) - 1);
unsigned long offsetvalue;
unsigned long sampleoffsetvalue;
datum data = (datum) 0xAAAAAAAA;
datum finalvalue = (datum) 0x55555555;
for (offsetvalue = 1; (offsetvalue & maskaddresslocation) != 0; offsetvalue <<= 1)
{
baseaddresslocation[offsetvalue] = data;
}
sampleoffsetvalue = 0;
baseaddresslocation[sampleoffsetvalue] = finalvalue;
for (offsetvalue = 1; (offsetvalue & maskaddresslocation) != 0; offsetvalue <<= 1)
{
if (baseaddresslocation[offsetvalue] != data)
{
return ((datum *) &baseaddresslocation[offsetvalue]);
}
}
baseaddresslocation[sampleoffsetvalue] = data;
for (sampleoffsetvalue = 1; (sampleoffsetvalue & maskaddresslocation) != 0; sampleoffsetvalue <<= 1)
{
baseaddresslocation[sampleoffsetvalue] = finalvalue;
if (baseaddresslocation[0] != data)
{
return ((datum *) &baseaddresslocation[sampleoffsetvalue]);
}
for (offsetvalue = 1; (offsetvalue & maskaddresslocation) != 0; offsetvalue <<= 1)
{
if ((baseaddresslocation[offsetvalue] != data) && (offsetvalue != sampleoffsetvalue))
{
return ((datum *) &baseaddresslocation[sampleoffsetvalue]);
}
}
baseaddresslocation[sampleoffsetvalue] = data;
}
return (NULL);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.