Home    Bloggers    Messages    Webinars    Resources   
Tw  |  Fb  |  In  |  Rss
Duane Benson

Discovering FPGAs: De-Bouncing Around

Duane Benson
Page 1 / 2 Next >
Page 1 / 6   >   >>
geekyasa
geekyasa
1/30/2013 8:10:03 PM
User Rank
Beginner
Re: Optimization
Sure will do. Thank you Duane

50%
50%
jandecaluwe
jandecaluwe
1/29/2013 2:29:36 PM
User Rank
Blogger
Re: My own take on a debounce circuit
@Garcia "I understand (correct me if necessary, please!) that MyHDl code can be directly executed (simulated?) in any Python shell, without the need of using "toVerilog", "toVHDL" or similar functionalities."

Yes - it has a simulator (class Simulation) that you use to simulate MyHDL descriptions, much like you would simulate Verilog or VHDL. As Python/MyHDL are "dynamic" languages, the run-time / simulation is very important to develop/debug your design - so you should really use this before attempting things like conversion. The conversion has taken a lot of work - but it is only there so that is straightforward to get a MyHDL design into a traditional design flow.

50%
50%
jandecaluwe
jandecaluwe
1/29/2013 2:20:37 PM
User Rank
Blogger
Re: My own take on a debounce circuit
@Karl "in blocking assignments, the last one wins"

Sorry to be picky, but that is not quite right. It is in nonblocking assignments that "the last one wins" when they are executed sequentially. What this means is that the values assigned in intermediate assignments will never ever be seen - they are simply unaccessible regardless of where you refer to the variable.

With blocking assignments, "every assignment wins" as with traditional variables: the assigned value is immediately available and accessible by referring to the variable.

50%
50%
jandecaluwe
jandecaluwe
1/29/2013 2:11:42 PM
User Rank
Blogger
Re: My own take on a debounce circuit
@Tobias "for clocked always blocks, some guys also recommend to use

lhs <= #1 rhs;

to avoid race conditions in Verilog."

For RTL level coding, this is overkill and dubious style.

Background: a long time ago (20 years), Verilog did not have nonblocking assignments (<=), but only blocking assignments (=). In that case, one way to avoid nondetermism is to add delay specs (#1) like above. (#0 would work also). This was rightly considered an ugly hack. For that reason, nonblocking assignments were introduced, as a clean way to guarantee nondeterminism in zero-delay RTL modeling.

50%
50%
jandecaluwe
jandecaluwe
1/29/2013 2:05:16 PM
User Rank
Blogger
Re: My own take on a debounce circuit
@Garcia "So HDL may be used in both hardware description and sequential general purpose programming... is this correct?"

Mm, theoretically yes, but that's not how I think about it - for true general purpose programming nothing beats a true general purpose language. Rather, it is a mistake to think that just because "hardware is concurrent", HDLs should offer concurrent semantics only. A sequential description can be a much more effective and straightforward way to describe a hardware function than a set of concurrent statements, that's all.

"I mean... can I use MyHDL for general purpose programming?"

Again, it's the other way around I think. Python is excellent for general purpose programming - MyHDL simply is one of its special purposes :-) because it is implemented as a Python package.

50%
50%
jandecaluwe
jandecaluwe
1/29/2013 1:56:56 PM
User Rank
Blogger
Re: My own take on a debounce circuit
@tomii "Did I get that right?"

I think you got it now. The easiest way to remember this, I think, is that blocking assignments behave exactly as traditional variables in programming languages. So they are the easy case - nonblocking assignments are special.

50%
50%
Karl
Karl
1/29/2013 1:32:57 PM
User Rank
Guru
Re: My own take on a debounce circuit
@tomii: I think you are right.  There has been tons of discussion and a lot of comparing Verilog to vhdl for signal assignments etc.

As an over simplification based on the "in blocking assignments, the last one wins" the sequence of blocking assignments kind of gives the programmer a way to express logic in the style of programming languages and the simulator will show the sequence.  Synthesis extracts the logic function and assigns the value to the flop.

Non-blocking assigns result in a reg/ff for each <= operator and it may take an extra clock cycle for the result to appear.

So PB_IN is input to a reg that exists in name only and actually becomes the din to the real clocked flop.  -- so yes, PB_IN propagates thru the first "reg" and becomes the input to the "real" reg.

50%
50%
Garcia-Lasheras
Garcia-Lasheras
1/29/2013 12:51:18 PM
User Rank
Blogger
Re: My own take on a debounce circuit
@Jan: "HDLs offer both concurrent and sequential semantics"

So HDL may be used in both hardware description and sequential general purpose programming... is this correct? (I've used GHDL for some testing...)

I've just discovered Python, and I've found a very powerfull and flexible tool with it. In this way, your MyHDL flow seems very, very interesting!!

I understand (correct me if necessary, please!) that MyHDl code can be directly executed (simulated?) in any Python shell, without the need of using "toVerilog", "toVHDL" or similar functionalities.

I mean... can I use MyHDL for general purpose programming? (in addition to hardware description)

By the way, your "MyHDL: Why Do We Need Signal Assignments?" post is very enlightening!! I hope more of these backward references in the future, as they are very interesting for APP newcomers like me.

50%
50%
tomii
tomii
1/29/2013 12:44:58 PM
User Rank
Blogger
Re: My own take on a debounce circuit
I am using my lunch break, today, to take the Alterra class referenced above.  I see that my understanding of blocking vs. non-blocking was wrong (and perhaps somewhat reversed).

Because the blocking statements wait for one another in execution, I assumed that they were needed to ensure that the flops were updated individually.  I now see that I had that backwards, that by using blocking statements, it appears that the PB_IN value propagates al the way through almost immediately.


Did I get that right?

50%
50%
jandecaluwe
jandecaluwe
1/29/2013 11:10:45 AM
User Rank
Blogger
Re: My own take on a debounce circuit
@tomii "I mean, this is hardware, so everything is concurrent, right?"

No, this is not hardware - this is a Verilog description that can be synthesized to hardware. The language has a value and semantics of its own that you will have to master - no escape.

HDLs offer both concurrent and sequential semantics. In Verilog, always blocks are concurrent, but the code within them is executed sequentially. If you look at your code and my comments from this perspective, I believe things will become clear.

One solution may also become clear now - just put the shift register code below the case in the always block. This will be much closer to what you want - in behavior and therefore also after synthesis.

Another solution would be to use nonblocking assignments (<=) for all your assignments. These are still executed sequentially, but their semantics are special, so that their behavior appears concurrent. To understand the background of all this, may I refer to my blog post on the subject:

http://www.programmableplanet.com/author.asp?section_id=2438&doc_id=251153

This also covers the subject of nondeterminism.

50%
50%
Page 1 / 6   >   >>
More Blogs from Duane Benson
Duane has decided that the time is ripe to get his ZedBoard bolted onto his robot with a Linux distribution up and running. That was the ultimate plan anyway, so why wait?
Now it's time to delve deeper into the state machine I'm using to control my I2C interface.
The three states associated with bi-directional "inout" pins can cause confusion for the unwary.
It's time to jump into unexplored territory -- the state machine that will control Duane Benson's I2C interface.
We're now ready for the I2C master to transmit a command set to a remote device.
flash poll
follow us on twitter
follow Xilinx on twitter
like us on facebook
like Xilinx on facebook
All Programmable Planet     About Us     Contact Us     Help     Register     Twitter     Facebook     RSS