Question: I need help revising this code in NIOS II DE - 1 0 Lite . Make sure to address the simple error . I want

I need help revising this code in NIOS II DE-10 Lite . Make sure to address the simple error . I want to see every single LED that is turned on go to the seven segment digit display. I want it to constantly run. I want the program to have fine details explaining how we can get the amount of switches to the LEDS. First I will give you the assignment, then I will give you the code I have so far. I just need help compiling successfully in CPULator . Please fix the code according to the assignment and give detialed description of the code and how it should run
Assignment:
My addresses for all my devices :
LED Base : 0xff200000
Seven Seg Display : 0xff200020
Swtiches : 0xff200040
In NIOS II DE-10 Lite I need a program that has 50 lines of code that does the following :
1.) Uses 3 Devices
2.) Uses Infinite Loops and allows user interaction until stopped
3.) The first change is functionable
4.) The Second change is functionable
5.) Overall program functions as described in the proposal's minimum requirements
6.) At-Least 60 Lines of NIOS II DE-10 Lite Instructions
7.) Meaningful and accurate comments included with every instruction
8.) Detailed program gives after . End directive
1.) The program I want to make allows the user to control LEDs on the DE10-Lite board using the board's switches as the input device. Each switch corresponds to one LED, and the program would read the state of the switches and updates the LEDs accordingly. The program I want to make, would use an infinite loop, that constantly checks the switches and adjusts the LEDs based on the switch state the user decides to select.
2.) My Input device would be using the switches. My Output would be the LEDS
3.) User Input: The user interacts with the program by toggling the switches.
Each switch corresponds to one of the 10 LEDs, allowing the user to control each LED individually deciding what switch the user would want to use.
4.) The program controls the 10 LEDs on the DE10-Lite board according to the state of the switches.
If the switch is on or off it directly affects the corresponding LED on or off
5.) First Change: Reading the switch inputs.
The program would continuously read the state of the switches.
The program uses this input to determine which LEDs should be turned on or off.
6.) Second Change : Update the LEDs based on the switch inputs.
The program would update the state of the LEDs based on the current state of the switches.
This mapping is direct, with each switch controlling one LED.
7.) Third Change: Looping back to continuously read switches and update LEDs.
The program continuously loops back to read switch inputs and update the state of the LEDs accordingly depending on the users input .
The use of the Infinite loop ensures real-time control of the LEDs based on switch input.
8.) After the user flips a switch, the count of the number of switches currently in the "on" position will show in the 7-seg display.
Current Code : .equ LED_BASE, 0xFF200000 ### Base address of LEDs
.equ SW_BASE, 0xFF200040 ### Base address of switches
.equ SEG7_BASE, 0xFF200020 ### Base address of 7-segment display
.section .text
.global _start
_start:
movia r2, LED_BASE ### Load LED base address
movia r3, SW_BASE ### Load switch base address
movia r4, SEG7_BASE ### Load 7-segment display base address
update_leds:
movi r5,0 ### Initialize switch count to 0
## Read switch state and update LEDs
movi r6,0xA ### Total number of switches
loop_read_switches:
ldwio r7,0(r3) ### Read switch state
andi r7, r7,1 ### Mask out switch state
stwio r7,0(r2) ### Update corresponding LED
addi r3, r3,4 ### Move to next switch
addi r2, r2,4 ### Move to next LED
add r5, r5, r7 ### Update switch count
subi r6, r6,1 ### Decrement loop counter
bne r6, zero, loop_read_switches ### Continue loop if not all switches read
## Display switch count on 7-segment display
mov r6, r5 ### Copy switch count to register
mov r7, zero ### Initialize display offset
movi r8,1000 ### Value for converting switch count to BCD
loop_display_count:
divu r9, r6, r8 ### Divide switch count by 1000
muli r9, r9,1000 ### Multiply quotient by 1000
sub r6, r6, r9 ### Update switch count
addi r9, r9,'0' ### Convert quotient to ASCII
stwio r9,0(r4) ### Display digit on 7-segment display
addi r4, r4,4 ### Move to next display
divu r8, r8,10 ### Shift divisor to next decimal place
bne r8, zero, loop_display_count ### Continue loop if more digits to display
br update_leds ### Repeat indefinitely

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!