Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.

Similar presentations


Presentation on theme: "Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how."— Presentation transcript:

1 Ellen Spertus MCS 111 October 16, 2001 Review

2 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how a computer works –Build an actual computer that you will program –Study the MIPS architecture Write assembly language programs Learn the implementation of a MIPS subset August 28 (Boolean Algebra and Binary Arithmetic)

3 3 Boolean algebra Two values: –0 / false / low / ground –1 / true / high / power Functions –One input: identity, not –Two input: and, or, xor nand, nor August 28 (Boolean Algebra and Binary Arithmetic)

4 4 Base-2 (binary) arithmetic Uses the two numbers from 0 to 1 Every column represents a power of 2 August 28 (Boolean Algebra and Binary Arithmetic)

5 5 Count on your fingers! How high can you count with –5 fingers? –10 fingers? August 28 (Boolean Algebra and Binary Arithmetic)

6 6 Homework 1 (Boolean algebra and binary numbers)

7 7 From switches to functions We can build switches. We can build and and not gates from switches. We can build from and and not gates. Therefore, August 30 (Digital Computing)

8 8 Digital computing ~1940 Boolean logic –true/false –and, or, etc. Electronic switches –electromagnetic relays –vacuum tubes Binary numbers August 30 (Digital Computing) Claude Shannon (1916-2001) Konrad Zuse (1910-1995)

9 9 Big Picture Any number can be represented as 0s and 1s Functions can be represented as a table Any table of 0s and 1s can be interpreted as a truth table Any truth table can be converted into a boolean function We can implement boolean functions with switches September 4 (Karnaugh Maps)

10 10 Karnaugh Maps What purpose do they serve?

11 11 Rules for Karnaugh maps Label each axis with a gray code, i.e., only change one bit at a time. Regions can stretch horizontally or vertically. Each side of a region must be a power of 2 (e.g., 1, 2, or 4). For simplest formula, choose ________ region and make use of “don’t care”s. Regions may wrap around the edges. September 4 (Karnaugh Maps)

12 12 Big Picture Any number can be represented as 0s and 1s. Any table of 0s and 1s can be interpreted as a truth table. We can implement boolean functions with switches. Any truth table can be converted into a boolean function.  September 4 (Karnaugh Maps)

13 13 Types of logic Combinational logic –No loops –Output only depends on current inputs Sequential logic –Loops –Output depends on current inputs and past state –Can implement memory September 13, 18 (Combinational Logic)

14 14 R-S latch September 13, 18 (Combinational Logic)

15 15 RS-latch dangerous transition 1  01  0 1  01  0 0 0  0 0  September 13, 18 (Combinational Logic)

16 16 D-latch Prevents dangerous transition. September 13, 18 (Combinational Logic)

17 17 D-latch behavior September 13, 18 (Combinational Logic) When E is _____, Q = D. Otherwise, Q keeps its old value.

18 18 D flip-flop Passes data through on rising edge of clock. September 13, 18 (Combinational Logic)

19 19 Clocks Most computers have a “clock” that generates a “square wave” Clock cycle time is measured in seconds Clock frequency is measured in Hertz (cycles per second) Example –Clock cycle time:.1 s –Clock frequency: 10 Hz September 13, 18 (Combinational Logic)

20 20 Common prefixes giga- (G): billion (10 9 ) mega- (M): million (10 6 ) kilo- (K or k): thousand (10 3 ) milli (m): one-thousandth (10 -3 ) micro (  ): one-millionth (10 -6 ) nano (n): one-billionth (10 -9 ) September 13, 18 (Combinational Logic)

21 21 Converting time to frequency 210 ns = 2.1  10 2 ns (cycle time of IBM PC) = 2.1  10 2  10 -9 s = 2.1  10 -7 s frequency = 1/(2.1  10 -7 ) Hz = 1/(2.1)  10 7 Hz .5  10 7 Hz  5  10 6 Hz  5 MHz (actually, 4.77 MHz) September 13, 18 (Combinational Logic)

22 22 Counter (Lab 1B) D flip-flop –Remembers current counter value –Acts as a barrier for the counter value September 13, 18 (Combinational Logic)

23 23 Big picture September 20 (Assembly Language)

24 24 Data storage and use Registers –32 locations –Each 32 bits wide –Can operate on them directly: add, sub, slt, … sll, srl beq, bne, … mul not, and, or Main memory (RAM) –Millions of locations –Each 8 bits (1 byte) wide –Cannot operate on them directly lw loads word from memory into register sw stores word from register into memory September 20 (Assembly Language)

25 25 Storing words in bytes Little-endian The “little end” (least significant byte) is stored first in memory. Big-endian The “big end” (most significant byte) is stored first in memory. September 20 (Assembly Language)

26 26 Scalars vs. arrays Scalar variable –Single item, e.g., count –Takes up one word of memory Array –Many items, e.g., a[0]…a[7] –Each element takes up one word of memory September 27 (Arrays and Loops)

27 27 Rules for accessing arrays The array is stored somewhere in memory. Put the address of the base (beginning) of the array into a register. Assuming each element of the array is one word (4 bytes) long, the offset (distance from base) of element n is 4*n. September 27 (Arrays and Loops)

28 28 Procedure calls Caller 200: add $a0, $zero, 3 204: add $a1, $zero, 6 208: jal sum 212:... Callee sum: 500: add $v0, $a0, $a1 504: jr $ra Program counter (PC): Return address ($ra): October 2 (Procedure Calls)

29 29 Factorial fact: # Store callee-saved values subi $sp, $sp, 8 # create space on stack for two items sw $ra, 4($sp) # store $ra (return address) on stack sw $a0, 0($sp) # store $a0 (n) on stack bne $a0, $zero, else_clause # if (n>0) goto else_clause # Base case addi $v0, $zero, 1 # prepare to return the value 1 addi $sp, $sp, 8 # return stack pointer to its original value jr $ra # return to caller else_clause: subi $a0, $a0, 1 # n = n - 1 jal fact # make recursive call lw $ra, 4($sp) # restore $ra from stack lw $a0, 0($sp) # restore $a0 from stack addi $sp, $sp, 8 # return stack pointer to its original value mult $v0, $v0, $a0 # multiply fact(n-1)*n jr $ra # return to caller Note: Save any values that you may need later onto the stack. October 2 (Procedure Calls)

30 30 Representations of numbers What’s the point? Homework 6 (Beyond positive integers)

31 31 Conversion to two’s complement To negate a number –Flip the bits –Add one Practice -21 10 6 10 -150 10 Homework 6 (Beyond positive integers) ±128 64 32 16 8 4 2 1

32 32 Conversion from two’s complement To negate a number –Flip the bits –Add one Practice 11110011 10001100 11111111 Homework 6 (Beyond positive integers) ±128 64 32 16 8 4 2 1

33 33 Signed instructions Assume that memory location 50 contains the value 150 ten (10100000 two ) lb $t0, 50($zero) lbu $t1, 50($zero) slt $t2, $t0, $t1 sltu $t3, $t0, $t1 Homework 6 (Beyond positive integers)

34 34 Upper-case letters Representations: –Characters A – Z –ASCII decimal 65 – 90 –ASCII binary 01000000 – 01010000 Homework 6 (Beyond positive integers)

35 35 upperCase (1) # if argument < ‘A’, return 0 slti $t0, $a0, 65# ‘A’ beq $t0, $zero, lab1 add $v0, $zero, $zero jr $ra lab1: # Return whether argument <= ‘Z’ slti $t0, $a0, 91# ‘Z’ + 1 add $v0, $t0, $zero jr $ra Homework 6 (Beyond positive integers)

36 36 upperCase (2) srl $t0, $a0, 5# shift right 5 li $t1, 2# load 2 beq $t0, $t1, yes# compare to 2 li $v0, 0# return false jr $ra yes: li $v0, 1# return true jr $ra Homework 6 (Beyond positive integers)

37 37 Floating-point numbers Representation (October 9) –Sign bit –Significand –Exponent Addition (October 11) –How to –Overflow, underflow –Limited precision

38 38 Summary Using nothing more than a bunch of ____________, we can perform computations on: positive and negative integers fractions characters –MIPS assembly instructions –Java programs


Download ppt "Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how."

Similar presentations


Ads by Google