cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Teacher
Teacher
5,416 Views
Registered: ‎07-09-2009

Why do people recomend use of signals over variables ?

Following on from another discussion on the forum about the difference between signals and variables, then the question came up,

why do people,  prefer to use signals not variables ?

 

My stake in the ground,

 

variables are great, but 

 

    Our code is aiming to generate hardware, i.e. gates and wires, in a flat architecture.

     Variables can easily lead to code written to look more like C or some of the OO languages.

        Unfortunately at this time and place the synthesisers we have don't translate OO code to well into the silicon we have.

 

 So my starting advise to people is to stay with signal, and only use variables if it's really needed to make more readable code.

and

  always to keep an eye on the synth to see what it's generating out of your code and it's the hardware you expected.

 

 

<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>
0 Kudos
4 Replies
Highlighted
Historian
Historian
5,413 Views
Registered: ‎02-25-2008

Re: Why do people recomend use of signals over variables ?

I think there's a simpler explanation.

 

Newbies have a hard enough time understanding delta delays and when signals actually update.  So adding a blocking assignment to the mix makes things a lot more complicated.

 

Having said that, I use variables quite often.

 

-a

----------------------------Yes, I do this for a living.
0 Kudos
Highlighted
Explorer
Explorer
5,406 Views
Registered: ‎07-27-2009

Re: Why do people recomend use of signals over variables ?


 

    Our code is aiming to generate hardware, i.e. gates and wires, in a flat architecture.

     Variables can easily lead to code written to look more like C or some of the OO languages.

        Unfortunately at this time and place the synthesisers we have don't translate OO code to well into the silicon we have.


 


*lol* Ever tried the Xilinx webpack lately, or Synopsys DC version 1998? You'd be surprised what these compilers can do!

 

These synthesis things are just plain old optimizing compilers in the end; they map some front-end language like VHDL or Verilog to some back-end (gates). The fact that you can write code that looks more like an ordinary programming language should be interpreted as a strong point rather than a weakness.

 

As some general background on the state-of-the-art you could have a look at www.deepchip.com and see that the world is moving on and that C/OO can be transformed into gates. People are even doing chips with that. Ain't that something?

0 Kudos
Highlighted
Anonymous
Not applicable
5,259 Views

Re: Why do people recomend use of signals over variables ?

I did use signals when i got started with vhdl. But now its hard to write vhdl code without variables.

signals are like I/O ports, they can only change on clock transition(ignoring asyncronous inputs).

 

Variables are internal to a  process. But I can't think of a hardware equivalent. Maybe a counter?

Tags (1)
0 Kudos
Highlighted
Historian
Historian
5,245 Views
Registered: ‎02-25-2008

Re: Why do people recomend use of signals over variables ?


hithesh wrote:

I did use signals when i got started with vhdl. But now its hard to write vhdl code without variables.

signals are like I/O ports, they can only change on clock transition(ignoring asyncronous inputs).

 

Variables are internal to a  process. But I can't think of a hardware equivalent. Maybe a counter?


You REALLLLLLLY need to read a good VHDL book to understand the differences between signals and variables!

 

it is NOT that variables are "internal to a process" (which they are, unless you use shared variables, which opens up a whole new world of hurt). And signals do NOT "only change on clock transition." And they are NOT "like I/O ports."

 

It all has to do with when signals update vs when variables update.  Variable assignments are blocking and update immediately. Signal assignments are non-blocking, and the signal is updated only after everything on the right-hand-side of the assignment updates.

 

There are significant semantic details here, and please don't spread misinformation.

 

-a

----------------------------Yes, I do this for a living.
0 Kudos