IL2206 Embedded Systems http:www.ict.kth.secoursesIL2206 - PowerPoint PPT Presentation

1 / 33
About This Presentation
Title:

IL2206 Embedded Systems http:www.ict.kth.secoursesIL2206

Description:

Course home page on the webb. Registration to the course. Schedule ... Tentamen. 4. Nios IDE (rep) I/O: polling/interrupt. Performance: Processor and Memory ... – PowerPoint PPT presentation

Number of Views:157
Avg rating:3.0/5.0
Slides: 34
Provided by: johanwe
Category:

less

Transcript and Presenter's Notes

Title: IL2206 Embedded Systems http:www.ict.kth.secoursesIL2206


1
IL2206 Embedded Systemshttp//www.ict.kth.se/cour
ses/IL2206
  • Exercise 0
  • Johan Wennlund, jwd_at_kth.sequestions to
    il2206-teachers_at_ict.kth.se
  • Administrative information
  • Laboratory course information
  • Laboratory equipement information
  • Laboratory exercise 0 information

2
IL2206 Embedded Systemshttp//www.ict.kth.se/cour
ses/IL2206
  • Exercise 0
  • Administration
  • Course home page on the webb
  • Registration to the course
  • Schedule found in daisy system
  • Examination, labs (3p) and final exam (4,5p)

3
IL2206 Embedded Systemshttp//www.ict.kth.se/cour
ses/IL2206
Nios IDE (rep) I/O polling/interrupt Performan
ceProcessor and Memory RealTime OS
2 sep
2-3 sep
5 sep
4 sep
5 sep
9 sep
15 sep
10 sep
11 sep
18 sep
19 sep
25 sep
23 sep
24 sep
29 sep ...
26 sep
2 okt
7 okt
9 okt
13 okt
10 okt
23 okt
4
Laboratory exercises
  • Registration using Daisy system
  • Each person registrates on each lab
  • Laboratory exercise on personal laptops
  • 2 students lab together on one DE2-board
  • Individual examination
  • Labs start time sharp 08.00, 10.00, 13.00
  • Preparations must be done in advance
  • Laboratory instructions on the webb home-page

5
Nios II C-code exampleLaboratory 0 and 1
  • int timeloc 0x5957 / startvalue given in
    hexadecimal/BCD-code /
  • define TRUE 1
  • extern void puttime(int timeloc)
  • extern void tick(int timeloc)
  • extern void delay (int millisec)
  • extern int hexasc(int invalue)
  • int main ()
  • while TRUE
  • puttime (timeloc)
  • tick (timeloc)
  • delay (1000)
  • return 0

6
Laboratory exercise 0
  • Install Altera IDE on your laptops
  • Write program codes that print time 5957
  • puttime is given in C-code
  • hexasc write in Nios II assembly-code
  • tick updated in C-code
  • delay write in Nios II assembly-code
  • print characters using C-code putchar()
  • Preparations Write all progams and simulate
  • Laboration Show programs and run on DE2-board

7
Laboratory exercise 1
  • Run the program printing time 5957
  • Output to Parallel I/O LED/HEX 5957
  • Poll parallel input I/O, keys
  • keys affect output start/stop, up/down
  • Call-back function using hardware Timer
  • Interrupts generated from keys
  • Calculate primes in background
  • All programs written in C-code

8
Laboratory exercise 2Performance
  • Memory hierarchy, cache ...
  • Different CPU-cores
  • Program / compiler optimization
  • ...

9
Laboratory exercise 3RTOS
  • Real Time Operating System
  • Scheduling
  • Semaphores
  • Synchronization
  • Mutual exclution
  • ...

10
Some parts of a Computer
CPU
BUS
program
MEM
I/O
data
11
Program execution(machine code)
FETCH (update PC)
12
Nios-II configurationon DE2-board
bus logic
BUS
...
TIMER
TOGGLES
KEYS
LEDS
13
Overview
Nios II CPU in FPGA
Configure FPGA
Load Program
14
Computer designis already done
  • Choice of components
  • CPU Nios II/s
  • Memory
  • I/O ports
  • ...
  • Compile and generate configuration files
  • HW configuration file.sof
  • SW configuration file.ptf

15
Nios II C-code exampleLaboratory 1
  • int timeloc 0x5957 / startvalue given in
    hexadecimal/BCD-code /
  • define TRUE 1
  • extern void puttime(int timeloc)
  • extern void tick(int timeloc)
  • extern void delay (int millisec)
  • extern int hexasc(int invalue)
  • int main ()
  • while TRUE
  • puttime (timeloc)
  • tick (timeloc)
  • delay (1000)
  • return 0

16
Nios II Assembly code exampleLaboratory 0, Home
Assignment 4-6
  • Laboratory 0, Home Assignment 4-6
  • .data Reserve space for time-variable
  • time .word 0x5957 give it initial value
    "5957"
  • .text Instructions follow
  • .global main Makes "main" globally known
  • main movia r4,time parameter for call to
    puttime
  • call puttime present current time
  • movia r4,time parameter for call to tick
  • call tick update current time
  • movi r4,1000 parameter 1000 to delay
  • call delay wait milliseconds, (how many?)
  • br main Branch to main
  • .end Marks the end of the program

17
Steps i program development
  • Edit program in C-code (or similar)
  • Compile C-code to Assembly-code
  • Edit code in assembly
  • Assemble assembly-code to object module
  • Link object modules -gt load module
  • Load load module to memory
  • Execute run program on CPU
  • Simulate program, run on simulator
  • Debug debug and test program

18
Separate compilation
Advantages ? Split work Fast compiling Disadvant
ages? Long commandstring
19
include
Advantages ? Split work Short commandstring Disadv
antages? Slow compiling
20
DebuggingProgram executed on CPU
Where in memory ? Linker chooses
Debugging
Wishes Start program at any address (write to
PC) Stop program Stepwise execution 1
instruction at a time (S Step) Execute one
subroutine (N Next) Read/Modify contents in
register and memory Breakpoints add /
remove Run to next brekpoint (C Continue)
21
Altera - Literature
  • Alt-Intro Introduction to the Altera Nios II
    Soft Processor
  • Alt-HW Nios II Processor Reference Handbook
  • Alt-SW Nios II Software Developers Handbook
  • Alt-IO Nios II Embedded Peripherals Handbook
  • Alt-DE2 DE2 Development and Education Board,
    User Manual

22
Laboratory exercise 0function hexasc
IN-parameter in r4
4 bits one hexadecimal number
?
7 bits ASCII-code of a hexadecimal character
OUT-parameter in r2
23
Laboratory exercise 0function hexasc
Bin --gt ASCII hex 0000 --gt 011 0000
0 0001 --gt 011 0001 1 0010 --gt 011 0010
2 0011 --gt 011 0011 3 0100 --gt 011 0100
4 0101 --gt 011 0101 5 0110 --gt 011 0110
6 0111 --gt 011 0111 7 1000 --gt 011 1000
8 1001 --gt 011 1001 9 1010 --gt 100 0001
A 1011 --gt 100 0010 B 1100 --gt 100 0011
C 1101 --gt 100 0100 D 1110 --gt 100 0101
E 1111 --gt 100 0110 F
Algorithm?
For all these you can do like this ...
For all these you can do like this ...
24
delay subroutine, flow chart
25
Nios II CPU
  • 32 general registers
  • Required/Recommended use (by compiler)
  • Lots of expected instructions MOV... ADD...
    AND... JMP/BR ... BCond CALL ... RET
  • Several Operand addressing, register/memoryImmedi
    ate, Absolute, Relative, Indexed, ...
  • Processor Reference Handbook Chap 3 and 8

26
Nios IIcode examples
  • mul10 multiply by 10
  • MULINTU unsigned multiply
  • getchar read from serial inport
  • putchar write to serial outport

27
MUL10Multiply by 10 Nios-II-kod
MUL10 MOV r2, r4 r2 inval SLLI r2,
r2, 3 r2 8inval ADD r2, r2, r4 r2
9inval ADD r2, r2, r4 r2
10inval RET SLLI Shift Left Logical
Immediate page
28
MULINTU r2 r4 r5 Nios-II-kod
contents of r4 and r5 is expected to be gt0
(unsigned) r4 r5 is expected to fit into 32
bits content of r8 is allowed to be
destroyed MULINTU MOV r2, r0 clear r2
BEQ r4, r0, OUT return if 0 BEQ r5, r0,
OUT return if 0 MOV r8, r5 use r8, not
r5 MORE ADD r2, r2, r4 add once
(more) SUBI r8, r8, 1 decrement BGT r8,
r0, MORE repeat as long as r8 gt 0 OUT RET
29
getchar from serial portNios-II-kod(blocking)
int retval getchar(void) .equ indata,
0x860 0x880.equ outdata, 0x864
0x884.equ status, 0x868 0x888
.equ ibfmask, 0x80 0x80 getchar MOVIA r8,
indata LDW r9, 8(r8) statusindata8
ANDI r9, r9, ibfmask BEQ r9, r0,
getchar LDW r2, 0(r8) RET
30
putchar from serial portNios-II-kod(blocking)
void putchar(parameter) .equ indata,
0x860 0x880.equ outdata, 0x864
0x884.equ status, 0x868 0x888
.equ obemask, 0x40 0x40 putchar MOVIA r8,
indata LDW r9, 8(r8) statusindata8
ANDI r9, r9, obemask BEQ r9, r0,
putchar STW r4, 4(r8) utdataindata4
RET
31
Lab 0 Program structureNis II code / C-code
C code
Nios II code
Nios II code
32
Lab 1 Program structureNis II code / C-code
C code
Nios II code
C code
33
More to add next year
  • More about Nios II CPU Alt-HW chap 3, 8
  • Registers, name and use
  • Instructions, name and use
  • Adressing modes, name and use
  • Calling conventionparameterpassing once
    moreinput r4, r5, r6, r7return r2, (r3)
Write a Comment
User Comments (0)
About PowerShow.com