Thursday, June 09, 2005

Embedded Systems part 3

Given the current state of art of VHDL and FPGAs, I think that circuits and programs will walk around the networks. FPGAs are boards that can be programmed to emulate every digital circuit you can figure out. VHDL is how they are programmed.

If you can send a program over the net, by copying an instance of it in a given location, you can ask it to carry out a VHDL program, reach a particular target, access a FPGA board generate the circuit and next, ask the source to load theVHDL code.

Physical medium is most likely becoming optical or wireless, but to guys like me, it won´t matter. We will leave the information ready in bytes or whatever they will call it, so it reaches the physical medium and then gets broadcasted.

Embedded Systems part 2

Hardware and firmware are encapsulated to the programmer. OK, you could think that this is not TRUE programming, but remember digital circuits: you are not seeing all those C-MOS transistors that make all those gates that make all those latches and flip-flops.

The world is full of encapsulation.

Firmware should be written in C of course. Assembly might be used to, but in small bits. Not because I don´t like Assembly, because it is not readable, it is not easy to handle and maintain. Truth to be told, I mostly read the comments when I need to check out Assembly code rather than the code it self.

Suppose you write a program that reads temperature, pressure, and needs to generate an output for a electronic injection systems. In this case, using C is much better because all the code rely on low level.

Fun enough?

Embedded Systems part 1

Why using C? Is there anyone still using C? Surprisingly or not, most embeded programming done these days is written in C rather than C++ or Java. Well, I program embedded systems and I use C!!! heheheheh ;-)

Java has a trouble: you need a device that supports J2ME machines.
Not a big deal, as it is not impossible to create these machines as you may have seen in cell phones or PDAs.

Also, schools are still teaching C as an introduction to programming. If you want to write numerical methods and don´t want to bother using a pre-historical language like Fortran use C instead.

Anyways, the ANSI C standard is mandatory for C. Basically, you are required to use prototypes to every function, your main function explicitly returns a int, your functions have parameters inside it´s call ( for ex, f( int * a)).

Why not C++ ? It can be very complex if you want to make it complex. Try to read code with templates,operator overloading, it´s a pain. Not that these features are useless, on contrary, they are mandatory for good OOP design, but we end up with code that´s not easily read.

A note: Java 1.5 supports generics which are the Sun way for templates, but you these are not hard to read as C++ ones. If you are on embeded, avoid generics. Most of time you will deal with bytes, which are basically unsigned char types, and mostly certainly people will use your code.

Wednesday, June 01, 2005



I was wondering about Java and polymorphism. Actually, I am waiting for that the QA team to test my software so I can correct bugs and I was freaked out because I thought I could forget
OOP and Java so I thought I should try a little of it. :-)

I basically think of an abstract class A and derive B and C so I can have a 4th class that may use
any of the other 3 and I only write one implementation...

public abstract class A {

A( int a, int b ){};
public abstract void f1();

public class B extends A {

protected myC;

B( int a, int b, int c ){
super( a , b );
myC = c;

public void f2(){

public void f2b(){

public class C extends A {

protected String s;

C( int a, int b, String s ){
super( a , b );
this.s = s;

public void f2(){

public class D {

A aptr;

D( A a ){

// points to class A
// but knows which derived class it refers to
// because of the polymorphism
aptr = a;


void DoSomething(){


public class E{
public static void main( String[] args ){
B b = new b( 1 , 2 , 3 );
C c = new c( 1 , 2 , "asdasdd" );
D d1 = new D( b );
D d2 = new D( c );