Skip to content

Commit 20dbfaf

Browse files
committedMay 3, 2019
added specifications per assignment
1 parent 4ec496a commit 20dbfaf

File tree

6 files changed

+1220
-0
lines changed

6 files changed

+1220
-0
lines changed
 

‎lab0/spec.html

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
2+
<!-- saved from url=(0051)http://csl.yale.edu/~rajit/classes/eeng348/lab0.php -->
3+
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4+
<title>EENG 348/CPSC 338: Digital Systems</title>
5+
<link rel="stylesheet" href="./EENG 348_CPSC 338_ Digital Systems_files/std.css">
6+
<link rel="stylesheet" href="./EENG 348_CPSC 338_ Digital Systems_files/default.css">
7+
<script src="./EENG 348_CPSC 338_ Digital Systems_files/highlight.pack.js"></script>
8+
<script>hljs.initHighlightingOnLoad();</script>
9+
<style> body { overflow-y: scroll; } </style>
10+
<style> .alttable tr:nth-child(odd) { background: #dfefff; } .alttable tr:nth-child(even) { background: #ffffff; } .alttable { border-spacing: 0 10px; } .alttable td { padding: 5px; } </style>
11+
</head>
12+
<body bgcolor="#ffffff" fgcolor="#000000">
13+
<table width="100%">
14+
<tbody><tr>
15+
<td width="3%">&nbsp;</td>
16+
<td width="94%" align="center"><table width="100%"><tbody><tr><td width="100%"><center>
17+
<table border="0" width="100%">
18+
<tbody><tr>
19+
<td align="right" valign="middle">
20+
<a href="http://csl.yale.edu/"><img src="./EENG 348_CPSC 338_ Digital Systems_files/yaleseas.jpg" height="75" border="0"></a></td>
21+
<td valign="middle" width="80%">
22+
<font face="helvetica,arial">
23+
<center>
24+
<font size="+3">EENG 348/CPSC 338: Digital Systems</font><br><font size="+2">Yale University</font>
25+
</center>
26+
</font></td>
27+
<td align="left" valign="middle">
28+
<a href="http://avlsi.csl.yale.edu/"><img src="./EENG 348_CPSC 338_ Digital Systems_files/anew2.gif" width="150" border="0"></a></td>
29+
</tr>
30+
</tbody></table><br></center>
31+
</td></tr><tr><td width="100%">
32+
<table width="100%"><tbody><tr><td width="90" valign="top"><br>
33+
<table>
34+
<tbody><tr><td align="right"><b><a href="http://csl.yale.edu/~rajit/classes/eeng348/index.php"><font size="-1">Home</font></a></b></td></tr>
35+
<tr><td align="right"><b><a href="http://www.piazza.com/class"><font size="-1">Discussions</font></a></b></td></tr>
36+
<tr><td align="right"><b><a href="http://csl.yale.edu/~rajit/classes/eeng348/lectures.php"><font size="-1">Lectures</font></a></b></td></tr>
37+
<tr><td align="right"><b><a href="http://csl.yale.edu/~rajit/classes/eeng348/labs.php"><font size="-1">Labs</font></a></b></td></tr>
38+
<tr><td align="right"><b><a href="http://csl.yale.edu/~rajit/classes/eeng348/handouts.php"><font size="-1">Handouts</font></a></b></td></tr>
39+
<tr><td align="right"><b><a href="http://csl.yale.edu/~rajit/classes/eeng348/policies.php"><font size="-1">Policies</font></a></b></td></tr>
40+
<tr><td align="right"><b><a href="http://csl.yale.edu/~rajit/classes/eeng348/calendar.php"><font size="-1">Calendar</font></a></b></td></tr>
41+
<tr><td align="right"><b><a href="http://canvas.yale.edu/"><font size="-1">Canvas</font></a></b></td></tr>
42+
</tbody></table>
43+
</td><td width="4">&nbsp;</td><td valign="top">
44+
<h3>Lab 0: Getting Started</h3>
45+
<b>Due: Jan 22, 11:59pm. Submit on Canvas.</b><br>
46+
<b>Weight: 0%</b>
47+
48+
<p>
49+
<b>Goal.</b> The goal of this assignment is to install the software we will be
50+
using for the class to interact with the Arduino Uno, and to make sure
51+
you are capable of writing a simple program and running it on the Uno.
52+
</p>
53+
54+
<p> The Arduino project is an open-source effort, and the popularity
55+
of the platform means that there are innumerable online resources
56+
available. The project <a href="https://www.arduino.cc/">home page</a>
57+
has a link to the <a href="https://www.arduino.cc/en/Main/Software">software</a> you should
58+
install on your computer. </p>
59+
60+
<p>
61+
<b>Precautions.</b>
62+
</p><ul>
63+
64+
<li>The micro-controller boards should be handled with care. Mis-use
65+
such as incorrectly connecting the boards is likely to damage the
66+
device.
67+
68+
</li><li>These devices are <i>static sensitive</i>. This means that you can
69+
"zap" them with static electricity (a bigger problem in the winter
70+
months). Be careful with handling boards. Your body should be at the
71+
same potential as the boards to avoid damaging them. For more
72+
information, check <a href="http://en.wikipedia.org/wiki/Electrostatic_sensitive_device">wikipedia</a>
73+
and the external links at the bottom.
74+
75+
</li></ul>
76+
77+
<p>
78+
<table border="0" cellspacing="4" cellpadding="2" width="100%">
79+
<tbody><tr bgcolor="#aaaacc" valign="center"><td><b>&nbsp;Collect the hardware and setup software</b></td>
80+
</tr>
81+
</tbody></table>
82+
83+
</p><p>
84+
For this lab, start by:
85+
</p><ul>
86+
87+
<li>Finding a team-mate
88+
89+
</li><li>Collect the hardware from the TFs. The hardware will be distributed
90+
after class on Friday January 18; you can also get it by contacting the TFs.
91+
The hardware consists of an Arduino Uno board and USB cable.
92+
93+
</li><li>Install the Arduino <a href="https://www.arduino.cc/en/Main/Software">software</a> (the latest version is 1.8.8)
94+
</li></ul>
95+
<p></p>
96+
97+
<p> The Arduino platform was designed to be accessible to people with
98+
very different backgrounds. This means the software tries to hide a
99+
lot of the details of microcontroller-based programming from the
100+
user. Programs are called "sketches", and while they use the C++
101+
language they even try to hide that from you to some extent.</p>
102+
103+
<p> A "sketch" has to specify two functions: "setup" and
104+
"loop". When a new sketch is created, the Arduino interface
105+
automatically populates it with blank functions as a reminder.</p>
106+
107+
<p>
108+
A simple model for the main program is the following code fragment:
109+
110+
</p><pre><code class="hljs bash"> setup();
111+
<span class="hljs-keyword">while</span> (1) {
112+
loop();
113+
}
114+
</code></pre>
115+
<p></p>
116+
117+
<p>
118+
<table border="0" cellspacing="4" cellpadding="2" width="100%">
119+
<tbody><tr bgcolor="#aaaacc" valign="center"><td><b>&nbsp;What you have to do</b></td>
120+
</tr>
121+
</tbody></table>
122+
123+
</p><p> To get started, plug in your Arduino board, and start the Arduino
124+
software package. Navigate the menus and select the Uno board
125+
(Arduino/Genuino Uno), and pick the port corresponding to the Uno. (On
126+
my mac, it looks something like /dev/cu.usbmodem...)</p>
127+
128+
<p>
129+
For the rest of this lab, run a simple program on the Uno that prints "Hello, world!" in a way that you can display it on your computer.</p>
130+
131+
<p> This is more complicated than it sounds (we will explain how this
132+
really works as the class progresses), since the Uno does not have a
133+
display. However, it does have a way to communicate with your laptop
134+
through the USB cable. One nice thing about using the Arduino platform
135+
is that there are a number of built-in libraries that provide useful
136+
functionality, making it easy to get started. One of these libraries
137+
can be used for communication through the USB interface to a terminal
138+
on your laptop.</p>
139+
140+
<p>
141+
Use the following function for "<code>setup()<code>":
142+
</code></code></p><code><code>
143+
144+
<pre><code class="hljs cpp"><span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">setup</span><span class="hljs-params">()</span> </span>{
145+
Serial.begin(<span class="hljs-number">9600</span>);
146+
Serial.println(<span class="hljs-string">"Hello, world!"</span>);
147+
}
148+
</code></pre>
149+
150+
<p> The "<code>loop()</code>" function can remain empty. Compile
151+
this sketch and upload it to the board (the "right arrow" icon).
152+
</p>
153+
154+
<p> If all is well, your program will compile successfully and be
155+
uploaded to the board. You should see some LEDs on the board flashing
156+
while this is happening.</p>
157+
158+
<p> Open the serial monitor (icon on the top right corner of the
159+
application). You should see "<code>Hello, world!</code>" displayed.</p>
160+
161+
<p>
162+
Some comments:
163+
</p><ul>
164+
165+
<li>You may see a slightly corrupted version of the "<code>Hello,
166+
world!</code>" string. In that case, clear the output in the serial
167+
monitor and hit the red reset button on the Uno. It should work
168+
properly this time.
169+
170+
</li><li>The "9600" matches the "9600 baud" setting in the serial
171+
monitor. This means that the peak communication rate between the
172+
microcontroller and laptop is 9600 characters per second.
173+
</li></ul>
174+
<p></p>
175+
176+
<p>
177+
<table border="0" cellspacing="4" cellpadding="2" width="100%">
178+
<tbody><tr bgcolor="#aaaacc" valign="center"><td><b>&nbsp; What you have to submit</b></td>
179+
</tr>
180+
</tbody></table>
181+
</p><p>
182+
Just a simple sentence in text saying "<code>We (name1, name2) successfully completed lab0!</code>"
183+
</p>
184+
<p>
185+
Please use one submission per team. We will use this to create groups on Canvas for future submissions.
186+
</p>
187+
188+
189+
</code></code></td></tr></tbody></table></td></tr><tr><td width="100%"><br>
190+
</td></tr></tbody></table></td><td width="3%">&nbsp;</td>
191+
</tr>
192+
</tbody></table><table noborder="" cellpadding="0" cellspacing="0" width="100%"><tbody><tr><td>&nbsp;</td><td>&nbsp;</td></tr><tr bgcolor="#00356b"><td width="2%"></td><td width="98%" align="left"><a href="http://www.yale.edu/"><img src="./EENG 348_CPSC 338_ Digital Systems_files/yale-white.png" alt="Yale"></a></td></tr></tbody></table>
193+
</body></html>

‎lab1/spec.html

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
2+
<!-- saved from url=(0051)http://csl.yale.edu/~rajit/classes/eeng348/lab1.php -->
3+
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4+
<title>EENG 348/CPSC 338: Digital Systems</title>
5+
<link rel="stylesheet" href="./spec_files/std.css">
6+
<link rel="stylesheet" href="./spec_files/default.css">
7+
<script src="./spec_files/highlight.pack.js"></script>
8+
<script>hljs.initHighlightingOnLoad();</script>
9+
<style> body { overflow-y: scroll; } </style>
10+
<style> .alttable tr:nth-child(odd) { background: #dfefff; } .alttable tr:nth-child(even) { background: #ffffff; } .alttable { border-spacing: 0 10px; } .alttable td { padding: 5px; } </style>
11+
</head>
12+
<body bgcolor="#ffffff" fgcolor="#000000">
13+
<table width="100%">
14+
<tbody><tr>
15+
<td width="3%">&nbsp;</td>
16+
<td width="94%" align="center"><table width="100%"><tbody><tr><td width="100%"><center>
17+
<table border="0" width="100%">
18+
<tbody><tr>
19+
<td align="right" valign="middle">
20+
<a href="http://csl.yale.edu/"><img src="./spec_files/yaleseas.jpg" height="75" border="0"></a></td>
21+
<td valign="middle" width="80%">
22+
<font face="helvetica,arial">
23+
<center>
24+
<font size="+3">EENG 348/CPSC 338: Digital Systems</font><br><font size="+2">Yale University</font>
25+
</center>
26+
</font></td>
27+
<td align="left" valign="middle">
28+
<a href="http://avlsi.csl.yale.edu/"><img src="./spec_files/anew2.gif" width="150" border="0"></a></td>
29+
</tr>
30+
</tbody></table><br></center>
31+
</td></tr><tr><td width="100%">
32+
<table width="100%"><tbody><tr><td width="90" valign="top"><br>
33+
<table>
34+
<tbody><tr><td align="right"><b><a href="http://csl.yale.edu/~rajit/classes/eeng348/index.php"><font size="-1">Home</font></a></b></td></tr>
35+
<tr><td align="right"><b><a href="http://www.piazza.com/class"><font size="-1">Discussions</font></a></b></td></tr>
36+
<tr><td align="right"><b><a href="http://csl.yale.edu/~rajit/classes/eeng348/lectures.php"><font size="-1">Lectures</font></a></b></td></tr>
37+
<tr><td align="right"><b><a href="http://csl.yale.edu/~rajit/classes/eeng348/labs.php"><font size="-1">Labs</font></a></b></td></tr>
38+
<tr><td align="right"><b><a href="http://csl.yale.edu/~rajit/classes/eeng348/handouts.php"><font size="-1">Handouts</font></a></b></td></tr>
39+
<tr><td align="right"><b><a href="http://csl.yale.edu/~rajit/classes/eeng348/policies.php"><font size="-1">Policies</font></a></b></td></tr>
40+
<tr><td align="right"><b><a href="http://csl.yale.edu/~rajit/classes/eeng348/calendar.php"><font size="-1">Calendar</font></a></b></td></tr>
41+
<tr><td align="right"><b><a href="http://canvas.yale.edu/"><font size="-1">Canvas</font></a></b></td></tr>
42+
</tbody></table>
43+
</td><td width="4">&nbsp;</td><td valign="top">
44+
<h3>Lab 1: Assembly language programming</h3>
45+
<b>Due: Feb <strike>2</strike> 4, 11:59pm. Submit on Canvas.</b><br>
46+
<b>Weight: 10%</b>
47+
48+
<p> <b>Goal.</b> The goal of this lab is to give you some experience
49+
writing assembly language programs for the AVR microcontroller. To
50+
successfully complete the lab, you will need to understand:
51+
52+
</p><ul>
53+
<li>The AVR instruction set
54+
</li><li>The Arduino programming environment (i.e. lab 0)
55+
</li><li>Calling conventions
56+
</li></ul>
57+
<p></p>
58+
59+
<table border="0" cellspacing="4" cellpadding="2" width="100%">
60+
<tbody><tr bgcolor="#aaaacc" valign="center"><td><b>&nbsp; Part 1: Getting started with assembly</b></td>
61+
</tr>
62+
</tbody></table>
63+
64+
<p> To write assembly in the unmodified Arduino environment, we will
65+
use a construct that is built into the C++ compiler that is invoked to
66+
compile your program. We can mix assembly language and C++ directly by
67+
using the "<code>asm</code>" directive. The flavor we use is
68+
sometimes called "<code>asm volatile</code>", and by using the
69+
keyword "<code>volatile</code>" we are telling the compiler not to
70+
touch the assembly language sequence that has been specified--i.e. to
71+
perform no optimizations.</p>
72+
73+
<p> A template Arduino sketch for assembly language programming is
74+
provided (<a href="http://csl.yale.edu/~rajit/classes/eeng348/files/sketch_asm.zip">zip file</a>). The
75+
"<code>.ino</code>" file contains the driver, which can be used to
76+
output values using the serial monitor. The file that should contain
77+
the assembly language is "<code>testasm.cpp</code>", which you can
78+
edit with any text editor directly.</p>
79+
80+
<p> The example sketch in the zip file ends with a loop that
81+
continuously blinks the built-in LED on the Uno. This is just a simple
82+
sanity check to make sure that your assembly language program ran
83+
properly and didn't mess up the stack.</p>
84+
85+
<p> For this part, write an assembly language program that adds two
86+
numbers. The two numbers to be added are the unsigned 8-bit integers
87+
"<code>a</code>" and "<code>b</code>" (see the
88+
"<code>testasm</code>" function), and the result should be a 16-bit
89+
value corresponding to their sum. In this part, you will be saving and
90+
restoring any register being modified (see the instructions in
91+
<code>testasm</code> function). (Hint: you will need to use the carry
92+
flag.)</p>
93+
94+
<table border="0" cellspacing="4" cellpadding="2" width="100%">
95+
<tbody><tr bgcolor="#aaaacc" valign="center"><td><b>&nbsp; Part 2: Procedures</b></td>
96+
</tr>
97+
</tbody></table>
98+
99+
<p>Implement the following two functions in assembly, respecting all calling conventions.</p>
100+
101+
<pre><code class="hljs cpp"><span class="hljs-function"><span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span> <span class="hljs-title">sumval</span><span class="hljs-params">(<span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">char</span> a, <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">char</span> b)</span>
102+
</span>{
103+
<span class="hljs-keyword">return</span> a+b;
104+
}
105+
106+
<span class="hljs-function"><span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span> <span class="hljs-title">diffval</span><span class="hljs-params">(<span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">char</span> a, <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">char</span> b)</span>
107+
</span>{
108+
<span class="hljs-keyword">if</span> (a &gt; b) {
109+
<span class="hljs-keyword">return</span> a-b;
110+
}
111+
<span class="hljs-keyword">else</span> {
112+
<span class="hljs-keyword">return</span> b-a;
113+
}
114+
}
115+
</code></pre>
116+
117+
<p>
118+
Finally, the main program in assembly language should set the return
119+
registers (<code>r25:r24</code>, see the template) to the value
120+
"<code>sumval(a,b)+diffval(a,b)</code>", using function calls to
121+
invoke the two functions and combine their return values.</p>
122+
123+
<table border="0" cellspacing="4" cellpadding="2" width="100%">
124+
<tbody><tr bgcolor="#aaaacc" valign="center"><td><b>&nbsp; Part 3: Recursion</b></td>
125+
</tr>
126+
</tbody></table>
127+
128+
<p>
129+
The <a href="https://en.wikipedia.org/wiki/Fibonacci_number">Fibonacci
130+
sequence</a> is defined by the recursion F<sub>0</sub> = 0,
131+
F<sub>1</sub> = 1, and F<sub>n</sub> = F<sub>n-1</sub> +
132+
F<sub>n-2</sub> for n&gt;1. A simple way to compute the nth Fibonacci
133+
number is the following C program (which also returns zero for
134+
negative arguments):</p>
135+
136+
<pre><code class="hljs cpp"><span class="hljs-function"><span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span> <span class="hljs-title">fib</span><span class="hljs-params">(<span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">char</span> n)</span>
137+
</span>{
138+
<span class="hljs-keyword">if</span> (n == <span class="hljs-number">0</span>) <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
139+
<span class="hljs-keyword">if</span> (n == <span class="hljs-number">1</span>) <span class="hljs-keyword">return</span> <span class="hljs-number">1</span>;
140+
<span class="hljs-keyword">return</span> fib(n<span class="hljs-number">-1</span>)+fib(n<span class="hljs-number">-2</span>);
141+
}
142+
</code></pre>
143+
144+
<p> Implement this recursive function using assembly language. Your
145+
implementation <u>must use recursion</u>. The result of the call to
146+
<code>fib()</code> should be displayed on the serial monitor. Your
147+
program should be able to work for any Fibonacci number that can be
148+
represented by an 8-bit value. Include your test cases in your
149+
submission as well. Use the template from part 1 for this part. For
150+
simplicity, you can simply ignore the second argument to the
151+
function. For the more adventurous, feel free to modify the
152+
"<code>asm</code>" directive to only use one argument.</p>
153+
154+
155+
<table border="0" cellspacing="4" cellpadding="2" width="100%">
156+
<tbody><tr bgcolor="#aaaacc" valign="center"><td><b>&nbsp; What you have to submit</b></td>
157+
</tr>
158+
</tbody></table>
159+
160+
<p> You should turn in three sketches, one for each part of the lab,
161+
as a single zip file. The zip file should be submitted through Canvas,
162+
with one submission per team. </p>
163+
164+
<p> The zip file should contain three sketches,
165+
"<code>sketch_part1</code>", "<code>sketch_part2</code>",
166+
"<code>sketch_part3</code>" that are folders containing the
167+
"<code>.ino</code>" file and the "<code>testasm.{cpp,h}</code>"
168+
files. Include a plain text file called "<code>README</code>" as
169+
part of your submission, where you can provide any information you
170+
like to the teaching staff grading the lab.</p>
171+
172+
<p> Please make sure your assembly language program is
173+
well-commented. In particular, for any program that includes
174+
functions, your comments should describe the stack layout (i.e. a
175+
detailed description of the stack frame for each function).</p>
176+
177+
<p>
178+
The sketches should also include a reasonable set of test cases.
179+
</p>
180+
181+
182+
</td></tr></tbody></table></td></tr><tr><td width="100%"><br>
183+
</td></tr></tbody></table></td><td width="3%">&nbsp;</td>
184+
</tr>
185+
</tbody></table><table noborder="" cellpadding="0" cellspacing="0" width="100%"><tbody><tr><td>&nbsp;</td><td>&nbsp;</td></tr><tr bgcolor="#00356b"><td width="2%"></td><td width="98%" align="left"><a href="http://www.yale.edu/"><img src="./spec_files/yale-white.png" alt="Yale"></a></td></tr></tbody></table>
186+
</body></html>

0 commit comments

Comments
 (0)