Write once on silicon

20
WRITE ONCE ON SILICON AND PLAY IT FOR EVER : AN EMBEDDED JOURNEY Sandip Ray April 29, 2011

Transcript of Write once on silicon

Page 1: Write once on silicon

WRITE ONCE ON SILICON AND PLAY IT FOR EVER : AN EMBEDDED JOURNEY

Sandip Ray

April 29, 2011

Page 2: Write once on silicon

WHAT TO WRITE ?

Any thing that comes to your mind.

Any language you can choose.

Write a small C code of your favorite game.

Or your favorite algorithm that you have learned in

your computer science class.

2/7

/20

13

2

Page 3: Write once on silicon

HOW TO WRITE ?

Create a Flow Chart of what is inside your

algorithm.

Start

Is

Temp

> 90 C

Generate

Heat

End

2/7

/20

13

3

Page 4: Write once on silicon

IS YOUR CODE CORRECT ?

Review 2 times before a bug catches your eye.

Share the code with your peer to review it once

again.

Compile the code.

0 Warnings, 0 Errors !!!!

Too good, you have written an excellent code.

If errors are there, you have to go through your

code and try to fix it.

If warnings are there, you have to understand the

source of it and try to avoid it.

2/7

/20

13

4

Page 5: Write once on silicon

THINK OF OPTIMIZATION

Optimization in terms of :

CPU Clocks

Code Memory

Data Memory

Power etc.

2/7

/20

13

5

Page 6: Write once on silicon

OPTIMIZATION IN TERMS OF CPU CLOCKS

for (i=0;i<100;i++)

{

for(j=0;j<50;j++)

{

for(k=0;k<25;k++)

{

A[i][j][k]= B[i][j]*8 + C[i]*4;

}

}

}

2/7

/20

13

6

Page 7: Write once on silicon

OPTIMIZATION IN TERMS OF CPU CLOCKS

for (i=0;i<100;i++)

{

M= C[i]<<2;

for(j=0;j<50;j++)

{

N= B[i][j]<<3;

for(k=0;k<25;k++)

{

A[i][j][k]= M + N;

}

}

}

2/7

/20

13

7

Page 8: Write once on silicon

OPTIMIZATION IN TERMS OF CODE

*ptr++ = 10;

*ptr++ = 20;

*ptr++ = 30;

*ptr++ = 40;

for(i=0;i<4;i++)

{

*ptr++ = (10*i);

}

2/7

/20

13

8

Page 9: Write once on silicon

OPTIMIZATION IN TERMS OF DATA

for(i=0;i<4;i++)

{

B[i]=A[i]*3;

for(j=0;j<10;j++)

{

C[i] [j]= B[i]*5+2;

}

}

2/7

/20

13

9

Page 10: Write once on silicon

OPTIMIZATION IN TERMS OF DATA

for(i=0;i<4;i++)

{

for(j=0;j<10;j++)

{

C[i][j] = A[i]*15+2;

}

}

2/7

/20

13

10

Page 11: Write once on silicon

WHAT IS YOUR PLATFORM ?

X86

ARM

TI C55x

TI C64x

ADI Blackfin

2/7

/20

13

11

Page 12: Write once on silicon

WHAT ARE CODE GENERATION TOOLS ?

Compiler

Assembler

Archiver

Linker

Debugger

Simulator

Profiler

Hex Dump Utility

2/7

/20

13

12

Page 13: Write once on silicon

COMPILER

Compiles the code from high level language to

assembly language.

Example : C, C++, Fortran, Java

2/7

/20

13

13

Page 14: Write once on silicon

ASSEMBLER

Assembles the assembly code to binary opcodes

and operands.

MOV #40, A

SUB A, B, A

LD *A++, C

2/7

/20

13

14

Page 15: Write once on silicon

LINKER

Links the code as per the provided code and data

memory map.

Example : TI C64x Linker, gcc

2/7

/20

13

15

Page 16: Write once on silicon

DEBUGGER

To find the bug or fault in the code.

Run

Single Step

Run Till This Point

Step Over

Step Through

Breakpoint

Log

Example : TI Code Composer Studio IDE, gdb.

2/7

/20

13

16

Page 17: Write once on silicon

SIMULATOR

Functional Simulator

Instruction Set Simulator

Cycle Accurate Simulator

Example : TI Code Composer Studio IDE

2/7

/20

13

17

Page 18: Write once on silicon

IS YOUR CODE RUNNING FINE ON SIMULATOR

?

Debug till the point your expected output doesn’t

appear on the screen.

Ahhhhh…… Finally it is coming !!!

2/7

/20

13

18

Page 19: Write once on silicon

WANT TO TRY IT OUT ON SILICON ?

Yes !!! You can run the code on silicon(provided it is not a mission critical one)

Connect the hardware board with serial port, parallel port or PCI through JTAG.

Load the object file on processor.

Press Run and see if expected output are coming on the screen.

If yes, you are done !!!

And don’t forget to check the performance of your code by using a profiler.

2/7

/20

13

19

Page 20: Write once on silicon

THANK YOU

2/7

/20

13

20