What I know is Variable has no hardware representation. So does it comes under the category of Non-synthesizable codes in VHDL?

  • \$\begingroup\$ Yes it has a hardware representation, though that depends how you use it, and yes it is synthesisable. \$\endgroup\$ – Brian Drummond Dec 1 '15 at 10:21

How is a VHDL variable synthesized by synthesis tools has some useful information though it's not exactly a duplicate of your question IMO.

Just because something doesn't have a direct hardware representation doesn't mean it's not synthesizable.

When writing VHDL (and Verilog) for synthesis you typically write program code that defines what happens on each clock cycle. You can also write code that takes input signals and produces outputs from them as soon as any input changes without involving a clock.

The synthesis tool turns that block of code into a combination of logic operations (gates, multiplexers, adders, multipliers, etc which will later be mapped onto target specific resources) and registers. Logically that block of code can be though of as completing "instantly".

How does it do that? Well first off any loops are fully unrolled (you will get errors if you have loops with a number of iterations that can't be statically determined). Some variables (i.e. loop counters) are likely to disappear at this point.

Then the code is turned into a data flow form. The variables at this point are essentially labels telling the compiler what output feeds into what input. Each variable will become one or more signals representing it's value at different points in the code.

"if" statements and similar become multiplexers selecting which version of a signal should feed into later logic and/or registers.

If there is a path through the code where a given variable is read before being set and/or a path where the variable is not set at all then the final value of a variable from one pass through the code must be fed to the input of the next.

How exactly that happens depends on when the code is run. If the code runs on a clock edge then a clocked register will be created to feed the final value from one iteration to the initial value for the next. This is fine, the tools can handle it just like any other register.

If the code is not clock triggered then the output value will be fed directly back to the input creating what is essentially a "transparent latch". This is usually a bad thing! Transparent latches are very sensitive to input glitches and are difficult for timing analysers to handle. While most synthsis tools will synthesize this the results may well not match with simulation results and may be unredictable.

  • \$\begingroup\$ I have doubt on what u said last. How we can implement a design in which variable is assigned on one clock and read on next. \$\endgroup\$ – tollin jose Dec 1 '15 at 11:52
  • \$\begingroup\$ Does my edit answer your question? \$\endgroup\$ – Peter Green Dec 1 '15 at 14:48
  • \$\begingroup\$ @PeterGreen I think that you decribe in the last paragraph is commonly called "Latch" (unclocked D-Flip-Flop) rather than "Register". \$\endgroup\$ – Fritz Dec 1 '15 at 14:52
  • \$\begingroup\$ I was assuming that the code was running in a clocked context. Maybe I should make things clearer. \$\endgroup\$ – Peter Green Dec 1 '15 at 14:55
  • \$\begingroup\$ Are people happy with the current version or is there further stuff you think needs clarifying? \$\endgroup\$ – Peter Green Dec 1 '15 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.