R – Getting started with HDLs from regular programming

fpgahardwareverilogvhdl

I've always kinda wanted to make my own microprocessor.. I've read How can I make my own microcontroller? .

I tried multiple times to learn some Verilog and VHDL. But for the life of me I just can not get my head around the language styles. I come from a C/C++/C# background and have dabbed some(with success) with doing functionalish programming with Ruby.

Can anyone suggest a book or online resource for teaching an HDL language from scratch(so that I can unlearn my procedural way of thinking)

Also, I am having trouble getting my head around exactly how to simulate an HDL program. There is nothing like printing or stuff in hardware, so what is the best way of testing programs without an FPGA(I'm going to order one of those sometime though!). How exactly does simulating it work?

Basically I'm just needing someone to help me get my head around HDLs and their simulation.

Best Answer

Remember, HDLs were intended to model hardware. With hardware everything happens at once. By hardware, I mean a collection of logic gates connected to inputs and to the outputs of other logic gates in some fashion. This is essentially what an FPGA or an ASIC is (in an FPGA those connections are programmable). Wiggle an input and the effects ripple through the chain of logic gates - think of every logic gate as a little processor that's constantly evaluating it's inputs.

So in an HDL the first thing you need to consider is that all assignments are happening at the same time. The only place things happen in the "normal" sense (one statement following another as in a regular programming language) is inside of a process block (in VHDL, or an always block in Verilog). But then you have to realize that all of the process blocks (or always blocks in Verilog) are also executing concurrently.

HDLs are just trying to model the concurrency of hardware.

As far as books that try to teach HDLs to software developers... I don't think there are any. Most are aimed at Hardware Engineers.

You mentioned that you've done some Ruby programming. If you want to play with an HDL written in Ruby you can try out RHDL: http://rhdl.rubyforge.org/ The basic HDL concepts are there and it looks a lot like VHDL, but it's Ruby so you can experiment a bit more with the innards. You can write models and then simulate them. There are some examples included.

Related Topic