EE382C Embedded Software Systems - Hints for Homework #1
For the programming parts of the homework assignments, please e-mail
the source code and a makefile (if there are multiple source code files)
to the grader.
- Problem 1.2: You can phrase each difference in less than a sentence.
- Problem 1.3: You can phrase each advantage and each disadvantage
in less than a sentence.
- Problem 1.4: C++ Style.
Software Development in the Unix Environment may be of use to you.
Before submitting the code for grade, you might want to read over
tips for writing better C/C++ code.
I do not recommend that you use the standard C++ template library.
- Problem 1.4: Profiling Execution Time.
In C++, there are many choices of functions to use in timing
execution time of a fragment of code.
As far C routines go, you can check the <sys/time.h> include
file to see what your options are. On the LRC machines, this
include file would be /usr/include/sys/time.h. Options include:
Here is part of the man page entry for gethrtime:
- gettimeofday: not accurate to the nearest millisecond
- getitimer: get interval timer. This what Ptolemy Classic
uses when profiling runtimes. See the ProfileTimer
C++ class defined by
This class relies on include files from the directory
- gethrtime: get high resolution time. See the man page on
a Unix machine.
The gethrtime() function returns the current high-resolution
real time. Time is expressed as nanoseconds since some
arbitrary time in the past; it is not correlated in any way
to the time of day, and thus is not subject to resetting or
drifting by way of adjtime(2) or settimeofday(3C). The hi-res
timer is ideally suited to performance measurement tasks,
heap, accurate interval timing is required.
- Problems 1.4 and 1.5: Comparing Execution Time.
Be sure that you are timing the same events in C++ and Java.
The Unix command
time would provide a crude
way to time to overall execution of the programs.
- Problems 1.4 and 1.5: FIR Filtering.
I am asking you to implement an FIR filter and pass a stream
(sequence) of samples through it.
The FIR filter takes one sample as input, adds it to a buffer
containing the previous input samples, computes the filter response
in the discrete-time domain, and outputs the filter response.
Hence, each time that the FIR filter executes, it takes in one
sample as input and produces one sample of output.
You are going to need to initialize the buffer holding the
current and previous input samples to zero.
In this case, the input and output data values are integers;
hence, the circular buffer will hold integers.
- Problems 1.4 and 1.5: Modulo Addressing.
This is one of the addressing modes on a conventional
Using modulo addressing is a way to implement a circular buffer.
If the buffer were of length 10, and
I were stepping through the array starting at index 9,
then the indices into the array would be taken modulo 10,
i.e., 9 becomes 9, 10 becomes 0, 11 becomes 1, ....