Download presentation
Presentation is loading. Please wait.
1
Introduction to Computer Engineering
CS/ECE 252, Fall 2016 Kai Zhao Computer Sciences Department University of Wisconsin – Madison
2
Releasing Untested Software
Boss pressuring you to release software Every day delay is $1 million in sales Is it okay to release software not fully tested? What if it’s a medical device? A number of patients receive up to 100x the intended dose of radiation therapy in died as a direct results and 21 died the following years A number of patients receive up to 100x the intended dose of radiation therapy in
3
Ethics Wrapup Laws Ethics Discussion
Set of rules with civil and/or criminal penalties can be enforced by governmental bodies Ethics Set of standards, usually voluntary Discussion Usually, no clear right and wrong Choose between competing interests
4
Recap Story behind Quote of the Day Quote of the Day:
“It is a good thing for an uneducated man to read books of quotations.” -- Sir Winston Churchill
5
Chapter 1: Abstraction and Complexity
Abstraction helps us manage complexity Complex interfaces Specify what to do Hide details of how Application Program CS302 Operating System CS537 Compiler CS536 Machine Language (ISA) CS/ECE354 Goal: Use abstractions yet still understand details Computer Architecture CS/ECE552 Scope of this course Digital Design CS/ECE352 Electronic circuits ECE340
6
Chapter 2: Number Representation
2’s complement representation -23 22 21 20 1 2 3 4 5 6 7 -23 22 21 20 1 -8 -7 -6 -5 -4 -3 -2 -1
7
Chapter 2: Hexadecimal and Operations
Hexadecimal table Addition Binary Hex Decimal Unsigned 2’s complement 1000 8 -8 1001 9 -7 1010 A 10 -6 1011 B 11 -5 1100 C 12 -4 1101 D 13 -3 1110 E 14 -2 1111 F 15 -1 Binary Hex Decimal 0000 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 (104) (-10) (-16) + (-9) (98) (-19)
8
Chapter 3: Transistor Gate Supply Voltage Output P-type transistor
Ground N-type transistor Gate Behavior 1 Closed Output=0 Open Output=Z Gate Behavior Closed Output=1 1 Open Output=Z
9
Chapter 3: Building logic gates from transistors
NOR gate A B C 1
10
Chapter 3: implementing truth tables w/ logic gates
D 1 1. AND combinations that yield a "1" in the truth table. 2. OR the results of the AND gates.
11
Chapter 3: Memory R is used to “reset” or “clear” the element – set it to zero. S is used to “set” the element – set it to one. If both R and S are one, out could be either zero or one. “quiescent” state -- holds its previous value note: if a is 1, b is 0, and vice versa 1 1 1 1 1 1 1 out out 1 1
12
Chapter 3: Finite State Machine
A description of a system with the following components: A finite number of states A finite number of external inputs A finite number of external outputs An explicit specification of all state transitions An explicit specification of what causes each external output value.
13
Chapter 4: Von Neumann Model
14
Chapter 5: LC-3 ISA
15
Chapter 6: Programming via Iterative Refinement
Decompose task into a few simpler subtasks. There are three basic ways to decompose a task:
16
Chapter 6: Debug by Tracing
execute instruction sequences set/display registers set/display memory set breakpoints
17
Chap7: Char Count in Assembly Language (1 of 3)
; ; Program to count occurrences of a character in a file. ; Character to be input from the keyboard. ; Result to be displayed on the monitor. ; Program only works if no more than 9 occurrences are found. ; Initialization .ORIG x3000 AND R2, R2, #0 ; R2 is counter, initially 0 LD R3, PTR ; R3 is pointer to characters GETC ; R0 gets character input LDR R1, R3, #0 ; R1 gets first character ; Test character for end of file TEST ADD R4, R1, #-4 ; Test for EOT (ASCII x04) BRz OUTPUT ; If done, prepare the output
18
Chap7: Char Count in Assembly Language (2 of 3)
; ; Test character for match. If a match, increment count. NOT R1, R1 ADD R1, R1, R0 ; If match, R1 = xFFFF NOT R1, R1 ; If match, R1 = x0000 BRnp GETCHAR ; If no match, do not increment ADD R2, R2, #1 ; Get next character from file. GETCHAR ADD R3, R3, #1 ; Point to next character. LDR R1, R3, #0 ; R1 gets next char to test BRnzp TEST ; Output the count. OUTPUT LD R0, ASCII ; Load the ASCII template ADD R0, R0, R2 ; Covert binary count to ASCII OUT ; ASCII code in R0 is displayed. HALT ; Halt machine Do comparison by adding not
19
Chapter 9.2 Subroutines ; CountChar: subroutine to count occurrences of a char CountChar ST R3, CCR3 ; save registers ST R4, CCR4 ST R7, CCR7 ; JSR alters R7 ST R1, CCR1 ; save original string ptr AND R4, R4, #0 ; initialize count to zero CC1 JSR FirstChar ; find next occurrence (ptr in R2) LDR R3, R2, #0 ; see if char or null BRz CC2 ; if null, no more chars ADD R4, R4, #1 ; increment count ADD R1, R2, #1 ; point to next char in string BRnzp CC1 CC2 ADD R2, R4, #0 ; move return val (count) to R2 LD R3, CCR3 ; restore regs LD R4, CCR4 LD R1, CCR1 LD R7, CCR7 RET ; and return
20
Chapter 8: I/O CPU Control/Status Registers Data Registers
CPU tells device what to do -- write to control register CPU checks whether task is done -- read status register Data Registers CPU transfers data to/from device Device electronics performs actual operation pixels to screen, bits to/from disk, characters from keyboard Graphics Controller Control/Status CPU Electronics display Output Data
21
Chapter 9.1 TRAPs Code Equivalent Description HALT TRAP x25
Halt execution and print message to console. IN TRAP x23 Print prompt on console, read (and echo) one character from keybd. Character stored in R0[7:0]. OUT TRAP x21 Write one character (in R0[7:0]) to console. GETC TRAP x20 Read one character from keyboard. Character stored in R0[7:0]. PUTS TRAP x22 Write null-terminated string to console. Address of string is in R0.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.