ECE 371 Lab 1 -- RAM Experiment

OBJECTIVE:   Design and implement a RAM interface with 8K bytes at a specified base address.  A "C" language application must be written to verify the implemented design.

EQUIPMENT NECESSARY:
Breadboard
74138 3-to-8 Decoder
SRM2264L 8K x 8 bit RAM memory chip

PRE-LAB:
1.  Design a circuit to uniquely interface the 8K byte RAM chip to the ISA bus using a starting address of D000:4000H (remember the shift to create the 20-bit address).  The overall physical address range will be D4000H to D5FFFH (remember that the H stands for HEX notation).  Incorporate the correct control signals from the breadboard in your design.  Draw a detailed schematic to show your designed circuit.  This design should include pin numbers and names.

2.  Write a "C" language program that will test your RAM memory as follows.  For each byte location of the interfaced memory, the following tests must be performed. NOTE: DATA refers to the information you will write to the specific memory address.
 (a)  WRITE operation ::: DATA = address mod 256 (remember that this is the last 8 significant bits of the memory address) The DATA should be written to location "address". (remember that the "0x" notation means HEX number)
 
DATA
ADDRESS
0x00 0xD4000
0x01 0xD4001
... ...
0x3A 0xD423A
... ...
0xFF 0xD5FFF

(b)  READ operation :::  read contents of each location and check for correct results
(c)  WRITE operation ::: DATA = boolean_complement(address mod 256)  The DATA should be written to location "address"
 
DATA
ADDRESS
0xFF 0xD4000
0xFE 0xD4001
... ...
0xC5 0xD423A
... ...
0x00 0xD5FFF

For each test value written the program should display:  the value written, the present memory address, and the value read from memory.  If an error is detected, the program should print a message that indicates that an error was found as well as the following information:  the address that the error occurred at, the written value and the read value.

PRE-LAB:
1.  Read over the assignment and be sure you understand the concepts.
2.  Write your program <see interface below>
3.  Draw a schematic that shows the connection of the parts involved.

DURING LAB:
1.  Implement your RAM memory design.
2.  Make corrections (if necessary) to your schematic.
3.  Execute your test program to verify that is works.
4.  Make corrections (if necessary) to your program.
5.  Make sure the TA checks your work (circuit and program) prior to leaving.

POST-LAB:
1.  Write a report describing your design, testing procedures, and observations.
2.  The report must include:  (a) a correctly drawn schematic (b) a well commented printout of your program

PROGRAMING COMMENTS:
Using the Borland Turbo C software package, one method for reading and writing to memory is to map an unsigned character array of 8K bytes into the 8K memory chip address range as follows:
----------------------------
        #include <stdio.h>
        #include <dos.h>
        ---
        unsigned char far *p;                        // p is a far pointer
        p = MK_FP(0xD000,0x4000);        //  set the value of p to the base address of memory
----------------------------
This code fragment makes the variable 'p[i] be mapped to the address D4000+i.

Another method is to use the function calls 'peekb' and 'pokeb' as follows:
----------------------------
        pokeb(0xD000,0x4000+i, data);      // writes
        data = peekb(0xD000,0x4000+i);    // reads
----------------------------

HINTS:
1.  To address the RAM chip to the address range, first convert the address to a binary number and assign each place holder a name like A0, A1, ... A19.  Now visualized the range as a Boolean equation that asserts TRUE when you are in the range and FALSE when you are not in the range.  After doing this, simply attach the input lines to the 74138 decoder.  You can use the select and enable lines as inputs to achieve what you want.  REMEMBER:  The little bubbles indicate active low inputs ( 0 VDC means active ).

2.  The modulo operator in C is the "%"
        Ex.  1024 mod 256 in c would be:    1024%256
 

THINGS TO ASK YOURSELF:
1.  How many lines do I really need to UNIQUELY address that range?
2.  How can I manage with only the 6 lines available to me on the 74138 decoder?