![]() |
|
|
|||||||
![]() |
VHDL - How can I avoid multiple execution when handshaking operations? |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
As a newbie I would like to know what the code would look like for an
entity that behaves in the following manner: 1) It has an integer/enumeration input that is used by clients to tell it the type of operation to perform. 2) The clients set an 'Start' bit to indicate that the entity should perform the operation. 3) The clients then wait on a 'Ready' bit which is set by the entity when it has completed the operation. My main concern is how to code this in such a manner that the entity doesn't repeat the operation ad nauseum, due to the fact that there doesn't seem to be any clean way for the 'Start' bit to be cleared (and hence stop the entity from repeating the operating as soon as it completes one cycle). I suspect that the solution relies somehow on only triggering the operation on the transition on the Execute bit, but I'm not sure what the code would look like. Thanks for any info. Anon Anon |
|
|
|
|
#2 |
|
Posts: n/a
|
If you fire off a transition, then you'll need to make sure that the
clients generate a transition the next time they want the process to run. From you post, it seemed there was no plan to clear that start bit. If you don't clear it, you won't be able to generate a new transition, leaving you with the same problem. That bit needs to be cleared either by the client or the unit. canadianJaouk |
|
|
|
#3 |
|
Posts: n/a
|
canadianJaouk wrote:
> If you fire off a transition, then you'll need to make sure that the > clients generate a transition the next time they want the process to > run. From you post, it seemed there was no plan to clear that start > bit. If you don't clear it, you won't be able to generate a new > transition, leaving you with the same problem. That bit needs to be > cleared either by the client or the unit. > > Sorry - I should have made that clearer: please assume that the client clears the 'Start' bit as soon as it detects that the 'Ready' bit has been set. It then modifies the operation code and sets the Start bit once more to repeat the process all over again. What I really want to know is, what does the internal code of the entity look like to make it execute the command once only? Anon Anon |
|
|
|
#4 |
|
Posts: n/a
|
> What I really want to know is, what does the internal code of the entity
> look like to make it execute the command once only? then firing off the rising edge of the start signal should be the way to go, like you suggested in your first post. You need to code a simple edge detector for that. I assume you have a main clock in your unit. What you need to do goes like this signal start_rise : std_logic; signal start_ff : std_logic; .... process(reset, clk) begin if reset = '1' then start_ff <= '0'; elsif rising_edge(sysClk) then start_ff <= start; end if; end process; start_rise <= not (start_ff) and start; Basically the idea is to check when the signal is 1 but was 0 the cycle before. Run those through an AND gate and it will tell you everytime that condition happens this will get you a one clock cycle pulse (start_rise) everytime start transitions from 0 to 1. You can use that signal to fire off the process in your module instead of using start canadianJaouk |
|
|
|
#5 |
|
Posts: n/a
|
> process(reset, clk)
> begin > if reset = '1' then > start_ff <= '0'; > elsif rising_edge(sysClk) then > start_ff <= start; > end if; > end process; > > start_rise <= not (start_ff) and start; sorry sysClk was meant to be clk... rising_edge(clk) canadianJaouk |
|
|
|
#6 |
|
Posts: n/a
|
On Tue, 17 Apr 2007 16:35:08 +0100, Anon Anon <> wrote:
>canadianJaouk wrote: >> If you fire off a transition, then you'll need to make sure that the >> clients generate a transition the next time they want the process to >> run. From you post, it seemed there was no plan to clear that start >> bit. If you don't clear it, you won't be able to generate a new >> transition, leaving you with the same problem. That bit needs to be >> cleared either by the client or the unit. >> >> > >Sorry - I should have made that clearer: please assume that the client >clears the 'Start' bit as soon as it detects that the 'Ready' bit has >been set. It then modifies the operation code and sets the Start bit >once more to repeat the process all over again. This means that, after you set "Ready", you can watch for the Start bit to be cleared. When it is, you can safely clear Ready, and watch for Start to be set again. >What I really want to know is, what does the internal code of the entity >look like to make it execute the command once only? A state machine. (You can find plenty of information on state machines) - Brian Brian Drummond |
|