Download presentation
Presentation is loading. Please wait.
Published byLesley Walton Modified over 9 years ago
1
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 645-4739 alphonce@buffalo.edu 1
2
Name signs out 2
3
Announcements Cell phones & laptops off & away Name signs out 3
4
Today’s lessons A computer is a very simple machine –it manipulates voltages –gates are used to control voltage flow –circuits are combinations of gates –a flip-flop is a circuit that remembers Instructions are encoded as bit strings Machine/assembly/high-level languages Fetch-Decode-Execute cycle Requirements for a programming language 4
5
physical vs. logical perspectives Physical reality: Logical view: WIRE Carries a HIGH voltage or a LOW voltage WIRE Carries a 1 or a 0 5
6
Idea 6
7
Controlling flow 0 7
8
1 8
9
Two in a row? 0 9
10
0 10
11
Two in a row? 0 11
12
Two in a row? 1 12
13
AND gate For which input values is output 1? For which input values is output 0? inputs are on left output is on right 13 0 or 1
14
Truth table for AND Input 1Input 2Output 000 010 100 111 14
15
OR gate For which input values is output 1? For which input values is output 0? inputs are on left output is on right 15
16
Truth table for OR Input 1Input 2Output 000 011 101 111 16
17
NOT gate For which input value is output 1? For which input value is output 0? input is on left output is on right 17
18
Truth table for NOT InputOutput 01 10 18
19
Flip-flop (a bit of memory!) S (set) R (reset) remembered value 19
20
Setting the flip-flop The normal value of R and S is zero. S (set) = 0 R (reset) = 0 remembered value 20
21
Setting the flip-flop To store 1 in the flip-flop, we “raise” S to 1… S (set) = 1 R (reset) = 0 remembered value 21
22
Setting the flip-flop …which makes the output of the OR gate 1. S (set) = 1 R (reset) = 0 remembered value 22 1
23
Setting the flip-flop The NOT gate inverts this 1 value to 0, which becomes the second input to the upper OR gate. S (set) = 1 R (reset) = 0 remembered value 23 10 0
24
Setting the flip-flop Since both inputs of the upper OR gate are zero, its output is zero. S (set) = 1 R (reset) = 0 remembered value 24 1 0 0 0
25
Setting the flip-flop The NOT gate inverts this 0 to a 1; this value becomes the second input to the bottom OR. S (set) = 1 R (reset) = 0 remembered value 25 1 0 0 0 1 1
26
Setting the flip-flop Because the output of the bottom OR gate will now stay at 1, we can lower S to zero, and the circuit will stay in a stable state, with 1 as the remembered value! 26 Resetting the flip-flop Resetting the remembered value to zero is similar, except we raise, then lower, the value on R. S (set) = 0 R (reset) = 0 remembered value 1 0 0 0 1 1
27
Recap Bit string by itself does not carry meaning. Bit string can be interpreted under a given representation scheme, which allows us to recover the encoded meaning. Circuits made from simple gates let us store and manipulate bit strings. 27
28
Questions? 28
29
Computer Organization Central Processing Unit (CPU) –Registers General purpose (e.g. R1 – R16) Special purpose (e.g. Program Counter and Instruction Register) –Arithmetic Logic Unit (ALU) Memory 29
30
Computer Organization 30 Processor (CPU) Memory (RAM) 11010010 R1R2... R16 PC IR ALU 11010010
31
Encoding instructions Example –1101000001000010 –INSTR ARG1 ARG2 –ADD Reg1 Reg2 31
32
This wire will carry a 1 only if the op code of the instruction is 1101. Instruction decoding 32 1 1 0 1 0 0 0 0 0 1 0 0 0 0 1 0 Circuitry to decode rest of instruction and carry it out (“execute” the instruction) “ADD” OP CODE R1 R2
33
Fetch-Decode-Execute cycle Fetch an instruction (& update PC) Decode instruction Execute instruction 33 Fetch (load instruction into IR from location in PC) Update PCDecodeExecute
34
Low-level languages Machine language –1101000001000010 Assembly language –ADD R1 R2 34
35
High level languages Java –We can write “x + y” instead of “ADD R1 R2” (in addition to with several MOV instructions) Others: C#, Erlang, Python, ML, Prolog, Lisp, etc. 35
36
Questions? 36
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.