0% found this document useful (0 votes)
28 views22 pages

Lec1 - Introduction To Computers, Programs, and C++

The document provides an introduction to fundamentals of programming and computer hardware. It defines what a computer is and its basic components, including hardware like the central processing unit, memory, storage devices, and input/output devices. It explains how data and programs are stored in binary using bits and bytes. It also gives examples of computer hardware engineering concepts from the application layer down to the technology level, showing how different abstractions are built upon each other.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views22 pages

Lec1 - Introduction To Computers, Programs, and C++

The document provides an introduction to fundamentals of programming and computer hardware. It defines what a computer is and its basic components, including hardware like the central processing unit, memory, storage devices, and input/output devices. It explains how data and programs are stored in binary using bits and bytes. It also gives examples of computer hardware engineering concepts from the application layer down to the technology level, showing how different abstractions are built upon each other.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Fundamentals of Programming

Introduction to Computers, Programs, and C++


Computer
• What is?
‒ A computer is an electronic device that stores and processes data

• Data
‒ In computing, data is the information that has been translated into
a form that is efficient for movement or processing

• Computer Consists of
‒ Hardware
‒ Software

CS-114 Fundamentals of Programming 2


Hardware

• Keyboard
• Mouse
• What else??

3
CS-114 Fundamentals of Programming
Hardware Components
• Central processing unit
• Memory
• Storage devices
• Input devices
• Output devices
• Communication devices

CS-114 Fundamentals of Programming 4


Central Processing Unit
• Retrieves instructions from memory and executes them
• Two components
‒ Control unit
‒ Arithmetic / Logic unit
• Built from millions of transistors
• Internal Clock
‒ Used to control and synchronize the pace of operations
‒ Clock Speed Unit (hertz)
• Number of Cores

CS-114 Fundamentals of Programming 5


Central Processing Unit

CS-114 Fundamentals of Programming 6


Brainstorming
• Can you think of some examples of tasks that a human can
do easily but is a challenge for computers?
• Why do you think that computers lag behind humans in
this?

CS-114 Fundamentals of Programming 7


Bits and Bytes
• How data and program is stored in a computer?
‒ Set the series of switches On or Off
‒ On translates to 1 and Off translates to 0 (binary number system)
• Byte
‒ Minimum storage unit
‒ 8 bits form a byte
• Data Encoding
‒ encoding scheme is a set of rules that governs how a computer
translates characters, numbers, and symbols into data the
computer can actually work with (bits)
‒ ASCII: C translates to 01000011
• Memory units
‒ KB, MB, GB, TB is approximately 1000, 1 million, 1 billion, 1 trillion

CS-114 Fundamentals of Programming 8


Memory
• Computer’s work area for executing a program e.g RAM
• A program and its data must be moved into the computer’s
memory before they can be executed by the CPU
• Every byte in the memory has a unique address

Slower and less


expensive than
memory available
in CPU

CS-114 Fundamentals of Programming 9


Storage Devices
• RAM is volatile
‒ Data is lost when power is off
• Permanent storage elements?
‒ Hard disk
‒ CD / DVD
‒ Flash drive
• Programs and Data are store in permanent storage
‒ Moved to memory for processing

CS-114 Fundamentals of Programming 10


Input and Output Devices
• Keyboard
• Mouse
• Monitor
• Printer
• Touch-screen?

CS-114 Fundamentals of Programming 11


Communication Devices
• Dial-up Modem
• DSL
• Cable Modem
• Network Interface Card
• Wireless Network Adapter

What is a Computer Hardware Engineering - Stack ?

CS-114 Fundamentals of Programming 12


Computer Hardware Engineering - Stack

Application Sort an array of numbers


Algorithm 5,6,3,8,4,2 -> 2,3,4,5,6,8
Computer Engineering

Programming Language
Insertion sort algorithm
Operating System
1. Find minimum number in input array
Instruction Set 2. Move minimum number into output array
Architecture 3. Repeat steps 1 and 2 until finished
Microarchitecture
C implementation of insertion sort
Register-Transfer void isort( int b[], int a[], int n ) {
Level Gate Level for ( int idx, k = 0; k < n; k++ ) {
Circuits int min = 100;
for ( int i = 0; i < n; i++ ) {
Devices if ( a[i] < min ) {
Technology min = a[i];
idx = i;
}
}
b[k] = min;
a[idx] = 100;
}
}

CS-114 Fundamentals of Programming 13


Computer Hardware Engineering - Stack

Application Mac OS X, Windows, Linux


Algorithm Handles low-level hardware management
Computer Engineering

Programming Language
Operating System
Instruction Set
Architecture
Microarchitecture MIPS32 Instruction Set
Register-Transfer Instructions that machine executes
Level Gate Level ble $a2, done
Circuits z $a7, $zero
mov
Devices e
Technology li $t4, 99
move $a4, $a1
move $v1, $zero
li $a3, 99
lw $a5, 0($a4)
addiu $a4, $a4, 4
slt $a6, $a5, $a3
movn $v0, $v1, $a6
addiu $v1, $v1, 1
movn $a3, $a5, $a6

CS-114 Fundamentals of Programming 14


Computer Hardware Engineering - Stack

Application
How data flows
Algorithm through system
Computer Engineering

Programming Language
Operating System
Instruction Set Boolean logic gates
Architecture and functions
Microarchitecture
Register-Transfer Combining devices
Level Gate Level to do useful work
Circuits
Devices Transistors and wires
Technology

Si Si Si
Silicon process
technology Si Si Si

CS-114 Fundamentals of Programming 15


Computer Hardware Engineering - Stack

Application
Algorithm Traditional
Computer Science
Computer Engineering

Programming Language
Operating System
Instruction Set Computer Engineering is at the
Architecture interface between hardware and software
Microarchitecture and considers the entire system
Register-Transfer
Level Gate Level Traditional
Circuits Electrical Engineering
Devices
Technology

CS-114 Fundamentals of Programming 16


Computer Hardware Engineering - Stack

Application Lab Software


Algorithm pushing towards
hardware (CS,CE)
Computer Engineering

Programming Language
Operating System
Instruction Set
Architecture
Microarchitecture
Register-Transfer
Level Gate Level Lab
Circuits Hardware pushing
Devices towards software
Technology (EE,CE)

CS-114 Fundamentals of Programming 17


Computer Hardware Engineering - Stack

Application
Algorithm Application Requirements
• Suggest how to improve architecture
Computer Engineering

Programming Language
Operating System • Provide revenue to fund development
Instruction Set
Architecture Computer engineers provide feedback to guide
application and technology research directions
Microarchitecture
Register-Transfer
Level Gate Level Technology Constraints
Circuits • Restrict what can be done efficiently
Devices • New technologies make new arch possible
Technology

In its broadest definition, computer engineering is the


development of the abstraction/implementation layers that allow us to
execute information processing applications efficiently
using available manufacturing technologies

CS-114 Fundamentals of Programming 18


Computer Hardware Engineering - Stack

Application
Algorithm
Processor Compute
Computer Engineering

Programming Language
data
Operating System
Instruction Set
Architecture Input Output Move
Data Network Data data
Microarchitecture
Register-Transfer
Level Gate Level Memory Store
data
Circuits
Devices
Technology

Computer engineering’s basic building blocks


• Processors for computation
• Memories for storage
• Networks for communication

CS-114 Fundamentals of Programming 19


Did Can any hardware
function be implemented
you in software and vice
versa ?

know? Because its all 0s and 1s

CS-114 Fundamentals of Programming 20


System Design - Algorithm and Logic
• Algorithm
‒ Process of specifying a set of instructions or steps to
solve a particular problem or achieve a specific task
‒ Algorithms are the core building blocks of software
development
‒ They define how certain operations, behaviors, or
computations should be carried out
• Class Activity
‒ Algorithm for making a cup of tea
‒ Algo for sorting numbers

CS-114 Fundamentals of Programming 21


Making a cup of Tea
• Inputs:
‒ Boiling water
‒ Tea bag
‒ Cup
‒ Optional: Sugar, milk, or other additives

• Outputs:
‒ A cup of tea
‒ Algorithm:

• Boil Water:
‒ Place a kettle or pot with water on a heat source (e.g., stove).
‒ Turn on the heat source and wait for the water to come to a rolling boil. This is the "precondition" for making tea.

• Prepare the Cup:


‒ While the water is boiling, take a clean cup and place it on a flat surface.

• Add the Tea Bag:


‒ Once the water has boiled, carefully pour it into the cup. Be cautious to avoid burns.
‒ Insert a tea bag into the cup.

• Steep the Tea:


‒ Let the tea steep for a few minutes (typically 3-5 minutes, but you can adjust based on personal preference).
‒ Use a saucer or a small plate to cover the cup while steeping to keep the tea hot.

• Remove the Tea Bag:


‒ After steeping, remove the tea bag from the cup and discard it.

• Optional Additives:
‒ If desired, add sugar, milk, honey, or any other preferred additives to the tea. Stir well to ensure they are mixed.

• Enjoy:
‒ Your cup of tea is ready to be enjoyed. Be sure to allow it to cool to a suitable drinking temperature before sipping.

• Safety Note:
‒ Be cautious when handling hot water and hot tea. Avoid burns by using appropriate tools and being mindful of the
temperature.

CS-114 Fundamentals of Programming 22

You might also like