Design a circuit to implement part of an ECC memory controller that will encode four data bits into seven encoded bits by adding three even parity bits using the Hamming Code and will take seven encoded bits and correct a single bit error to produce four data bits. Submit a .pdf or .doc (MS Word) or .jpg or .gif or .rtf (rich text format) diagram of your design. Your ECC memory controller should have seven SPDT (Single-Pole Double-Throw) switches named M1 (the LSB), M2, ..., M7 (the MSB) to simulate the input of encoded bits from the actual memory and four SPDT switches named C1 (the LSB), C1, C3, and C4 (the MSB) to simulate the input of data bits from the actual CPU. A SPDT switch named Store will simulate the store signal from the CPU and another SPDT switch named Fetch will simulate the fetch signal from the CPU. You should have four flip-flops to temporarily store the date bits from the CPU, which are guaranteed to be correct on the downward transition of the Store signal. Use the same four flip-flops to temporarily store the decoded data during a fetch (the data should appear at the output of the flip-flops during the downward transition of the Fetch signal). Naturally the four flip-flops should feed into a circuit that encodes the data into seven encoded bits that produce output in Wires named E1 (LSB), E2, ..., E7 (MSB). Also the M1 to M7 bits should feed into a circuit that decodes them, correcting any single-bit errors and stores them into the flip-flops. The flip-flops' outputs should be Wires D1 (LSB) to D4 (MSB). In your circuit design, you must use only the gates: one input Not, and/or two or three input And, Or, Xor, Nand, Nor, Xnor.
Make your design as modular as possible. Do not draw the gates for all four flip-flops! Instead, draw the gates for a single flip-flop and the equivalent black-box (actually drawn as a white box :-). Then use the black-box flip-flop in your main design. You should do the same for your encode a parity bit circuit and then use the black-box encode for each of your three parity bits (each of which has different input bits). Likewise, your four decode circuits should be represented as a black box, possibly with a few additional gates outside the black box for the different D1 to D4 bits.
Create a circuit specification file called ecc.cir to test your design with an improved version of your program from assignment #2, which is available as Circuit.jar. The improved program accepts SPDTSWITCH specifications and And, Or, Xor, Nand, Nor, and Xnor gates. The three-input versions all have a "3" in their names, such as AND3GATE. Here is an example of a circuit spec file for a full adder circuit:
WIRE name preA0 WIRE name preA1 WIRE name preB0 WIRE name preB1 WIRE name preCin0 WIRE name preCin1 WIRE name A WIRE name B WIRE name Cin WIRE name AandB WIRE name AandCin WIRE name BandCin WIRE name Cout WIRE name Sum BATTERY high (preA1 preB1 preCin1) low (preA0 preB0 preCin0) SPDTSWITCH name A connect0 preA0 connect1 preA1 common A SPDTSWITCH name B connect0 preB0 connect1 preB1 common B SPDTSWITCH name Cin connect0 preCin0 connect1 preCin1 common Cin XOR3GATE input1 A input2 B input3 Cin output Sum ANDGATE input1 A input2 B output AandB ANDGATE input1 A input2 Cin output AandCin ANDGATE input1 B input2 Cin output BandCin OR3GATE input1 AandB input2 AandCin input3 BandCin output Cout
Here is a transcript of the program running with full_adder.cir (what you type is in italics):
java -jar Circuit.jar full_adder.cir Please enter the switch position for SPDTSwitch A (0 or 1): 1 Please enter the switch position for SPDTSwitch B (0 or 1): 1 Please enter the switch position for SPDTSwitch Cin (0 or 1): 1 preA0=0 preA1=1 preB0=0 preB1=1 preCin0=0 preCin1=1 A=1 B=1 Cin=1 AandB=1 AandCin=1 BandCin=1 Cout=1 Sum=1 Repeat? (y or n): y Please enter the switch position for SPDTSwitch A (0 or 1): 1 Please enter the switch position for SPDTSwitch B (0 or 1): 1 Please enter the switch position for SPDTSwitch Cin (0 or 1): 0 preA0=0 preA1=1 preB0=0 preB1=1 preCin0=0 preCin1=1 A=1 B=1 Cin=0 AandB=1 AandCin=0 BandCin=0 Cout=1 Sum=0 Repeat? (y or n): y Please enter the switch position for SPDTSwitch A (0 or 1): 1 Please enter the switch position for SPDTSwitch B (0 or 1): 0 Please enter the switch position for SPDTSwitch Cin (0 or 1): 0 preA0=0 preA1=1 preB0=0 preB1=1 preCin0=0 preCin1=1 A=1 B=0 Cin=0 AandB=0 AandCin=0 BandCin=0 Cout=0 Sum=1 Repeat? (y or n): y Please enter the switch position for SPDTSwitch A (0 or 1): 0 Please enter the switch position for SPDTSwitch B (0 or 1): 0 Please enter the switch position for SPDTSwitch Cin (0 or 1): 0 preA0=0 preA1=1 preB0=0 preB1=1 preCin0=0 preCin1=1 A=0 B=0 Cin=0 AandB=0 AandCin=0 BandCin=0 Cout=0 Sum=0 Repeat? (y or n): y
To draw your circuit diagrams, I highly recommend you download a free copy of Visio from MSDNAA. If you prefer MS Word, I have a Word file with gate drawings that you are welcome to use too.
To submit your assignment, zip all of your circuit drawing files, your ecc.cir circuit spec files and the transcript of a sample run and email the zip archive to our TA, dwkang@hawaii.edu.