Forum Discussion
Altera_Forum
Honored Contributor
13 years ago --- Quote Start --- The value i does get assigned to n_next, but immediately after that once the if statement resvolves n_next gets the value of n-1. So, effectively you never see the assignment of the value of i to n_next. By the time the clocked process triggers, n_next is equal to n-1, not i. The only time n_next will retain the value of i (instead of being re-assigned to n-1) when the process resolves is when the if statement is true (i.e. n==0). So, if the clocked process we call Process1 and the always@(*) we call Process2 then follow through the logic of what happens... On reset Process1 n=i; --A change on 'n' triggers Process2 Process2 n_next=i; -- n_next gets set to i at first Process2 n_next=n-1; --since 'n' is not equal to zero -- reset state ends On clk Process1 n=n_next; --A change on 'n' triggers Process2 Process2 n_next=i; Process2 n_next=n-1; --since 'n' is not equal to zero On clk Process1 n=n_next; --A change on 'n' triggers Process2 Process2 n_next=i; Process2 n_next=n-1; --since 'n' is not equal to zero . . . --this continues until n_next==0 On clk Process1 n=n_next; --A change on 'n' triggers Process2 Process2 n_next=i; --since 'n' is now equal to zero then the whole thing starts over... --- Quote End --- That was beautiful.. Many thanks for this detailed explanation.