VHDL coding tips and tricks: Difference between C and VHDL
Contact me for VHDL or Verilog projects and assignments

Saturday, February 12, 2011

Difference between C and VHDL

It is normally said that once you learn one programming language it is pretty easy to learn the other programming languages. This is because the concepts are almost same in most of the programming languages with some only syntax differences.

But if you ask a hardware engineer, he may have a totally different opinion. If you dont stop thinking from a C programmer's perspective, then life as VHDL programmer will drive you nuts. Because both the languages have many differences between them. Both are different from the basic level itself, though they seem to have many similarities.

So let me compile some of the basic differences between C programming and VHDL programming.
  1. C is a middle level language. I mean its a mix of a high level language and an assembly language.
    VHDL is a hardware description language(HDL) . It is used for implementing the hardware circuit.
  2. C can only handle sequential instructions.
    VHDL allows both sequential and concurrent executions.  
  3. A C program can be successfully written with pure logical or algorithmic thinking.
    But a successful VHDL programmer needs thorough working knowledge of the hardware circuits. He should be able to predict how a given code will be implemented in hardware.
  4. Normally we don't care about resource usage in C. This is because a C program is usually ran on a computer which uses a powerful processor with high speed. We also don't care about the memory usage.
    But when it comes to VHDL a slightly complicated code can make you bent on your  knees. The memory and other logic elements are limited in a FPGA(where you normally put the VHDL code in). This is why it is very difficult to implement image processing algorithms in VHDL than in C.
These are some of the main points. If you have anything to add, feel free to add them in the comment section. 

7 comments:

  1. one more thing :: why things are faster in HDL?

    ReplyDelete
  2. @hank: In C we are using the code to run on a microprocessor which is used for general purposes.
    But using HDL, we specify what we want. That means personal optimization is possible using HDL.This is the reason why ASIC chips are developed if the chip has a large demand. Because efficiency will be decreased when systems are implemented on general purpose processors.

    ReplyDelete
    Replies
    1. One more reason is that In c language there is sequential execution of instructions while VHDL can execute sequential as well as Concurrent instructions..

      Delete
  3. To top up vipin's comment, C code gets compiled to assembly instructions that runs on a microprocessor. The microprocessor itself is usually designed in HDL. So if you're running something on a uP, it has to be some software (the assembly code) running on top of a piece of hardware (designed in HDL). So of course if you design things directly using HDL, your design becomes the hardware itself and doesn't have to "run" on anything. That makes it faster and more efficient.

    ReplyDelete
  4. @Vipin,
    For HDL its a "design" language. It "describes" your circuit. This is the main stumbling block for C programmers.

    ReplyDelete
  5. Difference between c and c++

    The main difference between C and C++ is, C is the procedure oriented language and C++ is the object oriented language.

    ReplyDelete
  6. C programming language is a middle level programming language, it provide some low level data manipulation mechanisms like assembly language. C is not specifically designed to simulated circuit diagrams.

    ReplyDelete