LMMS: An 8-bit Microcode Simulation of the Little Man Computer



Similar documents
CHAPTER 7: The CPU and Memory

CPU Organisation and Operation

Notes on Assembly Language

Chapter 01: Introduction. Lesson 02 Evolution of Computers Part 2 First generation Computers

MICROPROCESSOR. Exclusive for IACE Students iacehyd.blogspot.in Ph: /422 Page 1

(Refer Slide Time: 00:01:16 min)

CS101 Lecture 26: Low Level Programming. John Magee 30 July 2013 Some material copyright Jones and Bartlett. Overview/Questions

Computer organization

what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?

Administrative Issues

MICROPROCESSOR AND MICROCOMPUTER BASICS

Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2

Microprocessor & Assembly Language

TIMING DIAGRAM O 8085

Central Processing Unit Simulation Version v2.5 (July 2005) Charles André University Nice-Sophia Antipolis

TEACHING COMPUTER ARCHITECTURE THROUGH SIMULATION (A BRIEF EVALUATION OF CPU SIMULATORS) *

Comp 255Q - 1M: Computer Organization Lab #3 - Machine Language Programs for the PDP-8

Summary of the MARIE Assembly Language

Let s put together a Manual Processor

Central Processing Unit (CPU)

1 Description of The Simpletron

Chapter 2 Basic Structure of Computers. Jin-Fu Li Department of Electrical Engineering National Central University Jungli, Taiwan

The Little Man Computer

PROBLEMS. which was discussed in Section

Computer Organization

Figure 1: Graphical example of a mergesort 1.

CPU Organization and Assembly Language

Instruction Set Architecture (ISA)

High level code and machine code

Chapter 2 Logic Gates and Introduction to Computer Architecture

PROBLEMS (Cap. 4 - Istruzioni macchina)

Chapter 4 Register Transfer and Microoperations. Section 4.1 Register Transfer Language

1 Computer hardware. Peripheral Bus device "B" Peripheral device. controller. Memory. Central Processing Unit (CPU)

1 Classical Universal Computer 3

Lecture N -1- PHYS Microcontrollers

Traditional IBM Mainframe Operating Principles

Chapter 5 Instructor's Manual

Computer Architecture Lecture 2: Instruction Set Principles (Appendix A) Chih Wei Liu 劉 志 尉 National Chiao Tung University

How It All Works. Other M68000 Updates. Basic Control Signals. Basic Control Signals

CHAPTER 4 MARIE: An Introduction to a Simple Computer

Today. Binary addition Representing negative numbers. Andrew H. Fagg: Embedded Real- Time Systems: Binary Arithmetic

Machine Architecture and Number Systems. Major Computer Components. Schematic Diagram of a Computer. The CPU. The Bus. Main Memory.

Lab 1: Full Adder 0.0

CPU Sim 3.1: A Tool for Simulating Computer Architectures for CS3 classes

The string of digits in the binary number system represents the quantity

İSTANBUL AYDIN UNIVERSITY

MACHINE INSTRUCTIONS AND PROGRAMS

Levels of Programming Languages. Gerald Penn CSC 324

In this Chapter you ll learn:

CSCI 4717 Computer Architecture. Function. Data Storage. Data Processing. Data movement to a peripheral. Data Movement

Two's Complement Adder/Subtractor Lab L03

UNIVERSITY OF CALIFORNIA, DAVIS Department of Electrical and Computer Engineering. EEC180B Lab 7: MISP Processor Design Spring 1995

OAMulator. Online One Address Machine emulator and OAMPL compiler.

Chapter 1 Computer System Overview

A s we saw in Chapter 4, a CPU contains three main sections: the register section,

Central Processing Unit

SPSS INSTRUCTION CHAPTER 1

Instruction Set Design

Computer Organization. and Instruction Execution. August 22

LSN 2 Computer Processors

Programming A PLC. Standard Instructions

Learning Outcomes. Simple CPU Operation and Buses. Composition of a CPU. A simple CPU design

8085 INSTRUCTION SET

Questions 1. half adder sum. x y

Computer Organization and Architecture

PART B QUESTIONS AND ANSWERS UNIT I

Modbus RTU Communications RX/WX and MRX/MWX

Exemplar Work for SAMs. Units A452 and A453

isppac-powr1220at8 I 2 C Hardware Verification Utility User s Guide

CSE 141L Computer Architecture Lab Fall Lecture 2

STEP 7 MICRO/WIN TUTORIAL. Step-1: How to open Step 7 Micro/WIN

Parts of a Computer. Preparation. Objectives. Standards. Materials Micron Technology Foundation, Inc. All Rights Reserved

MACHINE ARCHITECTURE & LANGUAGE

Jianjian Song LogicWorks 4 Tutorials (5/15/03) Page 1 of 14

Management Challenge. Managing Hardware Assets. Central Processing Unit. What is a Computer System?

First Bytes Programming Lab 2

Chapter 4 Lecture 5 The Microarchitecture Level Integer JAVA Virtual Machine

Computer System: User s View. Computer System Components: High Level View. Input. Output. Computer. Computer System: Motherboard Level

Programming Logic controllers

The goal is to program the PLC and HMI to count with the following behaviors:

TestManager Administration Guide

EE361: Digital Computer Organization Course Syllabus

CPU Sim USER'S MANUAL

ASSEMBLY PROGRAMMING ON A VIRTUAL COMPUTER

Overview. CISC Developments. RISC Designs. CISC Designs. VAX: Addressing Modes. Digital VAX

Generating MIF files

BASIC COMPUTER ORGANIZATION AND DESIGN

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

Addressing The problem. When & Where do we encounter Data? The concept of addressing data' in computations. The implications for our machine design(s)

Input / Output and I/O Strategies

1. Convert the following base 10 numbers into 8-bit 2 s complement notation 0, -1, -12

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek

Getting Started on the Computer With Mouseaerobics! Windows XP

Python Programming: An Introduction to Computer Science

COMPUTERS ORGANIZATION 2ND YEAR COMPUTE SCIENCE MANAGEMENT ENGINEERING JOSÉ GARCÍA RODRÍGUEZ JOSÉ ANTONIO SERRA PÉREZ

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Sync Tool for Clarion NX700/NX509/NP509 Series

Graded ARM assembly language Examples

13 Managing Devices. Your computer is an assembly of many components from different manufacturers. LESSON OBJECTIVES

Systems I: Computer Organization and Architecture

Transcription:

LMMS: An 8-bit Microcode Simulation of the Little Man Computer Thad Crews Western Kentucky University 1 Big Red Way (270) 745-4643 thad.crewsii@wku.edu Abstract The Little Man Computer (LMC) is a simplified example of computer architecture containing al l the components of modern computers: memory, a central processing unit (CPU), and input/output capability. The LMC also contains a small instruction set that allows students to write and execute simple programs. This paper describes the Little Man Microcode Simulator (LMMS), a register-transfer-level simulation of the Little Man Computer. LMMS is built on an 8-bit architecture with multiple viewing perspectives (e.g., digital, binary, and mnemonic). LMMS utilizes memory address and memory data registers to demonstrate CPU activity during memory access. LMMS provides detailed microcode implementation of the complete Little Man instruction set. LMMS uses a powerful but intuitive interface, providing an excellent simulation tool for introducing students to computer organization. Introduction The Little Man Computer (LMC) is a simplified example of computer architecture originally presented by Stuart Madnick at MIT in 1965. Over 35 years after its introduction, the LMC remains a useful tool for introducing students to computer hardware and software. The LMC contains all the components of modern computers: memory, a central processing unit (CPU), and input/output capability. The LMC also contains a small instruction set that allows students to write and execute simple programs. By writing and executing LMC programs, students gain valuable experience with important ideas including the stored program concept and the fetch-execute cycle.

The Original LMC Model There are many perturbations of Madnick s original LMC model, including a 1979 revision by Madnick himself. Madnick s second version of LMC is used in The Architecture of Computer Hardware and Systems Software, 2 nd Edition [Englander, 2000]. A diagram of Englander s LMC appears in Figure 1. Figure 1: Irv Englander s Little Man Computer The LMC model uses common analogies to represent CPU concepts. For example, memory is represented as a series of 100 mailboxes. The ALU is represented as a calculator. I/O activity occurs though an IN basket and an OUT basket. A hand held counter represents the program counter.

The LMC model is decimal based. The mailboxes and calculator each contain a three digit decimal number. When a number needs to be interpreted as an instruction, the first digit represents the op code, and the other two digits indicate the appropriate mailbox address associated with that instruction. For example, the instruction 512 would be interpreted as op code 5 (LOAD) and address 12, meaning the value in mailbox 12 would be copied into the calculator. Limitations of the LMC Model The LMC model is valuable as a conceptual tool for introducing students to important computer architecture concepts. However, there are aspects of the model that are problematic from a pedagogic and simulation perspective: 1. The decimal representation creates a problem concerning the number of memory locations. A single digit operand can access only 10 memory locations, which is too few in most cases. A two-digit operand maps to 100 memory locations, far more than necessary to demonstrate the functionality of the LMC model. For a pencil and paper version, the extra memory cells can simply be ignored (see Figure 1). With a simulator each memory location must be visible to the user, and presenting each memory location becomes a challenge. 2. The decimal representation also creates a problem when mapping to a binary equivalent. One digit op codes (10 instructions) and two digit operand (100 memory locations) corresponds to 4 bit op codes (with unused combinations) and 7 bit addresses (with memory addresses 100 to 127 unused). Also, the 11 total required bits is itself an unusual number (one and three-eights bytes).

3. The notion of a little man following a strict set of rules is a useful analogy for the control unit of a CPU. However, since there obviously is no real little man inside the PC, students wanting a more accurate understanding of the CPUs internal structure need a depiction that is closer to reality. The LMMS system, discussed in the following section, addresses these problems and provides pedagogical benefits that go beyond the original LMC model. The LMMS system The LMMS (Little Man Microcode Simulator) system is a register-transfer-level simulation of Madnick s LMC model. The LMMS system is built on an 8-bit architecture with multiple viewing perspectives (e.g., digital, binary and mnemonic). LMMS displays memory address and memory data registers to demonstrate CPU behavior when accessing memory. LMMS provides detailed microcode implementation of the complete Little Man instruction set. The LMMS interface is shown in Figure 2.

Figure 2: LMMS user interface The LMMS system is built on a binary (8-bit) architecture, although it also allows decimal and mnemonic representations to support multiple student perspectives. Figure 3 shows the binary and decimal representations of an LMC program that inputs two numbers and displays their sum. Notice how the first three bits make up the decimal op code and the last five bits make up the decimal operand. Details of the program itself are discussed later.

Figure 3: Multiple representations of an LMC program. LMMS Fetch-Execute Cycle With the LMC model, the behavior of the Little Man (e.g., control unit) is described at a high level for each instruction in the instruction set. For example, Englander explains the fetch-execute activities of the LOAD instruction this way: The Little Man walks over to the mailbox address specified in the instruction. He reads the three-digit number located in that mailbox, and then walks over to the calculator and punches that number into the calculator. The three-digit number in the mailbox is left unchanged, but of course the original number in the calculator is replaced by the new number. [Englander, 2000, p. 149] The above description is sufficient to carry out the desired behavior using pencil and paper. However since the little man is clearly fictitious it does not provide an accurate understanding of the LOAD operation with respect to the internals of the CPU. LMMS addresses this problem by presenting the instruction set at a microcode level. The fetch-execute cycle for each instruction is described as a series of register transactions. LMMS microcode uses the following five registers: The program counter (PC) contains the address of the next instruction.

The instruction register (IR) holds the current instruction being executed by the computer. This register is not identified in the traditional LMC model but is essential to the LMMS system as you will see. The memory address register (MAR) holds the address of a memory location. The memory data register (MDR) is a read/write connection to the data stored in memory at the address identified by the MAR. The accumulator (A) is a general purpose register. The fetch microcode is the same for all instructions: access to the memory location holding the next instruction. auto-increment the program counter copy the instruction from memory to the instruction register After the fetch is complete, the instruction is decoded, and the appropriate execute microcode occurs. LMMS Instruction Set LOAD instruction 1xx Loads the contents of mailbox xx into the calculator. IR[add] MAR access the xx memory location MDR A copy the data from memory to the accumulator STORE instruction 2xx Stores the calculator value into mailbox xx. IR[add] MAR access the xx memory location A MDR copy the data in the accumulator to memory

ADD instruction 3xx Adds the contents of mailbox xx to the calculator. IR[add] MAR access the xx memory location A + MDR A increase the value in the accumulator by the data in memory SUBTRACT instruction 4xx Subtracts the contents of mailbox xx from the calculator. IR[add] MAR access the xx memory location A MDR A reduce the value in the accumulator by the data in memory BRANCH instruction 5xx Change the program counter to xx. IR[add] PC change the program counter to xx BRANCH IF POSITIVE instruction 6xx If the calculator value is positive (including zero), then change the program counter to xx. If A >= 0 then IR[add] PC change the program counter if A is positive BRANCH IF ZERO instruction 7xx If the calculator value is Zero, then change the program counter to xx. IF A = 0 then IR[add] PC change the program counter if A is zero INPUT instruction 001 Accept a number from the Input stream and put it in the calculator. I/O Stream A store I/O stream to accumulator

OUTPUT instruction 002 Display the number in the calculator. A I/O Stream put accumulator value on the I/O stream HALT instruction 003 Stops the program - the Little Man rests. {end program} terminate the program simulation Creating an LMMS Program Consider a simple program that inputs two numbers and displays their sum. This program can be accomplished with the following instructions: Input read the first value, placing it into the calculator Store 20 store the value in mailbox 20 Input read the second value, placing it into the calculator Add 20 add the first value to the second value in the calculator Output display the sum from the calculator LMC instructions are selected from the pull-down list as shown in Figure 4. Figure 4: Selecting an LMC instruction

Selected instructions are copied to specified memory locations. Selected instructions in memory may be edited by choosing a new instruction from the pull down list. Selected instructions may also be moved using the floating Up, Down, and Delete command buttons as shown in Figure 5. Figure 5: Floating edit commands for manipulating memory. Running an LMMS Program Figure 5 shows the memory contents when the Add Two Numbers program has been loaded. Programs are executed by selecting the Run Machine Instruction button or the Run Without Pause button under the register trace grid, or pressing F8 or F9 as a shortcut (see Figure 6). Figure 6: The Register Trace Grid

Figure 7 shows LMMS behavior when executing the first instruction (INPUT) of the Add Two Numbers program. The Fetch microcode (; ; ) has been executed. The Execute microcode (I/O Stream A) is waiting for the user to enter a value through the Input dialog box. After the user presses OK, the input value will be stored in the Accumulator and the instruction will be complete. Note that the Program Counter has the value of the address of the next instruction to Fetch. Figure 7: Accepting data during INPUT Figure 8 shows the contents of the register trace grid after completing the INPUT instruction. Notice that the input value 7 is successfully stored in the Accumulator register. Also notice how the register trace grid uses the color red to indicate when a register value has changed during the execution of a microinstruction.

Figure 8: Register Values after INPUT Figure 9 shows the LMMS interface after executing the second instruction (STORE 20). Like the register trace grid, the memory grid uses the color red to indicate data has been assigned to a memory location. Blue color indicates an executed instruction. Figure 9: LMMS interface after executing two instructions

By selecting Run Without Pause, the program executes Fetch Execute cycles for each instruction in sequence until the Halt instruction is executed. The only pause is for I/O Stream activity, such as accepting the second value and displaying the result of the addition as shown in Figures 10 and 11. Figure 10: Second Input Value Figure 11: LMMS displays the result

Other LMMS Programs The Add Two Numbers program is a good first program for beginning students. Other programs that may be more challenging include: Biggest of 3: Write a program that will prompt the user to input three values. The output should be the largest of the three input values. Countdown: Write a program that uses a loop to display the values 10 down to 1. Positive Difference: Write a program that will prompt the user to enter two values. The output should be the positive difference of the two values. For example, if the input is 5 and 7, the output should be 2. If the input values are reversed, the output should still be 2. Largest in a Series: Write a program that will prompt the user to enter a series of values. The program will continue to accept values until the sentinel value of zero is entered. The program should then display the largest value in the series. Solutions to each of these problems are stored in the LMMS folder. The programs may be loaded and executed to provide additional experimentation with the LMMS system. Conclusion The Little Man Computer is a valuable model for introducing student to key ideas in computer architecture, including memory, the central processing unit (CPU), and input/output capability. The LMC also contains a small instruction set that allows students to write and execute simple programs. By writing and executing LMC

programs, students gain valuable experience with important ideas including the stored program concept and the fetch-execute cycle. LMMS is a simulator that supports the Little Man model while also providing additional pedagogical benefits. LMMS supports decimal, binary, and mnemonic perspectives of data and instructions. LMMS illustrates CPU/memory behavior through memory address and memory data registers. LMMS provides detailed microcode implementation for the complete LMC instruction set. During simulation, the fetch/execute cycle for each instruction is presented as a trace of register-transfer activities. LMMS uses a powerful but intuitive interface, providing an excellent simulation tool for introducing students to computer organization. References Englander, I. (2000). The Architecture of Computer Hardware and Systems Software 2/e. New York: Wiley.