- About
- Number Formats
- Modules
- Simulation
- Test
- Helper Script
- Status
- Issues
- Licence
This project was originated from a laboratory assignment and rewritten with Xilinx Vivado to work on Digilent Basys 3 FPGA. Two adder and two multiplier modules implemented, one working with fixed point numbers, other with floating point (binary16) numbers.
Fixed Point Format:
Most significant 8 bits represent integer part and least significant 8 bits represent fraction part.
i.e. IIIIIIIIFFFFFFFF
= IIIIIIII.FFFFFFFF
Floating Point Format:
binary16 (IEEE 754-2008) is used. MSB is used as sign bit. 10 least significant bits are used as fraction and remaining bits are used as exponent.
For SEEEEEFFFFFFFFFF
:
Exponent | Fraction is 0 | Fraction is not 0 |
---|---|---|
b00000 |
0 | (-1)^S * 0.FFFFFFFFFF * 2^(-14) |
b00001 to b11110 |
(-1)^S * 2^(EEEEE-15) | (-1)^S * 1.FFFFFFFFFF * 2^(EEEEE-15) |
b11111 |
Infinity | NaN |
Flags:
Flag | Description |
---|---|
overflow | Result does not fit or is infinite |
zero | Result is zero |
NaN | One or both of the operands are not a number |
precisionLost | Result has errors due to precision lost |
Module fixed_adder
is a simple 16 bit adder with overflow signal. Overflow signal can also be used as 17th bit of result.
Ports:
Port | Type | Width | Description |
---|---|---|---|
num1 | I | 16 | First operant |
num2 | I | 16 | Second operant |
result | O | 16 | Result of the addition |
overflow | O | 1 | Overflow flag or bit 17 of the result |
I: Input O: Output
Module fixed_multi
multiply two 16 bit fixed point numbers. Multiplication is in 32 bit, thus no precision lost during multiplication process. Result can be obtained either in 32 bit or in 16 bit. 32 bit format is similar to 16 bit format, 16 most significant bits represent integer part and 16 least significant bits represent fraction part. For 16 bit result overflow and precision lost flags implemented.
Ports:
Port | Type | Width | Description |
---|---|---|---|
num1 | I | 16 | First operant |
num2 | I | 16 | Second operant |
result | O | 16 | 16 bit result of the multiplication |
overflow | O | 1 | Overflow flag |
precisionLost | O | 1 | Precision lost flag |
result_full | O | 32 | 32 bit result of the multiplication |
I: Input O: Output
Module float_adder
is an adder module that can add two half-precision floating-point format (binary16) numbers.
Ports:
Port | Type | Width | Description |
---|---|---|---|
num1 | I | 16 | First operant |
num2 | I | 16 | Second operant |
result | O | 16 | Result of the addition |
overflow | O | 1 | Overflow flag |
zero | O | 1 | Zero flag |
NaN | O | 1 | NaN flag |
precisionLost | O | 1 | Precision lost flag |
I: Input O: Output
Module float_multi
is an multiplier module that can multiply two half-precision floating-point format (binary16) numbers. Currently, multiplying a normal and a subnormal value does not work properly.
Ports:
Port | Type | Width | Description |
---|---|---|---|
num1 | I | 16 | First operant |
num2 | I | 16 | Second operant |
result | O | 16 | Result of the multiplication |
overflow | O | 1 | Overflow flag |
zero | O | 1 | Zero flag |
NaN | O | 1 | NaN flag |
precisionLost | O | 1 | Precision lost flag |
I: Input O: Output
Fixed point modules simulated using operatorCore_sim.v
. It contains four test cases.
Floating point adder module simulated using float_add_sim.v
. It contains ten test cases.
Floating point multiplier module simulated using float_multi_sim.v
.
Number switches
: Used to enter operandsReset/New calculation (Center button)
: Used to reset system or begin new calculationOperator buttons
: Switch operation, legend follows as:Up button
: Floating Format AdditionLeft button
: Floating Format MultiplicationDown button
: Fixed Format AdditionRight button
: Fixed Format Multiplication
Overflow LED (Leftmost LED)
: Indicates overflow during operationZero LED (Second Leftmost LED)
: Indicateds zero resultNaN LED (Third Leftmost LED)
: Indicates NaN errorprecisionLost LED (Forth Leftmost LED)
: Indicates precision lost during operationState LEDs (Rightmost two LEDs)
: Shows machine state, States follow as:IDLE
: System does nothing, waits for user inputWAIT1
: System stores operand 1WAIT2
: System stores operand 2RESULT
: Results are shown, operation can be changed for provided numbers
Seven Segment Displays
: Shows operation result in hexadecimal format
- This project provides a 16 bit adder multiplier hardware and interface for testing designed hardware
- System works on two number formats shown at number formats section
- Output is provided in the same format as the operands
- Flow:
- Start with
Reset/New calculation
button. - Enter the first operand via
Switches
and press any one of theOperator buttons
. - Enter the second operand via
Switches
and press any one of theOperator buttons
. - System will calculate results for all of the modules. Shown output can be chosen via
Operator buttons
. - To initiate a new calculation press
Reset/New calculation
button.
- Start with
Helper python 3 scripts are added to help verfication. They can be found at Scripts directory. Script can be used to calculate operation results for binary16 format or decode 16 bit binary16.
Simulation:
- Fixed Point Modules: 9 January 2021, with Vivado Simulator.
- Floating Point Adder: 22 May 2021, with Vivado Simulator.
- Floating Point Multiplier: 23 May 2021, with Vivado Simulator.
Test:
- Fixed Point Modules: 22 May 2021, on Digilent Basys 3
- Floating Point Adder: 22 May 2021, on Digilent Basys 3
- Floating Point Multiplier: 22 May 2021, on Digilent Basys 3
- Minor bug in floating multiplier module. Some of the results incorrect. See issue #4.
CERN Open Hardware Licence Version 2 - Weakly Reciprocal