Virtual Wallet Design of BCD Binary Converters To create a handheld device which will save money and time through budget assistance and improve the shopping experience. Gates Winkler Jordan Samuel Fei Yin Shen October 19, 2009
Status Finished Flow Chart Behavioral Verilog Transistor Estimate Floor Plan Structure Proposal Structural Verilog Schematic To Do Layout Testing
Introduction Binary – Representing numbers on a “2” scale. –Ex. 19 = BCD – Representing numbers on a “10” scale using a “2” scale. –Each set of 4 bits stores 1 base 10 digit. Called a nibble. –Ex. 19 = (2 nibbles) 0001 = 1; 1001 = 9
When Converting It is important to remember that though both are represented with 0 and 1s they will have different lengths when converted. BCD bit length will always be a multiple of 4 Number Number of Bits BinaryBCD e62028
Binary To BCD Algorithm Assumes the necessary number of bits to store the nibbles are all initialized to 0. Ex. Binary 51 = Needs 2 nibbles all set to 0 =>
Step 1 – Check For >=5 Check all nibbles to see if any are >= 5. –0000 < 5 If none are >= do nothing.
Step 2 – Shift Left Shift all bits left shifting the MSB of the binary number into the LSB of the BCD number. Anything can be shifted in. Initial: : After Shift: : 10011X
Step 3 – Repeat Repeat x times where x = length of binary number. 1 Run: : 10011X 2 Run: : 0011XX 3 Run: : 011XXX Wait… After 3 runs there is a nibble that that is >= 5.
Step 1b – Greater or Equal 5 If any nibbles are >= 5 then add 3 (0011) to that nibble. No nibble can ever be >9 so overflow is impossible < >5 thus – = 1001 After adding continue with step 2 –Initial: : 011XXX –After Increasing Nibbles: : 011XXX –After Shift: : 11XXXX
Step 3 – Repeat (Again) Finish repeating. 4 Run: : 11XXXX 5 Run: : 1XXXXX 6 Run After Adding: : 1XXXXX –6 After Shifting: : XXXXXX Final answer: = = 1
BCD To Binary Algorithm Practically identical but reversed. Here are the changes. Step 1 Shift –Shifts right instead of left –LSB of BCD is shifted into MSB of Binary –Must Shift in 0s Step 2 Greater than/equal to 8 –Compares each BCD nibble to 8 instead. If less than do nothing. If greater than/equal subtract 3 from the nibble. Step 3 Repeat (again) Repeat x times where x = length of binary number.
Structural Binary To BCD –Needs 48 Flip Flops –7 4-bit adders (28 1-bit adders) –7 compare blocks. BCD To Binary –Needs 48 Flip Flops –7 4-bit subtracters (28 1-bit subtracters) –7 compare blocks.
Flip Flops – Output The Output Flip Flops can be regular Sequential Flip Flops.
Flip Flops – Input The Input Flip Flops will be parallel Flip-Flops which allows us to chose whether we want to shift or write. The nand gates allow for the flip flops to be written to on low write while it acts as a shifter on high write.
Compare to 5 Assumes 4 bit input B[3:0]. Use a Truth table to figure out block configuration
Binary – BCD 1 Nibble
Compare to 8 Easy, if Cin = 1 then the nibble will become 8 or greater. Don’t need a compare.
BCD – Binary 1 Nibble
Note In a BCD – Binary converter the BCD is the input. Thus the Flip Flops are actually the ones shown on slide 13. Binary Just Shifts without anything fancy. Just Needs respective Flip Flops.
Schematics Binary - BCD
BCD - Binary
Binary – BCD: Binary
Parallel Flip Flop
Flip Flop
Nand Block
Binary – BCD: BCD
Binary – BCD: 1 nibble
Compare to 5
BCD – Binary: Binary
BCD – Binary: BCD
BCD – Binary: BCD 1 nibble