Code Snippets

Several VHDL code examples are listed below. Each example includes the source code and simulation waveform. Also, at the footer of each example you can find a link to download both the model source and testbench files.


Note: The categories marked with an (includes exercises) have proposed exercises for you to practice. Check them out!


Sources List

Binary to seven-segment decoder

Debouncer (for push-buttons)

Generic Demultiplexer / Decoder

Generic down-counter

Generic register with load

Generic up-down counter (includes exercises)

Parameterized PWM controller (includes exercises)

Parallel to serial converter

Serial to parallel converter (includes exercises)

Modulo Counter


IMPORTANT NOTE:design

All the examples in this site are according Altera recommended coding style. Altera recommends using asynchronous reset at the Flip Flop level.

Xilinx recommends using synchronous reset at the FF level.

Advertisements

4 thoughts on “Code Snippets

  1. With the possible exception of the PWM controller, I wouldn’t write any of these as entities. I would write them as procedures or maybe functions. But for practice I suppose it doesn’t matter which way they are coded.

    Like

    1. You possibly have a point in the case of just two of the examples: “Binary to seven-segment decoder” and “Generic Demultiplexer/Decoder.” However I think these are fine just as they are.

      But none of the other seven blocks are better written as procedures or functions. Procedures and functions can’t, in general, retain state information internally between calls.

      Clocked sequential circuitry meant for synthesis is best implemented in design entities, as the author shows in these clear and useful examples.

      Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s