sections in this module City College of San Francisco - CS270
Computer Architecture

Module: Simple Machine
module list

Simple Machine Basics

We begin our study of machine models with a very simple fictitious machine. Although this "simple machine" has many of the characteristics of a real machine it is very limited and its instruction format and internal organization are much simpler. It is an easy way to introduce concepts such as the fetch cycle, register transfer notation and instruction encoding without getting caught up in the details inherent in any real machine.

The Simple Machine (SM) has only 15 instructions and uses a wordsize that is 16 bits. All operations, both instructions and data, are performed on 16 bit quantities, and the only data type it can operate on is signed short integer. Thus, its memory can be thought of (and simulated as) an array of 16-bit integers, containing both instructions (interpreted as unsigned) and data (interpreted as signed).

The instruction format is very simple:

bit position
15
14
13
12
11
10
 9
 8
 7
 6
 5
 4
 3
 2
 1
 0
contents
opcode


address

where

Since it is an accumulator-based machine, the register(s) associated with the instruction are implicit in the instruction.

Simple Machine Registers

The Simple Machine registers are also detailed in the SimpleMachine document, but, as a brief review

Simple Machine Programs

The machine starts with an initial pc of 0. Thus instructions must be placed before data in the memory array.

Simple Machine operations are simulated by the Simple Machine simulator, sim. sim simulates the Simple machine by simulating its RTL (see below).

There is no assembler. SM instructions must be encoded in hexadecimal. For the programmer's convenience, the textual representation of hexadecimal may be used. sim will convert this to the corresponding binary and store it in the memory array before simulation begins. In the textual representation, each line is an instruction. A # on the line at any point indicates the rest of the line is a comment. If the entire line is a comment, it must begin with a #. As we know, hexadecimal numbers must start with 0x.

Example:

The simplest correct Simple Machine program is

0x0  # The end of the world!

A single instruction is executed. Its opcode is 0 (HALT). The machine halts.

RTL (or RTN)

Register transfer language (or notation) is used to describe the movement between, and operations on, registers and memory due to an instruction's execution. The RTL we use for the SM is simple, and is derived loosely from the diagram of the SM that shows its connected registers and how data may move. An added restriction is that each SM instruction is limited to two data transfers - one fetch operation to retrieve the next instruction, and one data memory cycle during the instruction execution phase.

As an illustration of RTL we will write the RTL for the entire simulation of a single instruction at address 0x3. The encoded instruction is 0x900a. When we begin the instruction cycle, here are the values for the registers and the first 11 words of the memory array. (I have capitalized the register names in the RTL to make them stand out. I have also annotated the RTL with C++-style comments)

PC: 0x3   ACCUM: 0x26  CTR: 0

MEMORY[] = { 0xb030,0x200a,0xb026,0x900a,0x2009,0x0,0x0,0x0,0x0,0x0,0x30 }

At the end of this sequence the ACCUM has the value 0xA.

Note that we have zeroed out the MAR before copying the address from the instruction to it. This is because all registers are 16-bits and we must ensure that the upper bits in the MAR are zero. (You might assume that the upper bits are always zero, since the memory space is only 1024 words, and a longer address would reference illegal memory, but this is a bit questionable.)

Can you finish the execution of the entire SM program that is in the memory array and determine what the resulting memory array looks like? (Hint: there is only one more instruction to execute, so there is only one change possible to the memory array.)

You should read the handout SimpleMachine and review the diagram of the SM  before you continue to the next section.

Prev This page was made entirely with free software on linux:  
Kompozer, the Mozilla Project
and Openoffice.org    
Next

Copyright 2015 Greg Boyd - All Rights Reserved.