Title: CPS 125: Digital Computation and Programming
1CPS 125 Digital Computation and Programming
- Week 1 Overview of Computers and Software
2Why do engineers study programming?
- Benefit
- from the ability to write their own programs
- Problems inevitably arise that are outside the
range of problems solvable by the application
software to which an individual
engineer/scientist has immediate access. - Critical
- Expanding societys technical knowledge
- Applying the principles of science and
mathematics to societys problems, overlooking
the limitations of a software
3Computer
- exists almost every where in our living
environment - From refrigerators, coffee machines, cars,
stereos, mp3s, cell phones, boats, toys, - A modern car contains about 50 microprocessors
- If you've got a late-model luxury sedan, two or
three processors might be obvious in the GPS
navigation system or the automatic distance
control. - The current 7-Series BMW and S-class Mercedes
boast about 100 processors apiece.
4Computer in twenty-first century
5Important hint
- Learning programming is an essential to be a
professional engineer for all fields.
6Outline
- What Is a Computer?
- Computer Components
- Computer Software
- Software Development Method
7What Is a Computer
- Computer
- An electronic machine that can receive, store,
- transform, and output data of all kinds
- numbers, text, images, graphics, and sound, to
name a few. - Conceptual Layers of a Computer System
- Application programs
- Operating system
- Computer hardware
- External connections
8 What are Machine Structures?
Hardware
- Coordination of many levels of abstraction
9Computer Components
10Computer System
- CPU Main Memory core
- Secondary Storage I/O Devices peripherals
- Bus communication between components
11Central Processing Unit
- CPU the brain of a computer, transforms data
from one to another, understands and executes
computer programs written in machine language - The circuitry of a modern CPU consists of
millions of miniature circuits manufactured in a
sliver of silicon known as Integrated Circuit
(IC) or chip - Microprocessor an entire CPU on a single chip
- Arithmetic operations are performed using binary
number system where data and control information
(instructions) uses only two basic symbols 0,
1 represented by electronics signals
12Components of CPU
- Arithmetic/Logic Unit (ALU)
- performs arithmetic operations (addition,
subtraction, etc.) and makes logical comparisons
(and, or, equal to, etc.) - Control Unit (CU)
- decodes machine instructions and sends control
signals to the other components to carry out the
instructions - Registers
- high speed memory locations inside the CPU, used
to store temporarily the current instructions and
data values
13Question
- Which of the following statement is true?
- A). CPU Main Memory core of a computer
- B). The CPU consists of ALU,CU and Register
- C). CU decodes machine instructions and sends
control signals to the other components to carry
out the instructions - D). Registers are high speed memory located
inside the CPU - E). All of the above
14Question 2
- The arithmetic and Logic Unit
- A). Decode instructions
- B). Perform decision making
- C). Performs arithmetic operations
- D). All of the above
- E). C and B above
15Binary Numbers
- All information in a typical computer is
represented in binary - Bits a binary digit (0 or 1)
- Bytes 8 bits of data, which is the amount of
memory required to represent one character - Conversion from binary to decimal
- b7 b6b5b4b3b2b1b0, where bi has place value 2i
- Convert to decimal
- b7 27b626 b525 b424 b323 b222 b121
b020
16Example of Binary-Decimal Conversion
- 124 in binary
- Answer 01111100
- 251 ?
- 10101011 in decimal
- Answer 171
- 01101111 ? In Binary
17Negative binary numbers
- 2s complement notation
- In one's complement, positive numbers are
represented as usual in regular binary. However,
negative numbers are represented differently. To
negate a number, replace all zeros with ones, and
ones with zeros - flip the bits - Begin with the number in one's complement. Add 1
if the number is negative.
18True or false?
- Arithmetic operations are performed by CPU
using binary number system
19Memory
- The main memory is used to store the program and
data which are currently manipulated by the CPU - The main memory is fast and of limited size
- The most common memory type is random access
memory (RAM) - The information stored in RAM will be lost when
electrical power is removed - ROM
20Memory Cells
- Memory a collection of memory cells
- Memory cell
- Memory cell can be randomly accessed
21Question
- Answer Ture/False
- Every byte in memory has a unique address to be
accessed - RAM stand for Random Access Memory
- can be read and written.
- ROM stand for Read Only Memory
- RAM is used to store application programs
- ROM is used to install System routines
- used for store the system BIOS and video BIOS
22Secondary Storage
- The secondary storage provides the long-term
storage of large amounts of data and program - Before data and program in the secondary storage
can be manipulated by the CPU, they must first be
loaded into the main memory - The secondary storage is relatively slow and of
very large size
23Secondary Storage Devices
- Magnetic Disks thin platter of metal or plastic
on which data are represented by magnetized spots
arranged in tracks - Hard disks (attached to disk drives) many GB
- Floppy disks (removable) 1.44 MB
- Zip disks (removable) 100 or 250 MB
24Secondary Storage Devices
- Optical Disks silvery plastic platter on which a
laser records data as pits in a spiral track on
one side of disk - CD 680 MB DVD 4.7 GB on one layer
- Magnetic Tape a sequential-access device (for
backup of data) - File named collection of data stored on disk
- e.g. c\compons\ics\cpus\pent.txt (PC)
25Data Storage Hierarchy
26Storage Capacity
Units Abbrev. Equivalent to Comparison to Power of 10
Byte B 8 bits
Kilobyte KB 1024 (210) bytes gt 103
Megabyte MB 220 bytes gt 106
Gigabyte GB 230 bytes gt 109
Terabyte TB 240 bytes gt 1012
27Input and Output Devices
- Provide interfaces for humans to communicate with
computers - Input devices
- Keyboards type into text
- Mouse, track balls, touch pads pointing devices
for input of position/selection data - Scanner convert image to a grid of pixels
- Output devices
- Monitor, printer, speaker, etc.
28Networks
- Groups of individual computers and peripheral
devices linked together to share information and
resources. - Local Networks (LAN)
- Wide Area Networks (WAN)
- Internet
- Links machine throughout the world
29Connecting Computers LAN
computer
computer
computer
Local Area Network (LAN)
color printer
BW printer
30Connecting Computers WAN
31Computer Software
- Two Types of Software
- Operating System
- Application Software
- Computer Languages
- Machine Language
- Assembly Language
- High-Level Language
- From Source-Code to Executable Code
32Operating System
- Control and manage computer resources
- Main functions
- Communicating with computer users
- Managing allocation of computer resource
- Collecting input and conveying output
- Accessing and writing to secondary storage
- Authorization
- Widely used operating systems
- UNIX, Windows, Macintosh OS, and OS/2, etc.
33Application Software
- Application software is the software that has
made using computers indispensable and popular - Common application software
- Word processors
- Spreadsheets
- Database management systems
- Drawing programs
- Learning how to develop application software is
our focus
34Computer Languages
- Machine Languages
- A collection of binary instructions
- Hard to understand by humans while the only
understandable language by computers - Specific to a particular type of CPU
- Assembly Languages
- Operations are represented by mnemonics,
variables are represented by names, so is more
readable - Dependent on type of CPU
35Example of machine language code
- 000000 00001 00010 00110 00000 100000
- 100011 00011 01000 00000 00001 000100
- 000010 00000 00000 00000 10000 000001
- adding the registers 1 and 2 and placing the
result in register 6 - Loading a value from the memory cell 68 cells
after the one register 3 points to into register
8 - Jumping to the address 1025
36Example of Assembly language code
- page 60,132
- TITLE A07LOOP (COM) Illustration of LOOP
- .MODEL SMALL
- .CODE
- ORG 100H
- A10MAIN PROC NEAR
- MOV AX,1 Initialize AX and
- MOV BX,1 BX to 1,
- MOV CX,10 CX for 10 loops
- INC AX Add 01 to AX
- A20 ADD AX,BX Add BX to AX
- MOV BX,AX
- LOOP A20 Decrement CX,
- loop if nonzero
- MOV AX,4C00H End processing
- INT 21H
- A10MAIN ENDP
- END A10MAIN
37Computer Language
- High-Level Language
- Closer to the human way of expression
- Using higher-level of abstraction concepts from
the application area for which it is intended - Independent of a given hardware
- The downside computers do not understand
high-level languages
38High-Level Language
39Software Development Cycle
40Software Development Method
- Specify the problem requirements
- Analyze the problem
- Design the algorithm to solve the problem
- Implement the algorithm in a high-level computer
language - Test and verify the completed program
- Maintain and update the program
41An Example for Problem Analysis
- Problem statement
- Calculate and display the volume of a cylinder
given its base radius and height in centimeters. - Summarization
- Problem inputs
- Radius of base of a cylinder (in centimeters)
- Height of cylinder (in centimeters)
- Problem outputs
- Volume of cylinder (in cubic centimeters)
- Relationship between input and output
- The formula for the volume of a cylinder V p r2h
42Design
- Algorithm a list of instructions to solve a
problem - Top-down design
- List major steps, or sub-problems
- Solve the sub-problems
- Algorithm refinement
- Basic algorithm for a programming problem
- Get the data -gt Perform the computations -gt
Display the results - Desk check
43Implementation, Testing, and Maintenance
- Implementation writing it as a program, which
means converting each step into one or more
statements in a programming language - Test testing the completed program to verify
that it works as desired, with several runs and
different sets of data - Maintenance modifying program to remove
undetected errors and to keep it up-to-date - Caution Failure is part of the process
44Summarize
- What Is a Computer
- Computer Components
- Computer Software
- Software Development Method
45(No Transcript)
46 Week1