Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Falling and Rising in same process

Status
Not open for further replies.

YodaTheGreat

Programmer
Jun 2, 2004
6
FR
Hi All,

I have 2 Signal INPUT_A and INPUT_B.

And I want Inc/Dec a variable with this signals

Process (INPUT_A,INPUT_B,Reset)
Begin
If Reset = '1' Then
-- Async reset etc
Else
If Falling_Edge(INPUT_A) Then
If INPUT_B='1' Then
Variable <= Variable + X"01";
Else
Variable <= Variable - X"01";
End If;
End If;
If Falling_Edge(INPUT_B) Then
If INPUT_A='1' Then
Variable <= Variable - X"01";
Else
Variable <= Variable + X"01";
End If;
End If;
If Rising_Edge(INPUT_A) Then
If INPUT_B='1' Then
Variable <= Variable + X"01";
Else
Variable <= Variable - X"01";
End If;
End If;
If Rising_Edge(INPUT_B) Then
If INPUT_A='1' Then
Variable <= Variable - X"01";
Else
Variable <= Variable + X"01";
End If;
End If;
End If;
End Process;


But This Code don't Work.....

Have you a Solution, Please.
Some Code for Me.

Best regards Yodathegreat.
VHDL Beginer..


 
Firstly, if you plan on using code for real logic (as opposed to simulation) then you can only have one edge detection per process (be that a wait until, or a if clk'event etc).

so what you are trying to do here is going to take some thought. I'll come back with some ideas.

--
 
Hi VHDLGuy,

I know for one EVENT by process..
I have read some topic in this forum.

now, in my source code I have 4 Procres..
But it's a same probleme....

A is a square ware (10khz)
B is a square ware (A with 90°)

_____ ______
A => ___| |______| |_____
_____ ______
B => _____| |______| |_____

best regards christophe (Yodathegreat)
 
ok that makes it easier. I take it that the square wave doesn't always exist (by exist i mean - the rise doesn't alway happen), but when they do exist that they follow the rule you mentioned. (and based on what you want to do, B can exist without A existing and visa verca - again with 'exist' meaning that the rise occurs or not).

Some questions:
do you have a clock? (list all of them) and is it synchronous to these 10khz signals? does the squarewave stay high for the same amount of time always?

A clock would make it much easier. If not I will have to think some more.

--
 
wait. I just realised. your rules don't match your counting logic.

if B is 90 degrees out of phase with A then this:
If Falling_Edge(INPUT_B) Then
If INPUT_A='1' Then
Variable <= Variable - X"01";
Else
Variable <= Variable + X"01";
End If;
End If;

doesn't have any use. A will always be '0' when B is falling.
Therefore there must be more that you haven't explained. (or your logic is wrong).

--
 
Yoda:

Is your application related with position-encoder? I have a way to work it out. VHDLguy is right, use more than one edge in one process can be dangerous.

We can design 4 similar entities, each is a counter.
Counter 1 works only on A's rising edge, it increases or decreases according to B's high or low. Counter 2 works only on A's falling edges. Counter 3 and 4 use B's edges and A's high/low.

Create a higher level entity that use the 4 counter as its components. The final output should be something like
CNT <= CNT1 - CNT2 + CNT3 - CNT4.

I am new in VHDL design[bigears]. Hope to learn more form you guys.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top