Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VHDL entity and architecture design

Tags:

vhdl

With Ada I can split my modular units into specification and body with .ads and .adb files.

Is it possible to separate VHDL entity and architecture? If so, is there a naming convention or recommended style for doing this? And can the entities be placed in a custom library/package?

like image 654
Dr. Watson Avatar asked Dec 21 '22 13:12

Dr. Watson


1 Answers

Libraries

Everything gets compiled into a library. By default this is called "work", but you can override this. I rarely have to use that though - it's occasionally useful with external IP if there are namespace clashes. As Chiggs commented, using libraries to create namespaces is a good practice. Most synthesizers can deal with multiple libraries now, although it wasn't always the case. All the simulators can (as far as I know). There's also a bit more hassle involved in setting them up (you have to tell the compiler where they all are).


maybe an example - say you have an i2c controller and an spi controller. You could call both blocks controller and compile them into their own libraries called i2c and spi and then instantiate them like this:

i2c_instance:entity i2c.controller...etc
spi_instance:entity spi.controller...etc

or you could call them i2c_controller and spi_controller and do:

i2c_instance:entity work.i2c_controller...etc
spi_instance:entity work.spi_controller...etc

And libraries are not "just the same" as hard disk folders. They are managed by the VHDL compiler, so you create and map them using whatever syntax the tool uses.

For example with Modelsim, vlib creates a library at a particular place in the filesystem (so it does look like a folder at this point) and vmap tells the compiler how to map a use some_lib; clause to a particular bit of the filesystem.

Entities, architectures, packages

You can separate your entity and architecture (or even more than one architecture per entity) into multiple files, or keep them in one file. Keeping the architecture in a separate file means that when you recompile it, you don't recompile the entity, which means you don't have to recompile everything that instantiates it.

Similarly with packages and package bodys - bodies in a separate file means you can just recompile that part without recompiling everything else. Note that packages are not for putting entities in.

(Aside - Modelsim has a -just switch that allows you to keep everything in one file and just compile selected bits of the files, for example, just the architecture and/or body part(s))

Summary

  • Compile re-useable cores into their own library to protect their namespace
  • Compile everything else into the work library
  • Put useful constants, functions, procedures, type definitions into one or more packages
  • Putting entities and architectures into one or more files is a matter of taste and development style more than anything else
  • Putting packages and package bodies into one or more files is a matter of taste and development style more than anything else
like image 137
Martin Thompson Avatar answered Jan 22 '23 17:01

Martin Thompson