??? 04/12/07 07:48 Read: times |
#137020 - Try a different algorithm Responding to: ???'s previous message |
I'm not surprised it takes a lot of gates to implement your code - easy to write though.
Many years ago I stumbled upon an algorithm (From a microchip app note) that converts binary to bcd by using a shift,correct,subtract algorithm - similar to the usual division algorithm but with a bcd correction added. If you implement this algorithm in logic, it will only need to shift and add/subtract rather than multiplies. I dare say it will reduce the number of gates (logic blocks??). The code will be a little more difficult to write. You should compare how many gates it took to implement your code vs a softcore cpu like a PIC! Important lesson learned here - anyone can write code, but it takes a little more skill to write compact and/or efficient code. |