SAP-1 ComputerSimple-As-Possible Computer Simple-As-Possible(SAP) Computer has been designed for beginners. The main purpose of SAP is to introduce all the crucial ideas behind computer operation. There are three different generations of SAP. (SAP-1 SAP-2 SAP-3) SAP-1 Computer SAP-1 is a computer because it stores a program and data before calculations begin; then it automatically carries out the program instructions without human intervention. And yet, SAP-1 is a primitive computing machine. When compared to a modern computer, it is like a Neanderthal human compared to a modern person. SAP-1 is the first stage in the evolution toward modern computers. SAP-1 ARCHITECTURE SAP-1 Architecture Architecture is the conceptual design and fundamental operational structure of a computer system. It is the blueprint and functional description of requirements and design implementations for various parts of a computer. PROGRAM COUNTER 4 8 ACCUMULATOR 8 8 INPUT and MEMORY ADDRESS REGISTER 4 RAM 4 RAM 4 W Bus 8 ADDER SUBTRACTOR 8 8 8 8 B REGISTER INSTRUCTION REGISTER 4 Controller Sequencer 8 4 8 OUTPUT REGISTER 8 BINARY DISPLAY SAP-1 ARCHITECTURE . All other register outputs are two-state. these outputs continuously drive the boxes they are connected to.SAP-1 Architecture SAP-1 Architecture is a Bus-Organized Computer. All register outputs to W Bus are three-state. these allows orderly transfer of data. . Three-State DATA IN DATA OUT ENABLE 0 1 1 Din X 0 1 Dout OPEN 0 1 ENABLE Din 0 Dout = OPEN Din 1 Dout = CLOSED . Bus-Organized Computer Bus is a group of wires that transmit a binary word. . It is a common transmission path between the three-state registers. LOADA CLR ENABLEA A REGISTER 4 4 BUS 4 4 C REGISTER LOADC CLR ENABLEC LOADB CLR ENABLEB B REGISTER 4 4 4 4 D REGISTER LOADD CLR ENABLED EXAMPLE OF BUS-ORGANIZED COMPUTER . as long as all LOAD and ENABLE inputs are LOW(0). the registers are isolated from the bus. In other words. . To begin with.Data Transfers The advantage of bus organization is the ease of transferring a word from one register to another. the same CLK signal drives all the registers. but nothing happens until you apply HIGH(1) signal to the control inputs(LOAD and ENABLE). CLR input clears the word in the register when HIGH(1). EXAMPLE: except D. Transfer word 0101 from A to B. Then from B to C and from C to D. After all registers have the binary word. Clear all register LA CLR EA 0101 A C LC CLR EC LB CLR EB B D LD CLR ED . .LA 1 CLR EA 0101 A C LC CLR EC 1 LB CLR EB 0101 B D LD CLR ED Apply HIGH signal on EA and LC to transfer binary word from A to B. LA CLR EA 0101 A 0101 C LC CLR EC 1 LB CLR 1 EB 0101 B D LD CLR ED Apply HIGH signal on EB and LC to transfer binary word from B to C. . .LA CLR EA 0101 A 0101 C LC CLR EC 1 LB CLR EB 0101 B 0101 D LD CLR ED 1 Apply HIGH signal on EC and LD to transfer binary word from C to D. LA 1 CLR EA 0101 A 0101 C LC CLR EC 1 LB 1 CLR EB 0101 B 0101 D LD CLR ED Apply HIGH signal on CLR on A.B and C to clear its contents. . CP EP CLK CLR LM CLK INPUT and MEMORY ADDRESS REGISTER 4 RAM 4 RAM 8 8 4 PROGRAM COUNTER 4 8 ACCUMULATOR 8 8 W Bus 8 ADDER SUBTRACTOR 8 8 B REGISTER LA EA CLK SU EU CE LI EI CLK CLR LB CLK LO CLK INSTRUCTION REGISTER 4 Controller Sequencer 8 4 8 OUTPUT REGISTER 8 BINARY DISPLAY SAP-1 ARCHITECTURE CPEPLMCE LIEILAEA SUEULBLO . the Instruction Register and the Controller-Sequencer that produces the control word. The SAP-1 I/O unit includes the programming switches.SAP-1 Architecture The SAP-1 Control unit consists of the Program counter. . The SAP-1 ALU(Arithmetic Logic unit) consists of an Accumulator. The SAP-1 Memory has the Memory Address Register and a 16x8 RAM. Output register and Binary display. the clear signals and the clock signal. an Adder/Subtractor and a B Register. The binary word output of the counter (0000 to 1111) corresponds to the memory location or address(00H to 10H) of RAM where the instruction is written. .Program counter Program counter is a circuit counter that counts from 0000 to 1111. the output of the program counter(0000 to 1111) is latched into MAR. Memory Address Register(MAR) is part of the SAP-1 Memory. . where a read operation is performed. MAR applies this 4-bit address to the RAM.INPUT and Memory Address Register(MAR) INPUT is where the programming switches that allows you to send 4-bit address and 8bit data to the RAM. A moment later. During a computer run. During a computer run. .Random-Access Memory(RAM) Before a computer run. the instruction or data word stored in the RAM is placed on the W bus for use in some other part of the computer. the instruction or data word is stored in the RAM by using address and data switch registers. In this way. the RAM receives the 4-bit address from the MAR and a read operation is performed. RAM CE D0 D1 D2 D3 WE O0 O1 O2 O3 A3 A2 A1 A0 To write data on the RAM: ----Address the memory where the data will be written. there are 16 memory locations(address) to write on with 4 bits of data. In this case.] ----Clear both CE and WE to perform write operation. ----Clear CE and set WE to perform Read operation. 0 A0 – A3 Address bits D 0 – D3 Data Input O0 – O 3 Data Output (threestate) CE Chip Enable WE Write Enable 1 1 0 0 1 ------1001 AH BH CH 1 0 1 0 . [SAP-1 uses two 16x4 TTL RAM. Example: Write 1001 on 10H. Example: Read the data stored in 10H. 0 1 0 0 1 1 0 1 0 ------1001 0 AH BH CH To read data from the RAM: ----Address the memory where the data will be read. Instruction Register Instruction register is a part of control unit and a buffer register that fetch an instruction from the RAM when the computer does a memory read operation. The upper nibble(MSB) output of the instruction register goes directly to the Controller-Sequencer. the lower nibble(LSB) is a three-state output that is read onto the W bus when needed. . . the controller-sequencer contains the Clock generator which sends out CLK and CLK signals and the Master reset which sends out CLR and CLR signals. The control word has the format of: CON = CPEPLMCE LIEILAEA SUEULBLO Also.Controller-Sequencer This controls the whole operation of the computer(like a supervisor telling everyone what to do) by sending out 12-bit word called control word. Accumulator has two sets of outputs. Also called as the A Register. The first set of output is two-state and is directly connected to Adder/Subtractor.Accumulator Accumulator is a part of ALU and a buffer register that stores intermediate answers during computer run. The second set of output is a three-state and is directly connected to the W bus. . B Register B register is a part of ALU and another buffer register which contains the number to be added or subtracted to the contents of the accumulator. . Adder/Subtractor The adder/subtractor is consists of two 4-bit full adder that can perform addition and subtraction(by using 2's complement). . the output ports are connected to interface circuits that drive peripheral devices. Also called as output port because it processed data can leave the computer through this register. In microcomputers. .Output Register Output register is the register that receives the processed data from the accumulator and drives the output display of SAP-1. Binary Display The binary display is a row of 8 LEDs. it shows the contents of the processed data. Because the binary display is connected to the output port. . SAP-1 INSTRUCTION SET . SAP-2 and SAP-3 instruction are also part of 8080/8085 instruction. OUT and HLT. SAP-1 Instruction set are LDA. Instruction set is the basic operation a computer can perform.SAP-1 Instruction Set A computer is a useless pile of hardware until someone programs it. SAP-1 instructions are taken from Intel 8080/8085 instructions. ADD. In other words. . Likewise. SUB. These instructions are upward compatible with Intel 8080/8085(first widely used 8-bit microprocessor introduced in 1970). Mnemonic LDA ADD SUB OUT HLT Operation Load RAM data into accumulator Add RAM data to accumulator Subtract RAM data from accumulator Load accumulator data into output register Stop processing .SAP-1 Instruction Set Abbreviated instructions(LDA. OUT. ADD. SUB. HLT) are called mnemonics. A complete LDA instruction includes the address or memory location(written in hexadecimal to avoid confusion). Example: LDA 8H LDA 8H means ''Load the accumulator with the contents of memory location 8H'' .LDA LDA means ''LoaD the Accumulator''. ADD ADD is another SAP-1 instruction. Example: ADD AH ADD AH means ''ADD the contents of memory location AH to the contents of accumulator''. A complete ADD instruction includes the address or memory location where given data is stored to be added. . Example: SUB CH SUB CH means ''SUB the contents of memory location CH to the contents of accumulator''.SUB SUB is another SAP-1 instruction. A complete SUB instruction includes the address or memory location where given data is stored to be subtracted. . OUT is complete by itself. that is you do not have to include an address or memory location when using OUT. Example: OUT .OUT The instruction OUT tells the SAP-1 computer to transfer the accumulator contents to the output port. HLT is complete by itself. HLT marks the end of a program. It is necessary to use HLT instruction at the end of every SAP-1 program. This instruction tells the computer to stop processing data.HLT HLT means ''HaLT''. Example: HLT . you will get a computer trash(meaningless answers caused by runaway processing). otherwise. that is you do not have to include an address or memory location when using HLT. SAP-1 PROGRAMMING . SAP-1 Program Example: Create a SAP-1 program to solve this arithmetic problem: 10 + 5 +35 .46 . ADDRESS 0H 1H 2H 3H 4H 5H 6H 7H 8H 9H CONTENTS LDA 6H ADD 7H ADD 8H SUB 9H OUT HLT 0000 1010 0000 0101 0010 0011 0011 0010 . we need to convert the source program(original program with mnemonics) into object program(program written in machine language). This means.SAP-1 Program To load the instruction and data word into SAP-1. instructions in mnemonic will be converted in operation code. Mnemonic LDA ADD SUB OUT HLT Op code 0000 0001 0010 1110 1111 . Example: ADDRESS 0H 1H 2H 3H 4H Translate the program into SAP-1 machine language. CONTENTS LDA 9H ADD AH SUB BH OUT HLT . LDA=0000 ADD=0001 SUB=0010 OUT=1110 HLT=1111 ADDRESS 0000 0001 0010 0011 0100 CONTENTS 0000 1001 0001 1010 0010 1011 1110 xxxx 1111 xxxx . SAP-1 MACHINE CYCLE . .SAP-1 Machine Cycle The control unit is the key to a computer's automatic operation. The control unit generates the control words that fetch and execute each instructions. the computer passes through different timing states(T states). While each instructions is fetched and executed. Then during the next clock pulse. 1000. a ring counter has an initial output of 0001. a ring counter uses words that have only a single high bit. After 0010 is 0100. During a clock pulse. For example. the output carries over the high bit into the next binary weight. 0001 0000 and so on. .SAP-1 Timing States Timing states are binary words produced from a circuit counter called ring counter. Instead of counting binary numbers. the next output would be 0010. T1 = T2 = T3 = 000001 000010 000100 T4 = T5 = T6 = 001000 010000 100000 . SAP-1 computer uses 6 different timing states. The first three states are called fetch cycle and the second three states are called execution states.SAP-1 Timing States The importance of ring counter is to control the sequence of operations by assigning it to different timing states. During this state. the controller-sequencer sends out a CONTROL word: CON = = 0101 1110 0011 5E3(simplified form) .SAP-1 Fetch cycle The T1 state is called the address state because the output of the program counter is transferred to the memory address register. During this state.SAP-1 Fetch cycle The T2 state is called increment state because the program counter is incremented. the controller-sequencer sends out a CONTROL word: CON = = 1011 BE3 1110 0011 . the controller-sequencer sends out a CONTROL word: CON = = 0010 263 0110 0011 . During this state.SAP-1 Fetch cycle The T3 state is called memory state because the addressed RAM instruction is transferred from the memory to the instruction register. T5 and T6 are execution cycles.The T4. SAP-1 Execution cycle . Microinstructions that were group together is called macroinstructions. the instruction is carried out or performed. In these states. It is called microinstruction. For example. LDA has three microinstructions for each timing states. There are different execution cycles for each instructions. MACRO LDA ADD SUB OUT STATE T4 T5 T6 T4 T5 T6 T4 T5 T6 T4 T5 T6 CON 1A3 2C3 3E3 1A3 2E1 3C7 1A3 2E1 3CF 3F2 3E3 3E3 . T State T1 T2 T3 EXECUTION CYCLE T State T4 LDA T5 LDA T6 LDA T4 ADD T5 ADD T6 ADD T4 SUB T5 SUB T6 SUB T4 OUT CON 5E3 BE3 263 CON 1A3 2C3 3E3 1A3 2E1 3C7 1A3 2E1 3CF 3F2 EP CP CE LI Active LM Active LM EI CE LA none LM EI CE LB LA EU LM EI CE LB LA SU EU EA LO . SAP-1 SCHEMATIC DIAGRAM .