.en(enable_mot),// enable, 0 turns off motors and resets counterts
.pre_first(pre_first),// next whill be the first motor in a cycle (may use just spread bits)
.pwm_delay(pwm_delay[2:0]),// [2:0] - turns off bridge during transition (i.e. 10->00->11->00->10 ..). Nominal 0.3usec - 2 (0x18) cycles (80/4/3=6.66MHz)
.pwm_cycle(pwm_cycle[7:0]),// [7:0] - pwm cycle duration Nominal 10usec or 67 (0x43) 6.66MHz cycles. Total PWM period will be 8 of these cycles
.spread({sequence[3:2],1'b0}),// [2:0] shift on phase between motors, adds this number to the current phase (use just 2 MSBs for 3 motors)
.cur_pwm(cur_pwm[2:0]),// [2:0] - PWM data stored in per-motor memory. [1] - 'on', [0] direction, [2] - enable. That bit is used to turn off motor during PWM transitions
en,// enable, 0 turns off motors and resets counterts
pre_first,// next whill be the first motor in a cycle (may use just spread bits)
pwm_delay,// [2:0] - turns off bridge during transition (i.e. 10->00->11->00->10 ..). Nominal 0.3usec - 2 (0x18) cycles (80/4/3=6.66MHz)
pwm_cycle,// [7:0] - pwm cycle duration Nominal 10usec or 67 (0x43) 6.66MHz cycles. Total PWM period will be 8 of these cycles
spread,// [2:0] shift on phase between motors, adds this number to the current phase (use just 2 MSBs for 3 motors)
cur_pwm,// [2:0] - PWM data stored in per-motor memory. [1] - 'on', [0] direction, [2] - enable. That bit is used to turn off motor during PWM transitions
mot// [1:0] - data to be copied to the motor outputs
);
inputclk;// posedge, 80MHz
inputen;// enable, 0 turns off motors and resets counterts
inputpre_first;// next whill be the first motor in a cycle (may use just spread bits)
input[2:0]pwm_delay;// [2:0] - turns off bridge during transition (i.e. 10->00->11->00->10 ..). Nominal 0.3usec - 24 (0x18) cycles
input[7:0]pwm_cycle;// [7:0] - pwm cycle duration Nominal 10usec oror 67 (0x43) 6.66MHz cycles. Total PWM period will be 8 of these cycles
input[2:0]spread;// [2:0] shift on phase between motors, adds this number to the current phase (use just 2 MSBs for 3 motors)
input[2:0]cur_pwm;// [2:0] - PWM data stored in per-motor memory. [1:0] - motors, [2] - enable. That bit is used to turn off motor during PWM transitions
assignnew_pwm[0]=!stop_cmd&&(pwm_cycle_next?pwm_code[3]:cur_pwm[0]);// direction
assignnew_pwm[1]=!stop_cmd&&(pwm_cycle_next?((pwm_code[2:0]!=0)&&!pwm_diff[3]):cur_pwm[1]);// turn off (by en) immediately, others - only at pwm_cycle_next;