Forgive me for my ignorance, but I'm a bit confused as to what the sequencer is actually supposed to do in the other 3 steps (4-6)? I was under the impression that most of the code would be written within the task itself.
The 2 tasks I made are nothing more than a timer.
1 task sets the beginning of the counter.
the other task counts down to 0, and once at 0, it will increment the 'function_pos' register.
The case statement, which can also be equivalent to an:
if (finction_pos == 0) begin
blah, blah, blah.
end else if (function_pos == 1) begin
blah, blah, blah.
end else ...
I made comments after each possible (function_pos == 0, 1, 2, 3, 4, 5, 6...)
Think about what you want to do.
in position #1, I wrote in the comment to turn off the laser & once the sync event comes in, IE: 'sync_trigger_on', increment the function_pos reg.
in position 2, I said you should set the universal timer's delay, 'SET_laser_clock' to your 'pixel offset' setting and increment the function_pos.
in position 3, I said to just run the timer, ie the 'RUN_laser_clock'. Remember, inside run laser clock, once the countdown reaches 0, it will increment the function_pos for you.
in position 4, I said to set the laser clock to your number of pixels you want to display on a line & increment the function_pos.
in position 5, I said to turn on the laser, toggle the laser output for effect, and run the 'RUN_laser_clock' timer remembering that inside run laser clock task, once the countdown reaches 0, it will increment the function_pos for you.
in position 6, I said to turn off the laser and set reg function_pos <= 1, meaning that the next cycle, we will be back at position 1, waiting for the 'sync_trigger_on' before we go to position 2. This is basically a loop.
Now, in your head, follow these instructions ion order and emulate how this home-made instruction step program will run. Remember, inside each position start, all the equations, or flip-flop regs are running always at your master 25MHz clock input.
So, when we are in state 1, whatever you type inside that begin ... end, will be operating at 25MHz while the functions or operations inside all the other states are ignored, or frozen.