This repository has been archived by the owner on Jul 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lecture1.tex
92 lines (81 loc) · 2.76 KB
/
lecture1.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
\chapter{Intro, Number Representation}
\section{Great Ideas in Computer Architecture}
\begin{enumerate}
\item Abstraction: Layers of representation/interpretation
\item Moore’s Law: Designing through trends
\item Principle of Locality/Memory Hierarchy
\item Parallelism \& Amdahl's Law (which limits it)
\item Dependability via Redundancy
\end{enumerate}
\section{Number Representation}
The atom of computer information is a \emph{bit}. Bits can represent anything.
\begin{itemize}
\item A \emph{nibble} is 4 bits.
\item A \emph{byte} is 8 bits.
\item A \emph{word} is 4 bytes.
\item A \emph{floating point} is 32 bits (single precision) or 64 bits (double precision).
\end{itemize}
\subsection{Unsigned Representation}
\begin{itemize}
\item Total range: \([0, 2^{n}-1]\)
\end{itemize}
\subsection{Sign and Magnitude}
MSB is the sign.
\begin{itemize}
\item Range of negative values: \([-(2^{n-1}-1), -0]\)
\item Range of positive values: \([+0, 2^{n-1}-1]\)
\item Total range: \([-(2^{n-1}-1), 2^{n-1}-1]\)
\item Problem: 2 zeros, difficult to represent
\end{itemize}
\subsection{One's Complement}
Flip the bits of the positive number to form the negative counterpart.
\begin{itemize}
\item Total range: \([-(2^{n-1}-1), 2^{n-1}-1]\)
\item Problem: impractical
\end{itemize}
\subsection{Two's Complement}
Shift the number line of one's complement by 1 to obtain just 1 zero.
\begin{itemize}
\item Negation: flip all bits and add 1
\item Range of negative values (shifted right by 1 compared to One's Complement): \([-(2^{n-1}), 0]\)
\item Range of positive values: \([0, 2^{n-1}-1]\)
\item Total range: \([-(2^{n-1}), 2^{n-1}-1]\)
\end{itemize}
\begin{description}
\item[Overflow] Computer is unable to represent the value returned.
If signs of operands are equal and sign of result is different from sign of operands, overflow occurs.
\begin{itemize}
\item 2 positives: if result < 0 \(\implies\) overflow
\item 2 negatives: if result > 0 \(\implies\) overflow
\item 1 positive, 1 negative: no overflow
\end{itemize}
\end{description}
\subsection{Bias Encoding}
Interpret the number as an unsigned integer and shift the number by the bias s.t. the lowest value is at zero.
\begin{itemize}
\item Two's complement bias: \(N = -(2^{n-1}-1)\)
\item Total range: \([-(2^{n-1}-1), 2^{n}-2^{n-1}]\)
\end{itemize}
\section{Number System Conversion
}
\begin{tabular}{ |c|c|c| }
\hline
\textbf{Decimal} & \textbf{Hex} & \textbf{Binary} \\
\hline
1 & 1 & 0001 \\
2 & 2 & 0010 \\
3 & 3 & 0011 \\
4 & 4 & 0100 \\
5 & 5 & 0101 \\
6 & 6 & 0110 \\
7 & 7 & 0111 \\
8 & 8 & 1000 \\
9 & 9 & 1001 \\
10 & A & 1010 \\
11 & B & 1011 \\
12 & C & 1100 \\
13 & D & 1101 \\
14 & E & 1110 \\
15 & F & 1111 \\
\hline
\end{tabular}