Computer Organization CSC 405 (VSC) Very Simple Computer
Very Simple Computer (VSC) For detailed design information on the VSC, please read the Very Simple Computer Overview. The VSC is a very impractical computer system with a single Bus, a 32 8-bit Word memory, switch/LED input/output, supporting 8 instructions. As simple as it is, the VSC is a complete representation of the Von Neumann Architecture. Registers: PC - program counter IR - instruction register MAR - memory address register LAT1 - latch 1, ALU input register LAT2 - latch 2, ALU input register ACC - accumulator, ALU output register VSC Functional Units: I/O - input output unit CU - control unit MU - memory unit ALU - arithmetic/logic unit
A Walk through the Fetch/Execute Cycle MAR <- PC IR <- MEM[MAR] PC <- PC+1 MAR <- IR 0-4 LAT1 <- MEM[MAR] LAT2 <- ACC EXE en
The Instructions of the VSC The eight instructions of the VSC are based on the Post/Turing language. These instructions form a complete set of operations. While not very practical, the operations of the Post/Turing language can be used to emulate any computable function. LDA - load the accumulator with a word from memory (selected by MAR) STA - store the word in the accumulator into memory (at address in MAR) ADD - add LAT1 and LAT2 and store the result into the accumulator (ACC) CMP - complement (bit inverse) the value in LAT1 and store in accumulator BNN - if the MSB of ACC is zero (0) replace PC with address in IR SHL - perform an arithmetic shift left on the value in LAT1 SHR - perform an arithmetic shift right on the value in LAT1 HLT - stop the fetch/execute cycle (for VSC set PC to 11111)
Register Transfers for Instruction Executions 000 LDA ACC <- MEM[MAR] 001 STA MEM[MAR] <- ACC 010 ADD ACC <- LAT1+LAT2 011 CMP ACC <- LAT1 100 BNN IF ACC 7 =0 THEN PC <- IR SHL ACC <- 2*LAT1 110 SHR ACC <- LAT1/2 111 HLT PC < OpCode ASM Register Transfer There is a different register transfer operation for each of the eight instructions of the VSC. The Control Unit is a combinatorial circuit (encoder) that activates the read and write enable lines that correspond to the operation indicated by the OpCode.
Implementing the Register Transfers in Hardware We have defined the registers for the VSC, the functional blocks (units) and the logic for the fetch/execute cycle. Now we need to design the circuitry that will invoke these register transfers. There are 7 steps in the fetch/execute cycle. We will use a divide-by-eight counter to generate the Read and Write enable signals for each step start 1 MAR <- PC 2 IR <- MEM[MAR] 3 PC <- PC+1 4 MAR <- IR LAT1<- MEM[MAR] 6 LAT2<- ACC 7 EXE en 8 No Op Time MAR RE PC RE PC WE PC INC IR RE IR WE LAT1 RE LAT2 RE MEM RE MEM WE ACC RE ACC WE EXE EN
555 Timer Divide by 8 Counter 3-to-8 Decoder MAR RE PC RE PC WE PC INC IR RE IR WE LAT1 RE LAT2 RE MEM RE MEM WE ACC RE ACC WE EXE EN The clock pulses that drive the divide-by-eight counter can be produced with a timer circuit (built from a A555). The divide-by-eight counter is available in a single TTL IC (7493). The 3-to-8 decoder can be built by inverting the outputs of a popular decoder IC (74138).
A similar circuit can be built to generate the control signals needed to implement each of the eight instructions of the VSC. In this case, the control lines input to the 3-to-8 decoder come directly from the OpCode of the current instruction in IR LDA ACC <- MEM[MAR] 001 STA MEM[MAR] <- ACC 010 ADD ACC <- LAT1+LAT2 011 CMP ACC <- LAT1 100 BNN if ACC 7 =0 then PC<-IR SHL ACC <- 2*LAT1 110 SHR ACC <- LAT1/2 111 HLT PC < OpCode ASM Register Transfer Note: Enable lines in common with those in the fetch circuit must be connected through OR gates. MEM RE 3-to-8 Decoder IR OpCode ACC RE ACC WE MEM RE MEM WE PC RE IR WE ADD EN CMP EN SHL EN SHR EN HLT ACC 7
We can define an assembler to write programs for the VSC. This assembler will be used to help us manually develop machine code (1’s and 0’s) for the VSC. The best way to become familiar with the VSC assembler is by reviewing a few examples: In our first example we will write a program to add the values 6 and 3. We will preload these values into memory labeled X and Y and have the program store the result in Z. VSC ASM Addr Data/Instr LDA X ADD Y STA Z HLT X Y Z Note that the assembly language commands are simply the 8 operations we defined for the VSC and their corresponding op-codes are the 3 highest-order bits of each instruction. The program is placed in memory with the 1st instruction at address Upon completion the VSC should hold the value at memory address
The next example is a program that checks an input value X. If X is even then it is divided by 2 otherwise it is multiplied by 2. The result replaces X. In this example X=7. LDA X SHR SHL STA Y LDA X CMP ADD ONE ADD Y BNN EVEN LDA X ODD SHL LDA ZERO BNN SAVE EVEN LDA X SHR SAVE STA X HLT X [INPUT] Y ONE ZERO First the value of X is loaded into the accumulator. Then it is divided and multiplied by 2. The value of X is subtracted from this result (Y). If the difference is negative then X was odd so X is loaded and multiplied by 2. The program then jumps to the address labeled SAVE. If the difference is zero (i.e. not negative) then X was even so X is loaded and divided by 2. The program then saves the result back into X. Homework: Write a VSC assember program that computes the sum of the first 10 integers. Use the pseuodo-code as shown in the last two examples.