Thursday, March 18, 2004

Yet more proof engineers shouldn't write compilers:

The Handel-C hardware design language compiler claims to e able to infer a variable or wire's width from the context. That is, if you create a variable, then create anotehr variable and assign the value of the first variable to it, you don't need to specify the bit width of the second variable, it simply accomodates it for whatever the width of the first variable is. This is generally good. However, you can't define an enum type, comprising a set of constants to act as opcodes in my case, and use those along with a switch statement, because for some reason switch statements only expect a certain width of variable as input. This isn't caught by the Handel-C precompiler itslef, but only causes problems when the C++ compiler chokes and dies on the C code generated for the simulator.

This leads us to the general difference between how engineers and computer scientists write software. For engineer, a program is done when it works well for the usual, expected cases. God help you if you try and do something that is syntactically correct but outside the realm of his imagination. A computer scientist, on the other hand, is not satisfied until his program works for all possible cases, and provably so at that.

I was able to fix my little problem by padding all my switch case contants with 0 bits on the left side. My point is that I shouldn't have to do this.

Hardware design is so much fun...

By al - 10:29 p.m. |

    follow me on Twitter

    al's del.icio.us Links

    • www.flickr.com
      This is a Flickr badge showing public photos from dragonofsea. Make you own badge here.
    •  
    • (al)



    • Powered by Blogger