workaround for Icarus not supporting do-while loops
fixed some parameterization typos
added another stage into the pipeline, so counting would be delayed compared to comparator/adder