Scientific calculator on Intel DE10-lite FPGA + NIOS II processor.
-
Calculator is capable of the following:
- Addition, Subtraction, Multiplication, Division, Log10, Power, Factorial, Degrees to Radians, Negative numbers
- Using Verilog to debounce keypresses
- Carrying over answer of previous operation to operand 0 of next equation
- Displaying answer on DE10-lite seven segment displays (truncated)
- Displaying "double" formatted answer to a PC using NIOS II UART
-
Requires a Digilent PMOD keypad to run this program: https://store.digilentinc.com/pmod-kypd-16-button-keypad/ -NOTE THIS PROJECT WAS DONE USING QUARTUS 18.1; IF YOU SEE WEIRD RESULTS IT'S DUE TO VERSION DIFFERENCES
Pinout for DE10-lite (PG 30): https://www.intel.com/content/dam/www/programmable/us/en/portal/dsn/42/doc-us-dsnbk-42-2912030810549-de10-lite-user-manual.pdf
Pinout for keypad is as follows:
(Keypad Pin,DE-10 lite): (Pin 1, Pin_W12), (Pin 2, Pin_AB12), (Pin 3, Pin_AB11), (Pin 4, Pin_AB10), (Pin 5, GND), (Pin 6, 5/3.3V), (Pin 7, Pin_AB13), (Pin 8, Pin_Y11), (Pin 9, Pin_W11), (Pin 10, Pin_AA10), (Pin 11, GND), (Pin 12, 5/3.3V)
General State Machine:
State 0:
- Reset (async: enter this state via KEY0 pushbutton)
State 1:
- Type in operand 0 using keypad, enter the number by pressing KEY1 pushbutton
- Advance to state 2
State 2:
- Choose operator
- SW9 is off
- SW0 is on -> Add
- SW1 is on -> Sub
- SW2 is on -> Mul
- SW3 is on -> Div
- SW9 is on
- SW0 is on -> Log_2
- SW1 is on -> Pow
- SW2 is on -> Fact
- SW3 is on -> D2r
- SW9 is off
- Enter desired operator by pressing KEY1 button
- Advance to state 3
State 3:
- Type in operand 1 using keypad, enter the number by pressing KEY1 button
- Advance to state 4
State 4:
- Show the output of the operation. Output will show in NIOS II uart terminal (in double format); output will also show on SSD on FPGA dev board. Obviously the uart terminal will show the best and most accurate results
- Press KEY1 to use output as operand0 and advance to state 2
- Press KEY0 to reset operation and advance to state 0
Easiest way to run the project:
- Download the .qar file
- Open the .qar file using Quartus
- Run compilation
- Program the FPGA
- In file explorer, open "Calculator_restored -> software -> nios2_uart_sw_bsp" directory
- Edit "settings.bsp" 6a. Change "BspGeneratedLocation" path to whatever the path to the directory is on your pc (inside of generated Calculator_restored project directory) 6b. Change "SopcDesignFile" path to whatever the path to the .sopc file is on your pc
- In Quartus -> tools -> nios ii software build tools for eclipse
- Eclipse opens, open workspace at "Calculator_restored -> software"
- Go to "File -> import", then "general -> existing projects in workspace", then "browse" 9a. Navigate to "Calculator_restored -> software" and press ok 9b. Under "Projects", "nios2_uart_sw" and "nios2_uart_sw_bsp" will show up, make sure they have check-marks next to them and press finish 9c. "nios2_uart_sw" and "nios2_uart_sw_bsp" should show up under project explorer at this point
- Go to "Nios II -> BSP Editor" in top bar
- "File -> open", navigate to "Calculator_restored -> software -> nios2_uart_sw_bsp", and open "settings.bsp"
- Hit "generate" and exit BSP editor
- Right-click "nios2_uart_sw_bsp" directory in the project explorer and press "NIOS II -> Generate BSP"
- Project -> Build all
- Run -> Run configurations 15a. Double-click "nios II hardware" 15b. "New_configuration" will show up, click on it 15c. Under "new configuration", go to project, press on project name and select "nios2_uart_sw" 15d. Go to "target connection", make sure you can see USB Blaster (if you can't, hit refresh connections), select the USB Blaster, and click run