Computer Science 251
Computer Organization

Dickinson College
Fall Semester 1999
Grant Braught


Sample Project Assignment:


Even Parity Checker: (Due: 2/2/22)

For this project you will design and test a four bit odd number detector. Your circuit should output a 1 if the 4 bit input represents an odd number and output a 0 if the 4 bit input represents and even number.

For example:

Input: Output: 0101 1 -- The input is an odd number (5) 0010 0 -- The input is an even number (2)

Sample Design Document:


Introduction:

In this project we design implement and test an even number detector. This circuit is capable of determining if a 4 bit binary input is odd or even. The circuit accepts as input a 4 bit binary number and generates one bit as the output. The output bit will be 1 if the input is even and 0 if the input is odd. Figure 1 shows a black box representation of the circuit:



Figure 1: Black-box Even Number Detector.


Design:

To design our even number detector we expressed the function in truth table shown in Table 1. From this table a sum-of-products expression for the even number detector was generated (eq. 1).

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Z = A B C D + A B C D + A B C D + A B C D + A B C D + A B C D + A B C D + A B C D (1)

A SOP expression can always be implemented in a straight forward manner. However, in this case there is a much more efficient solution. Looking at the truth table we noted that Z=1 only when D=0. Thus, it appears that the even number detector can be implemented using a single not gate. To verify this observation we applied the rules of Boolean Algebra to simplify equation 1 as follows:

_ _ _ _ _ _ _ _ _ _ _ _ Z = A B D (C + C) + A B D (C + C) + A B D (C + C) + A B D (C + C) Distributive + _ _ _ _ _ _ _ _ = A B D + A B D + A B D + A B D Inverse + _ _ _ _ _ = A D (B + B) + A D (B + B) Distributive + _ _ _ = A D + A D Inverse + _ _ = D (A + A) Distributive + _ = D Inverse +

Thus, the function of determining if a number is even requires no more than inverting the least significant bit.


Table 1: Truth Table for Odd Number Detector

Test Cases:

Because the number of inputs is small, the even number detector can be tested exhaustively. This will be done by VHDL test bench that drives the inputs with all 16 possible inputs (see table 1). The output generated in response to each input pattern will then be compared by hand to the Z value in table 1 to check for correctness.

Implementation:

The file evendet.v attached to this document contains the VHDL implementation of the even number detector. The evendet entity makes use of the notGate component defined in the lgates.v file to invert the LSB of the input. The file even_test.v attached to this document contains the VHDL test-bench for the even number detector. This test-bench implements the exhaustive tests described above.

Test Results:

The lgates.v, evendet.v and even_test.v files were all analyzed into a VHDL library using the va87 Vanilla VHDL analyzer. The vs87 simulator was then used to simulate the system while tracing the tst and e signals from the even_test.v test-bench. The output of the test bench has been displayed graphically in figure 2 through the use of the vanplot and gnuplot software packages.


Figure 2: Even Number Detector Test Bench Output

In figure 2, e represents the output of the even number detector and tst(3)...tst(0) are the inputs. By comparing the inputs to the output it can be seen that e is high (true, 1) only when an even number of the tst inputs are high. Thus, because the tst presented every possible input to the circuit and e is correct in all cases, the circuit is correct.