Floating point multiplication automata

  • Soft Deadline: 22.12.2023, 23:59
  • Hard Deadline: 28.12.2023, 23:59
  • Publish date: 13.12.2023
  • Last update: 13.12.2023, 23:50
  • History:
    • 13.12.2023, 23:50
      • Publish the assignment

Objectives

This assignment exercise the basic notions of Verilog by implementing complex sequential circuits. You will:

  • Understand numeral representations by implement an arithmetic algorithm for processing integer numbers
  • Divide and conquer - implement a finite state machine, based on a given scheme;
  • Interact with memory elements (register) when you process the data;

Description and requirements

Floating point has a long history in the engineering field and in computer science. The promoter was Leonardo Torres Quevedo back in 1914; nowadays, we use IEEE754 Standard Implementation. Wiki The assignment consists in implementing a floating point multiplication algorithm for 2 numbers with the following format (S_EEEE_MMMMMMM):

  • 1 sign bit - S
  • 4 exponent bits - E
  • 7 mantissa bits - M

The implementation can follow the proposed state machine: Because we encounter a multiplication of fixed point (mantissa), we should implement a dedicated module responsible for this operation. The Booth algorithm is a suitable option which reduces the complexity but keeps a good understanding behind. The size of the operands is dependent on the size of the mantissa.

Requirements:

  1. Implement Booth algorithm in the dedicated file for 2 8bit operands:
    1. Take 2 random 8bit numbers of your choice and demonstrate the algorithm on the paper;
    2. Implement the Verilog code.
  2. Implement the floating point multiplication algorithm:
    1. Take 2 random 12bit numbers of your choice which respects the floating point format and demonstrate the multiplication on the paper;
    2. Implement the Verilog code.

Don't forget to follow the TODO's inside the code and check for the errors and messages in the console! Checking is implemented inside the testcase!

Implementation

In order to implement the requirements, you shall build a finite state machine to divide the operations executed per clock cycle. This automata communicates with additional modules with determined behavior. The detailed implementation for each module is described below.

floating_point_fsm

Finite state machine to be implemented, this module also acts as a top module for the design (the one that have all the additional modules instantiated in it).

This module respects the following interface:

module floating_point_fsm(
        input         clk,
        input         rst,
        input         en,
        input [11:0]  a,
        input [11:0]  b,
        output reg    done,
        output [11:0] out
    );                

The signals' description for this module is:

  • clk - clock signal;
  • rst - reset signal - used to bring the module back to it's initial state;
  • en - when this signal asserts, it marks the valid information for a and b in the next clock cycle;
  • a - value for the first operand, expressed in sign_exponent_mantissa;
  • b - value for the second operand, expressed in sign_exponent_mantissa;
  • done - 1 when the result is ready;
  • out - the result of the multiplication;

Modifying the outputs to output reg is allowed for this module.

The module functionality is:

  • Storing the input values a and b in their corresponding registers after the en signal gets asserted.
  • Executing the operation and putting it on the output out; when out is available, done shall be one, to signalize that the out is available for the outside modules to be used.

We already have the input (A and B) and output (RES) registers instantiated inside and also an auxiliary register for saving the multiplication result (MUL) with their control signals for writing and reading and the proper connections with the environment, except the ones with the booth_mul.

This module actively used the booth_mul module to perform any multiplication operations needed.

booth_mul

Implements the Booth multiplication algorithm applied on 2 8bit numbers. This module uses combinational logic - the result is available as soon as the inputs change.

This module respects the following interface:

module booth_mul(
        input [7:0] op1,
        input [7:0] op2,
        output [15:0] result
    );

The signals' description for this module is:

  • op1 - holds the operand 1;
  • op2 - holds the operand 2;
  • result - holds the result;

Modifying the outputs to output reg is allowed for this module.

The module functionality is:

  • Trigger the algorithm and change the result every time a or b changes.

Notes

  • For the floating point implementation, the behavior of the register is the one studied in the lab.
  • You can modify the state machine as you like, as long as it respects the requirements.
  • For VIVADO, the top module for simulation is the booth test; when implementing the floating point multiplication, don't forget to change the test

Additional details

  • In the project resources recourses there are already the files that you need and the prerequisite modules.
  • The project archive that you shall upload (zip compression type) must include in it's root only:
    • the floating_point_fsm.v and the booth_mul.v files (you can already find them in the project skeleton);
    • other user-defined files (*.v), if used in your choice of implementation;
    • a README file, which shall contain at least:
      • your name and group;
      • general presentation of your solution;
      • description of any complex coding parts that you consider additional explanation is needed and they are too long to be an inline comment;
    • Pictures/Scans of your paper demonstrations.
  • The archive shall not contain any other files from the implementation folder (i.e. test files, project specific files, etc).

This assignment is an individual assignment; using any code from external sources can be considered as plagiarism and can lead to voiding the accumulated points!

Grading

  • +10.0 pts.: Correct implementation with the tests passing
    • 0.5 pts.: Booth Multiplication Example - 2 8bit numbers on your choice
    • 5.5 pts.: Multiplication Module
    • 0.5 pts.: Floating Point Multiplication Example - 2 12bit numbers with the specified format of your choice
    • 3.5 pts.: Floating Point Multiplication
    • 0.5 pts.: (bonus) Add your numbers in the test file; verify there is a match.
  • -10.0 pts.: using looping instructions with variable steps (i.e. while x > 0);
  • -6.0 pts.: using * operator in the booth_mul implementation;
  • -1.0 pts.: not using the booth_mul module for implementing the FSM
  • -1.0 pts.: the absence of the README file;
  • -1.0 pts.: bad coding style (chaotic indentation, irregular spacing, strange naming for variables, etc.);
  • -0.5 pts.: incorrect using of continuous assignments ( assign ), procedural blocking ( = ) and non-blocking ( ⇐ ) assignments;
  • -0.5 pts.: /day if submitted after the soft deadline;
  • -0.2 pts.: other generic implementation issues (/issue);
  • -0.1 pts.: useless code comments.

Remember that you have an error counter already implemented in each testcase inside the project files, which tells you exactly when an error is detected. However, do not count on that; the project evaluation is done manually, after analyzing the code and the anti-plagiarism report.

Even if you do not finish the assignment, you can receive up to 25% of the grade if you properly explain your idea in the README file. Your code must pass the compilation and run.

Recourses

Appendix

ac-is/teme-ie/proiect.txt · Last modified: 2024/01/07 18:47 by ionut.pascal
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0