Problem A (Memory mapped IO): (2 pts) One of the common ways to implement IO is to make Input/Output (IO) hardware look like memory cells. Then memory accesses (e.g., lw and sw) are used by software to interact with the hardware.
The following is an example of IO hardware. The example hardware is the receiver circuitry from a computer keyboard. The hardware consists of two memory cells:
(Note that an ASCII is the way text characters are represented in binary. Section 3.7 of the textbook describes the ASCII code, which translates an 8-bit binary number into a charcter, and vice versa. Figure 3.15 on page 142 shows the code. For example, the 8-bit number with value 65 represents the character "A".
In the C language, char data type is in the ASCII form.)
The following assembly language program implements getchar(),
the
C function that gets a character from the keyboard. It assumes that the
character is returned in $2 (in the least significant byte).
getchar:
lui $t0,0xffff # Load the upper half of $t0 with
# 1111111111111111, and the lower
# half with 0000000000000000.
wait:
lbu $at,0xc($t0) # Load $at with Receiver Control Reg.
# Here we use the "load byte
# unsigned" instruction (see pg.
# A.65).
andi $at,$at,2 # Mask all bits in $at except bit 1.
# Note that the mask is the
# constant 2, which is
# 0000..00010 in binary.
beq $0,$at,wait # If no new ACII byte then wait.
lbu $2,0x8($t0) # Put new ASCII byte from Receiver
# Data Register into $2
jr $31
Note
Now there are two IO registers to transmit ASCII charcters to a computer terminal.
Write an assembly language subroutine that implements putchar(char
c), the C function that outputs a character. The argument "c",
which is an ASCII byte, is passed through the least signifcant byte of
register $a0. You may use registers $at and $t0 for temporary storage.
Your assembly language subroutine have a comment line at the top
that has your name and the date, e.g.,
# Author: John Doe. Date: 10/6/04
By the way, these little programs are called drivers.
Instructions to turn in program file: Submit the program
file by emailing it to the grader Steven Williamson (WILLSTEVO@aol.com)
by 1230pm 10/6/04, also cc it to me at sasaki@spectra.eng.hawaii.edu.
The subject heading of the email should be "EE361 Hw 6".
The program file should be named
"YourLastNameFirstInitial_Hw6.s". For example in my case, the
file name would be "SasakiG_Hw6.s".
Problem B (not graded, 0 pts) In the Bucknell Verilog Handbook, there's a First Verilog Program. Get that program to work. Use the verilog simulator called Veriwell. There's a copy of Veriwell in the "Veriwell" Folder on the EE PC Server (it has a green square icon). You can also download a zipped version of Veriwell from our EE 361 web site. Skim through the Bucknell Verilog Handbook and in particular Sections 1 and 2. Run the Veriwell simulator. The handbook has description of using the Veriwell simulator in Section 3, which you should skim through as well. But it's for an old version of the simulator. The following are some hints for the simulators we have on the PCs:
It's important to do the problem even though
it's not graded.