Försättsblad till skriftlig tentamen vid Linköpings Universitet

advertisement
TDDI11.2009-05-27.08-12
Försättsblad till skriftlig tentamen
vid Linköpings Universitet
Cover page for written exam at Linköping University
Datum för tentamen
2009-05-27
Date of exam
Sal
TER2
Room
Tid
08:00-12:00
Time
Kurskod
TDDI11
Course code
Provkod
TEN1
LADOK code
Kursnamn/benämning
Programmering av inbyggda system
Course name
Embedded software
Institution
IDA
Department
Antal uppgifter som ingår i tentamen
8
Number of assignments
8 assignments for a total of 40 points
Antal sidor på tentamen
(inkl. försättsbladet)
4
Number of pages including cover
Jour/Kursansvarig
Klas Arvidsson
Responsible/Examiner
klaar@ida.liu.se
Telefon under skrivtid
013 - 28 21 46
Phone during exam
Besöker salen ca kl.
Start + 1h
Time of exam visit
Kuradministratör
Gunilla Mellheden
Course administrator
013 - 28 22 97, gunme@ida.liu.se
Tillåtna hjälpmedel
Ordlista och enkel miniräknare (+,-,*,/)
Allowed aids
Dictionary and simple pocket calculator (+,-,*,/)
Övrigt
Preliminary graded: U < 50% < 3 < 67% < 4 < 84% < 5
Grades may be raised or lowered based on overall impression.
Precise, explained and clearly motivated assumptions, statements and reasoning raise the impression and may triple the
points. Solve at most one assignment per sheet.
Results available within 10 working days.
Read all assignments and estimate how many points you can
get before you start.
Other information
Typ av papper
Rutigt, linjerat eller blankt
Paper to use
No preference
Antal exemplar i påsen
Number of exams
TDDI11.2009-05-27.08-12
1. (4p)
Early home appliances (fridge, dish-washer, wash-machine, TV, radio etc.) used various
ingenious analog devices coupled with mechanics to achieve the necessary control functions
and user interface.
a) What are the benefits, from design, manufacturing and user point of view, of replacing this
with embedded processors? (2p)
b) Pick two of the mentioned examples and explain in which cases we may call it an embedded
device. What characterize an embedded device? (2p)
2. (4p)
Explain how you can perform a 16-bit multiplication on a 8-bit processor. The result is of course
32-bit. You may assume a two register result of a 8-bit multiplication (16-bits spread in two
registers). You may also assume instructions that can add with carry.
3. (3p)
A circular buffer used by 4 processes for communication can contain max 256 values. Two 8bit variables keep track of the current read and write position, and one 16-bit variable how many
values that are currently stored.
int read() {
while (count == 0)
; /* empty buffer, wait for write */
--count;
return buffer[read++];
}
void write(int value) {
while (count == 256)
; /* full buffer, wait for read */
++count;
buffer[write++] = value;
}
a) Can the read and write variables after some time of use in this particular situation be
corrupted by overflow? (1p)
b) Can they possibly be corrupted by some other phenomena? If so, how? (2p)
4. (6p)
Your company are designing a new fan controller for computer geeks. A fan controller allows
to regulate the speed of a number of fans according to some temperature sensors and user
preference. The new controller will sport 4 temperature sensors, 6 PWM outputs to control up
to 6 fans, a “full speed” switch and a stepless dial the user may use to adjust the overall fan speed
(all fans). You are expecting a market of 1 million units if you can hit the market within 4
months.
Explain and motivate the design choices you would make for this system. Remember that
sometimes a good motivation is why you don’t select the competing option, and sometimes why
you do select the option you do.
a) Processor choice (general/special/single purpose processor) (2p)
b) Hardware choice (programmable logic, ready platform (semi-customizable), or full-custom
VLSI) (2p)
c) Software/OS choice (real-time OS, standard embedded OS, custom solution) (2p)
TDDI11.2009-05-27.08-12
5. (8p)
After a market hit and two million sold units, thanks to your choices in the previous question,
you received an offer for a good position in a security company that you could not refuse. They
are now about to create a new low cost, high security key-card-code door-lock. The vision it that
it will work as follow:
• The user slide her/his card in the card-reader (the card store only a unique card number)
• The user enters a four digit code
• The door opens if the code match the code registered for the card number
• After three attempts on the code the user must slide the card again
• If the user slide the card at unexpected times the system abandon the current operation and
wait for the code
• The keyboard should be kept disabled unless a code is needed
The hardware consist of the card reader, a 12-key keyboard, and a unit for communication with
the security center (code verification). Your task is to design the software. You immediately
understand that the key to a simple system is to split it in several modules, each with a simplistic
interface. You realize that if each module provide just the data you want from it as one ready
unit, you will not have to bother with all details in the “main” system.
a) Suggest how to organize the software system in a overview picture together with a short
explanation of how each part may be modeled. You should capture the key aspects of the
system, the details are left to another day. (3p)
b) Show how the “main” functionality outlined above can be modeled as a FSM. Clearly state
the inputs and outputs you assume. Make sure you use input signals from the subsystems in
a) to keep complexity down to at most 5 states. (5p)
N.B. As the product are in early development you can affect details of the system to your
advantage. It is very important to state any assumptions and customization your solution
require. But you can not negotiate the outlined main functionality in the list above.
6. (3p)
The PWM in the fourth assignment should be programmed to give a 60% average voltage level.
a) Briefly explain what a PWM (Pulse Width Modulator) is. (2p)
b) What value should be loaded in the 8-bit cycle_high register below? (1p)
clk
8-bit counter
1 when counter < cycle_high
cycle_high
cmp
7. (4p)
Optimizing code may give both some advantage and disadvantage.
a) What is the disadvantage of using inline functions? (1p)
b) What is the disadvantage of turning on heavy compiler optimization? (1p)
c) What is the disadvantage of hand-coded assembler? (1p)
d) What is the advantage of using fixed-point instead of floating point? (1p)
TDDI11.2009-05-27.08-12
8. (8p)
bit 7
bit 0
1 0 0 1 0 1 0 1
An array of 8 LED-lights are connected to your system. They are individually controlled by
manipulating the bits at address LED. It is a write only port. Write a set of “driver” functions to
control the lights. You may only use bit-manipulation, no loops.
void led_init()
/* turn the led indicated by integer ‘which’ on */
void led_turn_on(int which)
/* turn ON all leds corresponding to 1-bits in mask
* other lights must be kept the same */
void led_turn_on_mask(int mask)
/* turn OFF all leds corresponding to 1-bits in mask,
* other lights must be kept the same */
void led_turn_off_mask(int mask)
/* check if the led indicated by ‘which’ is on */
bool led_is_on(int which)
/* turn all leds with number lower than ‘which’ on,
* you may only use bit manipulation for full score */
void led_light_all_lower_than(int which)
Download