Question: Assignment # 1 0 Due: May 3 , 2 0 2 4 This is a required homework. It also has some extra credits. Please upload
Assignment # Due: May
This is a required homework. It also has some extra credits. Please upload your homework
solutions to Canvas. You need to upload your asm file and a single pdf file containing your
screenshots.
pts pts Extra Credit
In order to get the extra credit, your code should be working properly, and you need to upload both your
asm code and the pdf containing the screenshots.
In this assignment, we will use MPLabX to develop and simulate an assembly language program for the
PIC microcontroller that plays the guessing game, as described in Section of the Wakerly textbook,
th ed The assembly language program is to be tested using MPLab to apply the sequence of inputs
given below. The state diagram for this homework is modified such that there is a WIN output connected
to a green light showing that the guess was right WIN is asserted in the SOK state and the green light
turns on if the guess was correct
This state machine has inputs and outputs. Students should use the PICFA The required pin
assignments are given in the following table.
Required Pin Assignments
Inputs Right Outputs
Function PIC Function PIC
G RA L RB
G RA L RB
G RA L RB
G RA L RB
ERR RB
WIN RB
A high output is used to turn on a light while a low output signifies that the light is off.
Programs should initialize to state S and include a delay of ~ second from one state to the next in the
rotating light pattern. This delay could be created in different ways, for example, using a simple program
loop, or using a timer with or without interrupts. It need not be precise, but should be accurate to pm
seconds. You may choose your processor clock frequency to adjust the state delay.
The program should be tested using a stimulus workbook guessinggamestimuliSpringsbs
that has been posted on Canvas with this assignment. This external stimulus is applied using
Stimulus open a stimulus workbook from icons to the left of the Stimulus window
being sure to Apply the stimulus before you start debugging your code.
Your solution to this homework should include your documented assembly language code and watch
window to demonstrate that your game responds properly to stimulus. This example shows a watch
window following the first wrong guess. Your solution should show this watch window following each state
change. This can be done most easily by setting breakpoints immediately following each state change in
your code, then running the processor, which will automatically stop at each state change. You need to
use a processor frequency of kHz instruction frequency Fcyc kHz
Sample Display window following the first correct guess
Hints and Suggested Approach
Computation of the next state could potentially follow the approach used in the textbook which is geared
for implementation using Verilog and logic hardware. There are other approaches, however, which are
more sensible for a byte oriented, general purpose machine such as the PIC. For example, the state
could be onehot encoded to match the outputs, and the nextstate could be computed using the table
lookup or by ifthen statements that consider the present state and the inputs.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
