Skip to content

Commit 45c2d80

Browse files
committed
Chaper 9
1 parent 644d041 commit 45c2d80

9 files changed

Lines changed: 326 additions & 0 deletions
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
% Source: CPTR 280 Computer Organization and Assembly Language Fall 2023
2+
% File: "09 Automation (part 2) (key).pdf"
3+
% Author: James Foster, pogil@jgfoster.net
4+
5+
% comment out for student version
6+
% \ifdefined\Student\relax\else\def\Teacher{}\fi
7+
8+
\documentclass[12pt]{article}
9+
10+
\title{Activity 9: Addressable Memory}
11+
\author{James Foster}
12+
\newcommand{\activityeditor}{James Foster}
13+
\newcommand{\activitysource}{\url{pogil@jgfoster.net}}
14+
\date{Fall 2023}
15+
16+
\input{../../cspogil.sty}
17+
\usepackage{graphicx}
18+
\usepackage{tabularx}
19+
20+
\begin{document}
21+
22+
\begin{center}
23+
\maketitle
24+
\rolenames
25+
\end{center}
26+
27+
\keyquestions{
28+
\item Model 1, Question \#5
29+
\item Model 2, Question \#11
30+
\item Model 3, Question \#20
31+
}
32+
33+
\newpage
34+
\maketitle
35+
36+
We have looked a simple programmable computer. Now we add hardware and instructions for storing the code and the data in the same memory module.
37+
38+
\guides{
39+
\item Do 16-bit math with 8-bit memory.
40+
}{
41+
\item No additional process skills.
42+
}{
43+
No additional notes
44+
}
45+
46+
\input{load_instruction.tex}
47+
\newpage
48+
\input{addressable_memory.tex}
49+
\newpage
50+
\input{multi_byte_numbers.tex}
51+
52+
\end{document}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
\model{Addressable Memory}
2+
3+
\vspace{10pt}
4+
\begin{center}
5+
\includegraphics[width=0.85\textwidth]{figures/addressable_memory.png}
6+
\par\vspace{5pt}
7+
{\small Figure 3: Addressable Memory}
8+
\end{center}
9+
10+
Figure 3 shows the final major enhancement to the computer we are building.
11+
\begin{itemize}
12+
\item To the 16-Bit Program Counter (PC) we have added a Set control line that allows us to set the next instruction address to a 16-bit value obtained from the bottom two 8-bit (address) latches.
13+
\item The memory address for read/write is now specified by either the PC or the bottom two (address) latches based on a Select control line sent to the 2-1 Address Selector.
14+
\item Instead of having separate memory for code and data, we now share the memory (reducing cost and increasing flexibility).
15+
\item Instead of having a sequence of 8-bit instruction codes, we now have instructions made of an 8-bit opcode (operation code) followed by a 16-bit address (operand location). These values are read into the three latches shown in three consecutive clock ticks.
16+
\item Not shown are the instruction Decoder (to the right of the arrow labeled ``Code''), the 8-Bit Adder and the 8-Bit Data Latch (to the right of the arrows labeled ``8-Bit Data''), and the control lines coming out from the Decoder (the endpoints are shown with the affected components).
17+
\end{itemize}
18+
19+
\newpage
20+
21+
{\it\large Refer to Model 2 above as your team develops consensus answers
22+
to the questions below.}
23+
24+
\quest{15 min}
25+
26+
\Q What was the previous instruction size? What is the new instruction size? By what factor has the overall size of the instructions increased?
27+
\begin{answer}[0.5in]
28+
Previous instruction size: 1; new instruction size: 3; instruction size grew by 3x.
29+
\end{answer}
30+
31+
\Q Assuming that we can still read only one byte per clock cycle and that the clock speed is the same, what is the impact on speed by the instruction size changes?
32+
\begin{answer}[0.5in]
33+
One-third the speed.
34+
\end{answer}
35+
36+
\Q In Figure 1, what happened to the counter on each clock tick?
37+
\begin{answer}[0.5in]
38+
Counter increases by one.
39+
\end{answer}
40+
41+
\Q In Figure 1, what can be done to change the value of the counter to something other than the next integer? What value(s) (if any) can be assigned to the program counter?
42+
\begin{answer}[0.5in]
43+
Clear will reset it to zero.
44+
\end{answer}
45+
46+
\Q What new control line is added to the program counter in Figure 3? What does it do?
47+
\begin{answer}[0.5in]
48+
Set0 will take the values from high and low latches and put it into the counter.
49+
\end{answer}
50+
51+
\Q What is the impact of allowing a ``Set'' instruction (``Jump'') for the Program\key\\[-2.5mm] Counter?
52+
\begin{answer}[0.5in]
53+
We can now specify an address for the next instruction, so loop or skip.
54+
\end{answer}
55+
56+
\Q In Figure 1, what determines which address in memory will be provided to the adder?
57+
\begin{answer}[0.5in]
58+
The counter.
59+
\end{answer}
60+
61+
\Q What new component is added in Figure 3 between the counter and the memory?
62+
\begin{answer}[0.5in]
63+
The 2-to-1 Address Selector and a Select control line.
64+
\end{answer}
65+
66+
\Q In Figure 3, what determines which address in memory will be provided as output?
67+
\begin{answer}[0.5in]
68+
The 2-to-1 Address Selector selects either the Counter or the High and Low Latches.
69+
\end{answer}
70+
71+
\Q What is the impact of allowing a load/add/store instruction to specify an address?
72+
\begin{answer}[0.5in]
73+
We can now select something other than the counter, so the data can be in a separate location from the code.
74+
\end{answer}
75+
76+
\Q A variation of the Jump command is a Conditional Jump where the change to the PC happens only on if some specified condition exists. What conditions would be interesting?
77+
\begin{answer}[0.5in]
78+
Zero, non-zero, carry on or off, value negative or positive.
79+
\end{answer}
33.9 KB
Loading
35.4 KB
Loading
899 KB
Loading
52.4 KB
Loading
254 KB
Loading
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
\model{Load Instruction}
2+
3+
\vspace{10pt}
4+
\begin{center}
5+
\includegraphics[width=0.7\textwidth]{figures/programmable_computer_part2.png}
6+
\par\vspace{5pt}
7+
{\small Figure 1: Programmable Computer}
8+
\end{center}
9+
10+
\vspace{10pt}
11+
\begin{center}
12+
\begin{tabular}{|l|c|c|}
13+
\hline
14+
\textbf{Instruction} & \textbf{Hexadecimal Code} & \textbf{Binary Code} \\
15+
\hline
16+
Add (data to latch) & 0x00 & 0000 0000 \\
17+
\hline
18+
Clear (latch) & 0x01 & 0000 0001 \\
19+
\hline
20+
Subtract (data from latch) & 0x02 & 0000 0010 \\
21+
\hline
22+
Stop (the clock) & 0x04 & 0000 0100 \\
23+
\hline
24+
Store (latch to data) & 0x08 & 0000 1000 \\
25+
\hline
26+
\end{tabular}
27+
\end{center}
28+
29+
Figure 1 (copied from the previous lesson) shows a simple programmable computer with the following characteristics:
30+
\begin{itemize}
31+
\item A counter with 16-bit output that will increment on each clock tick (it can be reset to zero with the Start control line),
32+
\item Separate addressable memory for code and data that each output an 8-bit value based on the same 16-bit address (the value of the data memory can be set to the current data latch value by the Store control line),
33+
\item An 8-bit adder that calculates the sum (or difference based on the Subtract control line) of the latch and the value from memory,
34+
\item A latch that captures the result of the adder on each clock tick (or is cleared based on the Clear sum control line), and
35+
\item A decoder that takes each 8-bit instruction and sets the control lines appropriately.
36+
\end{itemize}
37+
38+
\newpage
39+
40+
{\it\large Refer to Model 1 above as your team develops consensus answers
41+
to the questions below.}
42+
43+
\quest{15 min}
44+
45+
\Q In Figure 1, the data path into the latch comes from what component?
46+
\hfill\ans[1in]{Adder}
47+
48+
\Q In Figure 1, what two instructions are required to get the value of a single memory location into the latch?
49+
(Hint: what would you add to a value to get the same value?)
50+
\begin{answer}[0.5in]
51+
Clear, Add
52+
\end{answer}
53+
54+
Figure 2 adds a new control line and a new component to our computer.
55+
56+
\vspace{10pt}
57+
\begin{center}
58+
\includegraphics[width=0.5\textwidth]{figures/load_instruction.png}
59+
\par\vspace{5pt}
60+
{\small Figure 2: Load Instruction}
61+
\end{center}
62+
63+
\Q What are the new elements?
64+
\hfill\ans{A 2-to-1 Selector and a Selection control line}
65+
66+
\vspace{10pt}
67+
A 2-to-1 Selector will pass on one of two inputs based on a control line. In this configuration, if the control line is 0,
68+
then the value from the adder will be passed to the latch. If the control line is 1, then the value from memory will be passed to the latch.
69+
70+
\Q How does this circuit simplify loading a value from memory into the latch?
71+
\begin{answer}[0.5in]
72+
Now it takes only one instruction.
73+
\end{answer}
74+
75+
\Q Suggest a name and a code for this instruction. (Hint: see the name of Figure 2\key\\[-2.5mm] and the pattern of hexadecimal codes used for previous instructions.)
76+
\begin{answer}[0.5in]
77+
Load (0x10)
78+
\end{answer}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
\model{Multi-Byte Numbers}
2+
3+
{\it\large Refer to Model 3 above as your team develops consensus answers
4+
to the questions below.}
5+
6+
\quest{20 min}
7+
8+
\Q Consider the expression with two unsigned integers: (1100 0001$_2$ + 0100 0011$_2$).
9+
\begin{itemize}
10+
\item What is the binary sum?
11+
\hfill\ans{1 0000 0100}
12+
\item How many bits are required for the answer?
13+
\hfill\ans{9}
14+
\end{itemize}
15+
16+
\Q Consider the 8-Bit Adder shown in Figure 4.
17+
\vspace{10pt}
18+
\begin{center}
19+
\includegraphics[width=0.3\textwidth]{figures/8bit_adder.png}
20+
\par\vspace{5pt}
21+
{\small Figure 4: 8-Bit Adder}
22+
\end{center}
23+
\begin{itemize}
24+
\item What are the data path widths (number of bits) for A, B, and Sum?
25+
\hfill\ans[1.5in]{8, 8, and 8}
26+
27+
\item What are the data path widths for Carry In and Carry Out?
28+
\hfill\ans[1in]{1 and 1}
29+
30+
\item How is this 8-Bit Adder different from the one shown in Figure 1?
31+
\begin{answer}[0.75in]
32+
It has a carry in and carry out.
33+
\end{answer}
34+
35+
\item If you were to use this 8-Bit Adder in the circuit shown in Figure 1, what value would you need for Carry In?
36+
What circuit component (from an earlier lesson) would you attach to the Carry In line to do proper math?
37+
\begin{answer}[1in]
38+
Carry in should always be zero; this can be achieved with ground.
39+
\end{answer}
40+
41+
\item What component would you add to the Carry Out line to ignore the overflow bit?
42+
\begin{answer}[0.75in]
43+
Carry out could be attached to ground.
44+
\end{answer}
45+
46+
\item If the carry lines are ignored for simple 8-bit addition, why do they exist?
47+
\begin{answer}[0.75in]
48+
So that we can do complex addition (say, 16-bit values).
49+
\end{answer}
50+
\end{itemize}
51+
52+
\vspace{-40pt}
53+
54+
\Q Consider the expression with two unsigned hexadecimal integers: (2345$_{16}$ + 3456$_{16}$)\key\\[-2.5mm]
55+
\begin{itemize}
56+
\item How many bits are required for each number?
57+
\begin{answer}[0.5in]
58+
4 bits for each digit, so 16-bits for each number.
59+
\end{answer}
60+
61+
\item How many bits are required to represent the sum?
62+
\begin{answer}[0.5in]
63+
The value 579B$_{16}$ is also just 16 bits.
64+
\end{answer}
65+
66+
\item Describe how you would use an 8-Bit Adder to perform this operation.
67+
\begin{answer}[1.5in]
68+
Add the low-order bytes: 45$_{16}$ + 56$_{16}$ = 9B$_{16}$ \\
69+
Add the high-order bytes: 23$_{16}$ + 34$_{16}$ = 57$_{16}$ \\
70+
Combine the high-order and low-order bytes to get the result of 579B$_{16}$
71+
\end{answer}
72+
\end{itemize}
73+
74+
\Q Consider the expression with two unsigned hexadecimal integers: (2385$_{16}$ + 3496$_{16}$).
75+
\begin{itemize}
76+
\item How would you use the Carry In line to add the low-order 8 bits (85$_{16}$ + 96$_{16}$)?
77+
\begin{answer}[0.75in]
78+
The carry-in value should be zero.
79+
\end{answer}
80+
81+
\item How would you use the Carry In line to add the high-order 8 bits?
82+
\begin{answer}[1in]
83+
The carry-in value for the high-order addition should be the (saved) carry out for the low-order addition.
84+
\end{answer}
85+
86+
\item Suggest a name for this new kind of Add command.
87+
\begin{answer}[0.75in]
88+
Add with carry.
89+
\end{answer}
90+
\end{itemize}
91+
92+
\Q What does the circuit in Figure 1 use to hold intermediate 8-bit sums?
93+
\begin{answer}[0.75in]
94+
An 8-bit latch.
95+
\end{answer}
96+
97+
\Q What has been added in Figure 5 compared to Figure 4?
98+
\vspace{10pt}
99+
\begin{center}
100+
\includegraphics[width=0.35\textwidth]{figures/add_with_carry.png}
101+
\par\vspace{5pt}
102+
{\small Figure 5: Add with Carry}
103+
\end{center}
104+
105+
\begin{answer}[0.75in]
106+
A Use Carry control line and a carry buffer or latch.
107+
\end{answer}
108+
109+
\Q If we used 0x20 as the code for the Add with Carry instruction, how would it differ from the Add instruction code?
110+
\begin{answer}[1in]
111+
It has a 1 in bit 5 (the 6th bit from the right), while all other are 0.
112+
\end{answer}
113+
114+
\Q If we attached bit 5 of the instruction decoder to the ``Use Carry'' control line, what logic gate(s) would provide the desired behavior?
115+
\begin{answer}[1in]
116+
An AND gate would have a 1 out if both the carry latch and the use carry control line are 1.
117+
\end{answer}

0 commit comments

Comments
 (0)