Thursday, April 30, 2009

Open source tool for code documentation : Doxygen and Graphviz

The platform used was windows and i dont think their will be much differece with linux.
Get the tools installers and install both the tools.
Method of installation: just click click type.
Usage : Just the normal brain. See the options and experiment with them.

Steps:
1. Open doxygen
2. specify the working directory,project name, source code directory
3. Enable recursive scan, give destination directory(this is where you fill find html folder after running of doxygen)
4. Rest all options see them and enable as you want.
5. In diagrams enable dot tool and enable all the options
6. Go on run tab and click run.
you will find a file in html folder called “index.html”
click on it and this is your documentaion .

What you want?
Ultimately from documetation you may want(wishlist)
1. how the module is organised
2. what are the different files
3. their dependency graphs, call graphs,
4. various function and their usage
5. globals used(macros, variables, structure, enums ,typedefs)
6. mainpage(what the documetation is about)
7. description of individual files

Hey if you intend to use these tools than first of all change your coding style in some form.
First of all change your commenting style
/*!
anything for multiple comments lines
*/
and
///for single line comments.

These are the list of efforts what you have to do for fulfilling your wishlists:
(it is to do list point by point wise according to wishlist)
1. just automatic, u have to do nothing .

2. just automatic, u have to do nothing.

3. Enable the option “use dot tool” in wizard->diagram.
Their check all the options.

4.Whenever you write any function
Than write in this form:
/*!
This is anyfunction doing anyting
\param integer named arg
\return integer value
*/
int anyfunction(int arg)

5.If you want to document any global(macros, functiondef, variables) than you can document
with /// comment. But note that it should come first and than what you want to document.
Incorrect:
int global; ///u know it is global
typedef unsigned int ui32; ///defines 32 bit

Correct:
///u know it is global
int global;
///defines 32 bit
typedef unsigned int ui32;

6.In mainfile(where main() exists) it is better to write
the following. This is called mainpage which is like is like brief of what the documentation is about.
/*!
\mainpage This is mainpage
This is the main file of file that i am trying to manipulata.
*/
and yes anythin with \ or @ in doxy comments are called commands.

7. At start of your file write
/*! \file filename
* \brief sth about this file
*/

This is what i think for now. Maybe i will get back for more if i get something more useful.
In future i will get with blog which gives the practical example for Doxygen together with fix point code examples.

There is another interested reading for interested ones:
http://justcheckingonall.wordpress.com/2…

Thursday, April 9, 2009

compiled list of shlokas

I came across this on yahoo answers. Unfortunately we forget where we came from and who we are. The list is compiled list of shlokas.
It is worth read.
Source: http://answers.yahoo.com/question/index?qid=20060901103951AAQzwgz


OPENING PRAYERS

1.Please chant 3 times - (Om)

2.(Prayer to Ganesha)
Shuklambara Dharam Vishnum
Shashivarnam Chatur Bhujam
Prasanna Vadanam Dhyayet
Sarva Vignopa Santaye
Meaning: Lord Vigneshwara, who wears a white garment, who is all pervading, who has a bright complexion (like a full moon), who has four hands (representing all power), who has an ever-smiling face, upon that deity I meditate, for the removal of all obstacles.

3.(Prayer to the Lord)
Om. Asato Maa Sadgamaya.
Tamaso Maa Jyotirgamaya.
Mrityormaa’mritam Gamaya.
Meaning: Oh lord, lead me from untruth to truth, from darkness to light, from death to immortality.

4.(Prayer to the Teacher)
Gurur Brahmaa Gurur Vishnu, Gurur Devo Maheshvarah;
Gurur Sakshaat Parabrahma, Tasmai Shri Guruve Namah.
Meaning: The Guru is Brahma (the creator within Hindu Trinity); the Guru is Vishnu (the preserver); the Guru is Shiva (the final dissolver of the universe); the Guru alone is the Supreme Brahman, The Absolute. To Him, the great Guru, I offer my salutation.

5.(Peace Prayer)
Om Sahana Vavatu Sahana Bhunattu
Saha Viryam Karawavahai
Tejasvinavaditamastu
Ma Vidvishavahai
Om Shanti Shanti Shanti Om

Meaning: Together may we be protected
Together may we be nourished
Together may we work with great energy
May our journey together be brilliant and effective
May there be no bad feelings between us
Peace, peace, peace

SLOKAS
6GANESHA
Vakratunda Mahakaaya
Suryakoti Samaprabha
Nirvighnam Kuru Mey Deva
Sarva Kaaryeshu Sarvada
Meaning:The Lord with the curved trunk and a mighty body, who has the luster of a million suns, I pray to thee Oh Lord, to remove the obstacles from all the actions I intend to perform.
7. (Morning Prayers)

Karagre Vasate Lakshmi Karmadhye Saraswati
Karmule Tu Govindaha Prabhaate Karadarshanam

Goddess Lakshmi is the symbol of wealth. Goddess Saraswati represents knowledge. Govinda is the God of Power. Hand is the symbol of human effort. So by placing the three divine powers on the tips, in the middle and at the base of the hand, this shloka suggests that all the divinity lies in human effort. Thus this shloka supports the need of human effort and self confidence.

8 . Bath time:

Gange cha Yamune chaiva Godavari Saraswati,
Narmade Sindhu Kaveri jalesmin sannidhim kuru

Meaning: In this water, I invoke the presence of holy waters from the rivers Ganga, Yamuna, Godavari, Saraswati, Narmada, Sindhu and Kaveri


9. WHILE LIGHTING LAMP(MORNING)

ShubhaM karoti kalyaaNaM
AaarogyaM dhanasaMpadaa .
Shatrubudhdivinaashaaya
Diipajyoti namo.astute ..
I salute the One who is the lamplight that brings auspiciousness, prosperity, good health, abundance of wealth, and the destruction of the intellect's enemy

10 WHILE LIGHTING LAMP(EVENING)
Deepajyothi parabrahma
Deepa sarva tamopahaha
Deepena saadhyate saram
Sandhyaa deepo namostute

11. Study time:
Sarasvatii namastubhyam
Varade kaamaruupini
Vidyaarambham Karishhyaami
Siddhirbhavatu me sadaa

Meaning: Oh Bhagawati Saraswathi, I bow to you, the fulfiller of my wishes. I begin my studies seeking your blessings so that I shall always be successful.

12. FOOD(MEAL TIME)


Brahmaarpanam Brahma Havir
Brahmaagnau Brahmanaa Hutam
Brahmaiva Tena Gantavyam
Brahma Karma Samaadhinaha In the term Brahmaarpanam the word Arpana refers to the long spoon. So Brahma is the spoon. He is also the oblation or Havis. He is the fire, the person who sacrifices, the sacrifice itself as well as the goal to be reached. That person who sees the Lord while doing the act is Brahma- karmasamadhina. This is possible by being happy in any action and getting only happiness in action. Sadhana is to enjoy every action, small or big--- Swami Chinmayananda


13. Night Prayer (BED TIME)

ramaskandham hanumantam |
vainateyam vrikodaram ||
shayaneya smarennityam |
dusvapnam tasya nashyati ||


Meditating upon Hanumanta, Bhima and Garuda before going to bed ensures a sleep without disturbing dreams.



14 ( SLOKA ON SHIVA)

Tathpurushaaya Vidhmahe Mahadevaaya Dheemahi
Thanno Rudra(h) Prachodayaath

15 ( SLOKA ON SHIVA)
Om Trayambakam Yajaamahe
Suganghim Pushtivardhanam
Urvaarukmiva Bandhanaan
Mrityor Mokshiya Mamritaat
[The meaning of the Mantra is as follows:]
I worship thee, O sweet Lord of transcendental vision (the three -eyed one or Lord Siva). O giver of prosperity to all, may I be free from the bonds of death, even as a melon (or cucumber) is severed from its bondage or attachment to the creeper.
16 SLOKA ON RAMA

Sri Rama Rama Rameti
Rame Raame Manorame
Sahasra Nama Tat Tulyam
Rama Nama Varanane
Lord Shiva told this shloka to Parvati I meditate upon Sri Ram as Sri Rama Rama
Rama, the thrice recital of Rama’s name is equal to Recitation of the thousand
names of Lord Vishnu (Vishnu Sahasranama)










CLOSING PRAYERS
17

Sarveshaam Svastir Bhavatu
Sarveshaam Shaantir Bhavatu
Sarveshaam Purnam Bhavatu
Sarveshaam Mangalam Bhavatu

May good befall all,
May there be peace for all,
May all be fit for perfection, and
May all experience that which is auspicious.





18


Sarve Bhavantu Sukhinah
Sarve Santu Niramayaah
Sarve Bhardrani Pashyantu
Maa Kadhchit Duhkhabhahg Bhavet
May all be happy. May all be healthy.
May all experience what is good and
let no one suffer


19

Brahmaarpanam Brahma Havir
Brahmaagnau Brahmanaa Hutam
Brahmaiva Tena Gantavyam
Brahma Karma Samaadhinaha In the term Brahmaarpanam the word Arpana refers to the long spoon. So Brahma is the spoon. He is also the oblation or Havis. He is the fire, the person who sacrifices, the sacrifice itself as well as the goal to be reached. That person who sees the Lord while doing the act is Brahma- karmasamadhina. This is possible by being happy in any action and getting only happiness in action. Sadhana is to enjoy every action, small or big--- Swami Chinmayananda

Tuesday, April 7, 2009

How the numbers are interprated in compiler with type conversion examples.

How the numbers are interprated in compiler with type conversion examples.

This post gives you some concepts about how the number are repersented inside processor
and with help of type conversion example you will get some practical insights.
The things in this post is observed by my own observation .

Type conversion: What happen inside?

I was dealing with fix and floating point arithmetic and wondered what happen inside of register when
the compiler execute this statement:
float fv = 5.0;
int a = (int)fv;

If you give this than their is in built routine in compiler which rearrange the bitstructure so that
you can get the appropriate representation.
At present the 5 is stored as 0101 in processors registers.
Now after this conversion the representation or arrangement of bits is changed by compiler.
Now the 5 is arranged as the single precision IEEE754 format of 1+8+23.

Here in this cases:-
0101 and all leading bits zero -->0 10000001 01 and trailing bits all zero
That is one bit for sign bit, 8 bits for exponent and 23 bits for mantissa.

This was case for normal floats but if you are using double than the representation is converted in 64 bits instead
of 32 bits.


lets see another example :
typedef unsigned long long ui64;
typedef unsigned int ui32;
ui32 x; ui64 y;
y=0x 20000000 10000000;
x = (ui32)y;

so now x will holds ox10000000 and sadly it truncates msb.

another type of example may be the sign extensions.
see here i demonstrates heavy use of typedefs but believe me they are really useful
for porting purposes. that is when you want to use your existing code for another
processor. just build this into your habit.
//some more typedefs
typedef signed int si32;
typedef unsigned char uc8;
typedef signed char sc8;

case 1:
uc8 a;
ui32 b = (ui32)a;
case 2:
sc8 c;
si32 d = (si32)c;

The first case will be same for all compilers. That is it will fill the msbs with zeroes.
But the second one i though fill with signs or sign extensions but it is highly suggestable
to find it in your compiler what is tha nature. In fact whereever such sign conversion occur
it is better to find out the nature by executing on your compiler and for most
important for that architecture.





Ever wondered what may be the maximum and minimum allowed numbers
represented by single precision float variable ?
Is it -3.4*pow(10,38) to 3.4*pow(10,38) as we read in books and if it is why it is?
Can you represnt any range of numbers or say any number with floats?
Just try to find out and if you cant find out wait for the next post for its answer.......

Monday, April 6, 2009

Something about Fix point logic

Something about Fix point logic

I am writing this topic because this topic is some cofused one but easy to understand.
ok so without wasting time i will directly jump to the topic.

If we have given the job of writing a real value(real values are values having points in them, u must have known this)
than its is very easy, huh!
write two point five. you write 2.5

Fix point and floating point are two types of representation for real values.
Floating point gives you higher range .
When a number is stored in processor it is stored in processor register.
The register length is of some bits and in case of ARM it is 32 bits.
So the number we store is get store in these 32 bits.
like if u write 17d(d for decimal) it will store as 10001 with leading bits as all zeroes.

Forget all representation you know . You are given job of writing 17.5.
How you will do it?
Now you will say i will fix 4 bits from these 32 bits for fractional bits and rest all for integer portions.
than you can write it as 10001.1000 with all leading bits zero
This is what you say fix point as you fix the fractional bits as 4 places.
The problem is precision here. The precision is pow(2,-4)
So it is you who decide how much number to fix for fractional part and how much for integer part.
That is programmer .
If my number table(or say range of numbers i am dealing with) is like .625 to 457878.5 than i am done with this allotment.
As both range ( pow(2,28) for unsigned or pow(2,27) for signed) and prcision are satisfied , i am happy man.
You can say it is Q28.4 or in short Q4. The usual standard saying in industry is Q27.4 so adopt it.

Now their is another representation system also . It is floating point system.
As the name seems it is the fractional thing which you can float.
like 250*pow(10,1) or 2.50*pow(10,3) .
The system use to represent is IEEE754 which in short can be said as 1+8+23 for single precision numbers.
So a 32 bit number can be represented by this notation.
You can read the old slides or google it for how to represent any number in this format.

Now the point is why on earth the fix point is preferred.
It is because if the core of the processor is fix point core than the compiler has to emulate the float variable in
your code to fix point.(It write fix point version for that section).
Floating point core needs complex logic and thus use more silicon and thus more costly.
Nowadays core for floats are also available but its selection depends on lot or factors.
Like difference in notation of ARM11F or ARM11 is that the former have floating point accelarator.
So you must use fix point notation if your core is ARM11 only.

(Note:- for people who will try to implement this theory ,note that you will see benefits in speed only if
you change the logic of code instead of calling fix point library function all the time for calculation
as the fucntion calling will make it ineffiecient. You can do practical with using profilers.)

Apologies for writing it in without figures and not giving practical examples for it but this blog
might solve some confusion .
I will clarify more with example in next blog if time permits.