EEC 281 - Homework/Project #1

Work individually, but I strongly recommend working with someone in the class nearby so you can help each other when you get stuck, with consideration of the Course Collaboration Policy. Send an email to me if something is not clear and I will update the assignment using green font.



Total: 155 points

Before getting started, go through the verilog notes located under Course Readings on the course home page.

  1. [35 pts] Design and write the verilog for a block that adds three 4-bit numbers into a 2's complement output that is sufficiently large to represent all inputs but with no extra bits. Use one stage of 3:2 carry-save adders and one carry-propagate adder (CPA) using a "+" in verilog. The three inputs are as follows:

    a) [2 pts] How many bits does the output have and where is its decimal point?
    b) [4 pts] Show the adder's dot diagram.
    c) [3 pts] What is the output's minimum attainable negative value (nearest –∞)?
    c) [3 pts] What is the output's minimum attainable positive (non-zero) value?
    e) [3 pts] What is the output's maximum attainable positive value?
    f) [20 pts] Test the circuit over at least 15 input values (including extreme cases). Turn in ***, opt. 1
    
                           4     +-------+
                   a ------/-----|       |   
                           4     |       |     ?
                   b ------/-----|   +   |-----/------ out
                           4     |       |
                   c ------/-----|       |
                                 +-------+
       
  2. [35 pts] Design and write the verilog for a block that performs floating point to fixed point number conversion. The floating point input is always normalized and has a 4-bit 2's complement mantissa in "3.1" format and a 3-bit 2's complement integer exponent. The fixed point output has enough bits to fully represent the converted floating point number, but no more.
    a) [6 pts] How many bits does the fixed-point output have and where is its decimal point?
    b) [3 pts] What is the output's minimum attainable negative value (nearest –∞)?
    c) [3 pts] What is the output's minimum attainable positive (non-zero) value?
    d) [3 pts] What is the output's maximum attainable positive value?
    e) [20 pts] Test the circuit over at least 15 input values (including extreme cases). Turn in ***, opt. 1
    
                           4     +--------+
            mantissa ------/-----| float  |     ?
                                 |  to    |-----/------ out
                 exp ------/-----| fixed  |
                           3     +--------+
       
  3. [35 pts] Design and write the verilog for a block that performs fixed-point to floating-point number conversion. The input fixed-point number has 7 bits and is in "5.2" 2's complement notation. The floating point output has a 4-bit "3.1" 2's complement mantissa and a 2's complement integer exponent.

    Normalize the output mantissa—the output must never be denormalized. Also keep the maximum possible number of bits from the input in the output mantissa. Note that for some input values, the output will not be able to represent all bits in the input and it will be necessary to reduce the number of bits (through rounding or truncation)—use truncation.
    a) [6 pts] How many bits are required for the exponent?
    b) [3 pts] What is the output's minimum attainable negative value (nearest –∞)?
    c) [3 pts] What is the output's minimum attainable positive (non-zero) value?
    d) [3 pts] What is the output's maximum attainable positive value?
    e) [20 pts] Test the circuit over at least 15 input values (including all extreme cases). Turn in ***, opt. 1
    
                                 +--------+     4 
                           7     | fixed  |-----/----- mantissa
                  in ------/-----|  to    |
                                 | float  |-----/----- exp
                                 +--------+     ?
       
  4. [15 pts] As mentioned in class, there are a number of ways to design a 4:2 adder.
    a) Using the diagram for the 4:2 given below and the truth table below, fill out the truth table with the values that must be a certain value (0 or 1) for the circuit to operate correctly. Leave others blank. A few of these required values have been filled in.
    
                                  a b c d
                                  | | | |
                                  | | | |
                                 +-------+
                                 |       |
                            co --|  4:2  |-- ci
                                 |       |
                                 +-------+
                                   |   |  
                                   |   |  
                                   c1  s  
    
              inputs  | outputs
                    c | c c
            a b c d i | o 1 s
           -----------+-------
            0 0 0 0 0 | 0 0 0
            0 0 0 0 1 | 0 0 1
            0 0 0 1 0 |     1
            0 0 0 1 1 |     0
            0 0 1 0 0 |     1   
            0 0 1 0 1 |         
            0 0 1 1 0 |         
            0 0 1 1 1 |         
            0 1 0 0 0 |         
            0 1 0 0 1 |         
            0 1 0 1 0 |         
            0 1 0 1 1 |         
            0 1 1 0 0 |         
            0 1 1 0 1 |         
            0 1 1 1 0 |         
            0 1 1 1 1 |         
            1 0 0 0 0 |         
            1 0 0 0 1 |         
            1 0 0 1 0 |         
            1 0 0 1 1 |         
            1 0 1 0 0 |         
            1 0 1 0 1 |         
            1 0 1 1 0 |         
            1 0 1 1 1 |         
            1 1 0 0 0 |         
            1 1 0 0 1 |         
            1 1 0 1 0 |         
            1 1 0 1 1 |         
            1 1 1 0 0 |         
            1 1 1 0 1 |         
            1 1 1 1 0 |         
            1 1 1 1 1 | 1 1 1
       
  5. [10 pts] Write verilog for a Full Adder (3:2) module using simple Boolean equations. Write verilog for a 4:2 adder module using two full adder module instantiations keeping in mind the non-rippling requirement for 4:2 adders. Simulate the 4:2 adder over all 32 possible inputs. Turn in *** option 1.


  6. [25 pts] Six-input adder

    a) [10 pts] Draw a dot diagram and write the verilog for a fast adder with six 4-bit signed 2's complement integer inputs and a 6-bit 2's complement integer output. The six-bit output is not wide enough to represent all possible values of the inputs, but it is sufficient for the test cases listed below. Compresses the inputs in carry-save form using your 4:2 and 3:2 adder modules, and add the final "carry" and "save" words using a "+" operator in verilog.

    b) [15 pts] Write a testbench module which instantiates the six-input adder module and test the circuit over the input values shown: Turn in ***

            =   0 +   0 +   0 +   0 +  0 +  0
            =   1 +   0 +   0 +   0 +  0 +  0
            =   0 +   1 +   0 +   0 +  0 +  0
            =   0 +   0 +   1 +   0 +  0 +  0
            =   0 +   0 +   0 +   1 +  0 +  0
            =   0 +   0 +   0 +   0 +  1 +  0
            =   0 +   0 +   0 +   0 +  0 +  1
            =  -1 +   0 +   0 +   0 +  0 +  0
            =   0 +  -1 +   0 +   0 +  0 +  0
            =   0 +   0 +  -1 +   0 +  0 +  0
            =   0 +   0 +   0 +  -1 +  0 +  0
            =   0 +   0 +   0 +   0 + -1 +  0
            =   0 +   0 +   0 +   0 +  0 + -1
            =   7 +   0 +   0 +   0 +  0 +  0
            =   0 +   7 +   0 +   0 +  0 +  0
            =   0 +   0 +   7 +   0 +  0 +  0
            =   0 +   0 +   0 +   7 +  0 +  0
            =   0 +   0 +   0 +   0 +  7 +  0
            =   0 +   0 +   0 +   0 +  0 +  7
            =  -8 +   0 +   0 +   0 +  0 +  0
            =   0 +  -8 +   0 +   0 +  0 +  0
            =   0 +   0 +  -8 +   0 +  0 +  0
            =   0 +   0 +   0 +  -8 +  0 +  0
            =   0 +   0 +   0 +   0 + -8 +  0
            =   0 +   0 +   0 +   0 +  0 + -8
            =   1 +   1 +   1 +   1 +  1 +  1
            =  -1 +  -1 +  -1 +  -1 + -1 + -1
            =   1 +   2 +   3 +   4 +  5 +  6
            =   7 +   4 +   5 +   5 +  5 +  5
            =  -7 +  -5 +  -5 +  -5 + -5 + -5
            



EEC 281 | B. Baas | ECE Dept. | UC Davis
2025/01/15  Posted