Full Library / Math Operator / Counter / Counter_Loop_K
Block Name: Counter_Loop_K
Code File Location: VisualSim/actor/lib/Counter_Loop_K
Block Overview
- This is a counter that increments or decrements until it reaches a the 'final value'. There are two models of operation for this block. The Do settings get the Final Value from the 'init' port. The Parameter Valid (Above) gets the final value from the Parameter. The increment or decrement of any value.
-
- The 'init' port is required to initialize the block for all mode of operations, to reset the counter and to restart the loop count. The ready_input is the trigger to modify the counter value. For every input on the ready_input port, the current value of the counter is placed on 'counter_output' port. When the loop count reaches the final value, this value is placed on the 'counter_output' and the 'done_output' port. In the case of DO(0,N-1), the final value will be one value less than the initial value set.
-
- The block has three modes of operation:
- "Do (1 , N)": In this mode, the value on the 'init' is the final value. The initial value is 1 and the increment value is the Increment_Value. The 'init' is required to start the loop and to reset it for every new loop. The counter value is incremented by the Increment_Value when a token arrives on the ready_input. When the loop is completed, the 'counter_output' and done_output receive the last value. This can be fed back to the 'init' to restart the loop.
- "Do (0 , N-1)": In this mode, one minus the value on the 'init' is the final value. The initial value is 0 and the increment value is the Increment_Value. The 'init' is required to start the loop and to reset it for every new loop. The counter value is incremented by the Increment_Value when a token arrives on the ready_input. When the loop is completed, the 'counter_output' and the done_output receives the final value which is N-1. This can be fed back to the 'init' to restart the loop.
- Above Parameters Valid: This uses the initial, final and increment values in the block. The 'init' is required to start the loop and to reset it for every new loop. The counter value is incremented by the value arriving on the ready_input. When the loop is completed, the'counter_output' and the done_output receive the last value. This token can be fed back to the 'init' to restart the loop. The Final Value remains unchanged.
init
public TypedIOPort begin_n_input
- For the "Do (1 - N)", or "Do (0, N-1)" mode, the value on this port sets the Final counter value. Type can be integer only. If Loop_Counter_Mode is set to Parameters Valid (Above), then user entered Intial_Value/Final_Value is set and this port value is ignored. Triggering this port resets the internal counter.
ready_input
public TypedIOPort ready_input
- "ready_input" input increments counter from initial counter state. If the "begin_n_input" port has not been set, for the "Do (1 - N)", or "Do (0, N-1)" modes prior to triggering the "ready_input", then an exception is caused.
counter_output
public TypedIOPort loop_index_output
- "counter_output" port sends out the current state of the loop counter. The first output appears when the "ready_input" is triggered, which increment the loop counter.
done_output
public TypedIOPort done_output
- "done_output" fires with the final value at the same time as the "counter_output", once the counter reaches this value.
Initial_Value
public Parameter Initial_Value
- Parameter, Initial value for the counter. This is used in the Loop_Counter_Mode: Parameter Valid (Above) setting only. The initial values for the "Do (1 - N)", or "Do (0, N-1)" mode are 1 and 0 respectively.
Final_Value
public Parameter Final_Value
- Parameter, Final value for the counter. This is used in the Loop_Counter_Mode: Parameter Valid (Above) setting only. The final values for the "Do (1 - N)", or "Do (0, N-1)" modes are the N ('init') and N('init')-1.
Increment_Value
public Parameter Increment_Value
- Parameter, increment value for the counter. it is used for all modes of operation.
Loop_Counter_Mode
public StringAttribute Loop_Counter_Mode
- The relative loop counter mode operator, determines operational mode of loop counter. For the "Do (1 , N)", or "Do (0, N-1)" modes, the initial value is 0 or 1 depending on the setting and the final value is the value on the 'init' port. The increment is always 1. For the Parameter Valid (Above), the initial value is in the Initial_Value parameter and the final value is in the Final_Value parameter. The 'init' is used to trigger the reste of the counter for the Parameter_Valid (Above) mode.
Created with the Personal Edition of HelpNDoc: Easy EPub and documentation editor