R
Rick C
Guest
I recall digging deeply into NCO design some years ago. I am trying to remember the dirty details of what I had learned. In particular I have a non-binary modulus. I\'d like to find the simplest way to implement this. This is the best I can think of now, but I want to say someone had come up with a really nice way to code this that was optimally simple and produced optimally simple implementation.
elsif (rising_edge(Clk)) then
if (PWM_Clk) then
if (NCO_Accum - Phase_Step < 0) then
NCO_Accum := NCO_Accum - Phase_Step;
else
NCO_Accum := NCO_Accum - Phase_Step + NCO_Mod;
end if;
end if;
end if;
I use the condition (NCO_Accum - Phase_Step < 0) in the IF because it in theory can use the same hardware as the subtractor borrow out.
I can\'t recall the detail, but I want to say someone had a solution that could do this with one adder, but maybe with a mux. Or maybe I\'m not remembering right and it was a mux with another adder that was not part of the critical timing path. I just can\'t see how to do this without the two adders (subtractors).
Maybe it is the sum of the step size and the modulus which is then muxed with the step size before the subtraction. I bet that\'s what I\'m thinking of.. I believe that will mess up the idea of sharing the carry chain for the conditional logic. I need to pull the difference out of the conditional I guess. I don\'t really need speed, so that\'s not an issue. I am just trying to remember how it all went.
--
Rick C.
- Get 1,000 miles of free Supercharging
- Tesla referral code - https://ts.la/richard11209
elsif (rising_edge(Clk)) then
if (PWM_Clk) then
if (NCO_Accum - Phase_Step < 0) then
NCO_Accum := NCO_Accum - Phase_Step;
else
NCO_Accum := NCO_Accum - Phase_Step + NCO_Mod;
end if;
end if;
end if;
I use the condition (NCO_Accum - Phase_Step < 0) in the IF because it in theory can use the same hardware as the subtractor borrow out.
I can\'t recall the detail, but I want to say someone had a solution that could do this with one adder, but maybe with a mux. Or maybe I\'m not remembering right and it was a mux with another adder that was not part of the critical timing path. I just can\'t see how to do this without the two adders (subtractors).
Maybe it is the sum of the step size and the modulus which is then muxed with the step size before the subtraction. I bet that\'s what I\'m thinking of.. I believe that will mess up the idea of sharing the carry chain for the conditional logic. I need to pull the difference out of the conditional I guess. I don\'t really need speed, so that\'s not an issue. I am just trying to remember how it all went.
--
Rick C.
- Get 1,000 miles of free Supercharging
- Tesla referral code - https://ts.la/richard11209