The number system that we use for most calculations is base-10, also known as the decimal number system. However, the decimal number system is not the only way of representing or working with numbers. Some advocate the use of a base-12, or dozenal number system. This YouTube video from Numberphile provides an explanation of how dozenal numbers work and highlights some of the advantages that come with using the dozenal number system. This project is a simple dozenal calculator built on the Arty FPGA board using a PmodKYPD for input and a serial terminal for output.
The input to this calculator is a PmodKYPD. Numerals are entered using the 0 - 9 keys and the A and B keys on the KYPD. A and B are used to enter the digits that have the value of ten and eleven. These digits are pronounced 'dek' and 'el' when read as dozenal digits (see the video linked from the introduction for more information). The values 'dek' and 'el' are represented as X and E on the display. The operators are mapped to the remaining four keys on the KYPD.
- C for addition ( + )
- D for subtraction ( - )
- E for division ( / )
- F for multiplication ( * )
See the "Images" section below for an image of the keypad layout as used in this project.
Once an expression has been entered, pressing button 0 on the Arty will evaluate the expression. Pressing button 3 on the Arty will end the program.
There is no way to enter negative numbers or floating point numbers. The calculator only performs integer arithmetic, so the result of a computation can be negative, but not a floating point number.
This calculator will only accept expressions written in infix notation that contain two operands and one operator (e.g. 8 + 4). The behavior of this calculator is undefined for illegal input.
To set up this project follow the Getting Started with Digilent Pmod IPs tutorial, adding a PmodKYPD to your design, until you have created a new Empty Application project. Copy the
main.c file provided below into the
src directory of the project you created. Return to the above tutorial to finish programming your board.