COSC 201: Computer Organization

Lab 9: Single Cycle CPU Control

Purpose
Learn to how to implement instructions for a CPU.
Method
Work in teams of 2 to implement the control for the instruction set architecture from Lab 2 and Lab 8.
Preparation
Read sections 5.1 through 5.3 in the text. Review the solution to Lab 2.
Files to Use
circuit diagram (control.sim)
What to Hand In
Turn in a written report including:

The file control.sim contains an incomplete implementation of the instruction set architecture (ISA) from Lab 2 and Lab 8. Your task is to complete the branch control, arithmetic control, and memory control circuits.

  1. Construct truth tables for the branch control, arithmetic control, and memory control circuits. Use "don't care" when possible to simplify the tables.
  2. Construct circuits to implement your truth tables.
  3. Test your CPU using each of the test programs below.

Test Programs

Translate each of the following assembly language programs into machine language. Enter the machine language into the program memory using hexadecimal notation. Run each program to test your CPU.


nop is a pseudo-instruction that does nothing. It is equivalent to an unconditional branch with an address offset of 0. Fill program memory with nop instructions. The program counter should increase by 1 as each nop instruction is executed.

	nop			# no operation (branch 0)

hlt is a pseudo-instruction that halts the CPU. It is equivalent to an unconditional branch with an address offset of -1. Replace one of the nop instructions with a hlt instruction. The program counter should increase by 1 as each nop instruction is executed. The program counter should stop changing when the hlt instruction is reached.

	hlt			# halt (branch -1)

This program loads a value from the first location in data memory and copies it to the next location in data memory. Enter a hexadecimal value into the first data memory location before executing this program.

	sub	$0, $0		# clear R0
	lw	$1, 0($0)	# load R1 from mem[0]
	sw	$1, 1($0)	# store R1 into mem[1]

This program loads a value from the first location in data memory, adds 1, then stores the result in the next location in data memory. Enter a hexadecimal value into the first data memory location before executing this program.

	sub	$0, $0		# address = 0
	lw	$1, 0($0)	# load n from mem[0]
	addi	$1, 1		# add 1
	sw	$1, 1($0)	# store n+1 in mem[1]

This program loads a value n from the first location in data memory and then fills the first n memory locations with the values from 0 to n-1. Enter a hexadecimal value into the first data memory location before executing this program.

	sub	$0, $0		# n = 0
	lw	$1, 0($0)	# limit = mem[0]
loop:	sw	$0, 0($0)	# mem[n] = n
	addi	$0, 1		# n++
	cmp	$0, $1		# compare n to limit
	blt	loop		# while(n < limit)
	hlt			# halt

Each team should hand in a written report including the following:

Also place one copy of the file control.sim in the ~/courses/201/assignments directory of one team member. Send e-mail to your instructor indicating where the file can be found. Be sure that your names appear in the comments for the main circuit.