EEC 281 - Homework/Project #3

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. Please send an email to me if something is not clear and I will update the assignment using green font.

Notes:


155 points total

  1. [20 pts] Using matlab, write a function which calculates the minimum number of partial products needed to calculate the product of a number multiplied by a fixed number. Both +multiplicand and –multiplicand partial products are allowed. Consider positive and negative numbers with a resolution of 0.5 (e.g., 0, 0.5, 1.0, ...). For example, a multiplicand of +5.5 should result in 3 partial products (either +4, +2, –0.5; or +4, +1, +0.5).

    Use your own algorithm, or try an algorithm that works like this:

    a) [15 pts] Write the described function in matlab.

    b) [5 pts] Assuming your function is called numppterms(), run the following bit of matlab code (a few points need fixing), submit the figure, and report the Total Sum for all numbers 0.5 – 100.00 .

       StepSize = 0.5;
       NumTermsArrayPos = zeros(1, 100/StepSize);    % small speedup if init first
       for k = StepSize : StepSize : 100,
          NumTermsArrayPos(k/StepSize) = numppterms(k);
       end
    
       fprintf('Total sum for +0.5 - +100.00 = %i\n', sum(NumTermsArrayPos));
    
       figure(1); clf;
       plot(StepSize:StepSize:100, NumTermsArrayPos, 'x');
       axis([0 101 0 1.1* max(NumTermsArrayPos)]);
       xlabel('Input number');
       ylabel('Number of partial product terms');
       
  2. ———————————————
  3. [30 pts] An FIR filter has the coefficients,
       coeff = [–15   –47   141   370   141   –47   –15];
       
    Assume the coefficients cannot be scaled smaller, but they can be scaled up to 2× larger. This implementation works with integers only, so round() all scaled coefficients.

    a) [5 pts] How many partial products are necessary to implement the FIR filter with the given coefficients?

    b) [5 pts] Find the scaling for the coefficients that yields the minimum number of partial products.

    c) [5 pts] Turn in a plot of the number of required partial products vs. the scaling factor. The plot should look something like the simulated results this matlab code generates.

       figure(1); clf;
       plot(0.5:0.001:1.0, round(5* rand(1,501)+1), 'x');
       axis([0.48 1.02 0 6.5]);  grid on;
       xlabel('Scaling factor');
       ylabel('Number of partial product terms');
       title('EEC 281, Hwk/proj 3, Problem x, Plot of simulated results');
       
    d) [15 pts] Draw dot diagrams showing how the partial products would be added (include sign extension) for the optimized coefficients you found in (b), using the FIR architecture shown below and a 7-bit 2's complement input word. Use 4:2, 3:2, and half adders as necessary and no need to design the final stage carry-propagate adder.

    ———————————————
  4. [55 pts] Design of an area-efficient low-pass FIR filter. The filter must meet the following specifications when its sample rate is 100 MHz.

    a) [10 pts] Write a matlab function lpfirstats(H) or lpfirstats(H,W) that takes a frequency response vector H from [H,W] = freqz(coeffs) (or a vector of filter coefficients directly) as an input and returns the four critical values listed above (passband ripple, etc.).

    b) [10 pts] Either by hand or with a matlab function, repeatedly call lpfirstats(H,W) to find a reasonable small area filter. There is no need to write a sophisticated optimization algorithm, just something reasonable that does more than simple coefficient scaling. For example, making small perturbations to the frequency and amplitude values that remez() uses such as using 0.01 and other small values instead of 0.00 in the stopband.

      It may be helpful to use the following matlab code. Remember that matlab vectors start at index=1 so H(1) is the magnitude at frequency=0.

             coeffs1   = remez(numtaps-1, freqs, amps);
             coeffs2   = coeffs1*scale;
             coeffs    = round(coeffs2);
             [H,W]     = freqz(coeffs);
             H_norm    = abs(H) ./ abs(H(1));
             [ripple, minpass, maxstoplo, maxstophi] = lpfirstats(H_norm,W); 

      Assume area is: Total_num_partial_products + 2*Num_filter_taps

      Examples from a previous year of the difference between good optimizations and weaker ones--these are class results for ten students for a different filter than the one assigned here:
             109 area, 31 taps,  47 PPs
             109 area, 31 taps,  47 PPs
             113 area, 33 taps,  47 PPs
             114 area, 33 taps,  48 PPs
             123 area, 33 taps,  57 PPs
             128 area, 34 taps,  60 PPs
             182 area, 55 taps,  72 PPs
             221 area, 59 taps, 103 PPs
             221 area, 59 taps, 103 PPs
             250 area, 61 taps, 128 PPs
             
    c) Provide the following for your smallest-area filter in your paper submission.

      i) [5 pts] Filter coefficients

      ii) [10 pts] The number of taps, number of required partial products, area estimate, and the attained values for the four filter criteria in dB.

      iii) [10 pts] A plot made by: plot_one_lpfir.m (that requires updating) to show the filter's frequency response.

      iv) [5 pts] A stem() plot of the filter's coefficients.

    d) [5 pts] Upload to canvas: i) Your modified version of plot_one_lpfir.m, and
        ii) Filter coefficients for your smallest-area filter in a matlab-readable vector in a text file called coeffs.m; for example:
        % coeffs.m
        coeffs = [1 4 -8 25 -8 4 1];

  5. ———————————————
  6. [40 pts] Design an adder that adds four 2's complement 4-bit inputs and then saturates the sum to 4 bits. Submit the following:
    1) [5 pts] a circuit diagram,
    2) [5 pts] calculate the range of the unsaturated sum, and the range of the saturated output,
    3) [10 pts] a dot diagram,
    4) [10 pts] verilog for the design using "+" for the adders,
    5) [10 pts] test your verilog design with at least 15 test cases including all extreme input cases, and verify using method ***(1).



EEC 281 | B. Baas | ECE Dept. | UC Davis
Updates:
2022/02/11  Posted