| Author |
Message |
Nike
Joined: 26 Sep 2005 Posts: 5
|
26 Sep 2005 7:46 Whats the easiest way to convert Binary to BCD |
|
|
|
|
I have a counter that counts from 0 up to 31 (based on optional increments of 1,2,4) in binary. Then I need to convert this code into BCD (Tens and units ie: the binary value of 17 is 10001 and I need to turn it into 0001 which is decomal 1 and 0111 which is decimal 7 before I display them) and then I need to display the decimal value on 7 segment display. And I'm using the Xilinx ISE6 schematics to design the circuit.
Whats the easiest way to design a circuit to convert this binary value into BCD? Do I need to use K-maps or just draw the truth table and write the functions from there.
|
|
| Back to top |
|
 |
kashimonga
Joined: 08 Sep 2005 Posts: 16
|
26 Sep 2005 8:09 Re: Whats the easiest way to convert Binary to BCD |
|
|
|
|
| you may simply a micro controller code to convert binary to BCD. are you familiar with microcontroller?
|
|
| Back to top |
|
 |
Nike
Joined: 26 Sep 2005 Posts: 5
|
26 Sep 2005 8:30 Re: Whats the easiest way to convert Binary to BCD |
|
|
|
|
| I am not allowed to use any code. I'm only allowed to use logic And,Nand, Or, Xor and inverters plus flip-flops to design this circuit. Basically I need to design the circuit with logic gates if you know what I mean.
|
|
| Back to top |
|
 |
echo47
Joined: 07 Apr 2002 Posts: 4206 Helped: 566
|
26 Sep 2005 8:59 Whats the easiest way to convert Binary to BCD |
|
|
|
|
I can't think of any simple approach except to use a small 32x8 ROM containing the truth table, but that may be against your project rules.
I think you already have the right idea: convert the truth table to boolean equations by using K-maps, or simple inspection, or engineering software, or whatever approach seems easiest to you.
|
|
| Back to top |
|
 |
svicent
Joined: 11 Jul 2001 Posts: 413 Helped: 23
|
26 Sep 2005 9:32 Re: Whats the easiest way to convert Binary to BCD |
|
|
|
|
Using Couleur's Technique (BIDEC), a binary number (most significant bit, MSB) first is shifted and processed, such that the BCD equivalent is obtained when the last binary bit is clocked into the register.
The basic rule is: if a 4 or less is in a decade, shift with the next clock pulse; if 5 or greater in a decade, add 3 and then shift at the next clock pulse.
For more information:
BIDEC – A Binary-to-Decimal or Decimal-to-Binary Converter, J. F. Couleur, IRE Transactions on Electronic Computers, Vol. EC-7, pp313-316, IRE, 1958.
|
|
| Back to top |
|
 |
Nike
Joined: 26 Sep 2005 Posts: 5
|
26 Sep 2005 10:08 Re: Whats the easiest way to convert Binary to BCD |
|
|
|
|
No I'm only allowed to use logic And,Nand, Or, Xor and inverters plus flip-flops to design this circuit. And the K-map is going to be extremely hard to draw and takes up a lot of time since I need a 5 bit K-map here. Do you know of any software on internet that does the K-map job and also shows what it is doing through diagrams so I know whats happening and can explain it at the time of demonstration? Because drawing them by hand is going to be one hell of a job. and has a very high risk of making a mistake.
Using Couleur's Technique (BIDEC), a binary number (most significant bit, MSB) first is shifted and processed, such that the BCD equivalent is obtained when the last binary bit is clocked into the register.
The basic rule is: if a 4 or less is in a decade, shift with the next clock pulse; if 5 or greater in a decade, add 3 and then shift at the next clock pulse.
I didn't quite understand what you are saying there but I'm assuming I need some sort of comparator? I can't use any gates or logic circuits other than what I mentioned. could you please explain that method some more if that method is possible using those gates I mentioned?
|
|
| Back to top |
|
 |
Google AdSense

|
26 Sep 2005 10:08 Ads |
|
|
|
|
|
|
| Back to top |
|
 |
nand_gates
Joined: 19 Jul 2004 Posts: 907 Helped: 120
|
26 Sep 2005 11:04 Re: Whats the easiest way to convert Binary to BCD |
|
|
|
|
For a simple counter we can do binary to bcd as follows!
| Code: |
module bin_bcd_counter(/*AUTOARG*/
// Outputs
counter,
// Inputs
clk, reset_n, cnt_bcd
);
input clk, reset_n;
input cnt_bcd;
output [7:0] counter;
reg [7:0] counter;
reg [7:0] counter_nx;
always@(posedge clk or negedge reset_n) begin
if (!reset_n) begin
counter <= 0;
end else begin
counter <= counter_nx;
end
end
always @(/*AS*/cnt_bcd or counter) begin
counter_nx = counter + 1;
if (cnt_bcd) begin
if (counter_nx[3:0] > 9) begin
counter_nx[3:0] = counter_nx[3:0] + 6;
counter_nx[7:4] = counter_nx[7:4] + 1;
end
if (counter_nx[7:4] > 9)
counter_nx[7:4] = counter_nx[7:4] + 6;
end
end
endmodule // bin_bcd_counter |
You can modify this for down counter also!
Hope this helps
|
|
| Back to top |
|
 |
eYe
Joined: 12 Aug 2001 Posts: 105 Helped: 1
|
26 Sep 2005 11:13 Whats the easiest way to convert Binary to BCD |
|
|
|
|
Back to basic digital design....
31 bits to two 7 segments is making K-Map and do the boolean.
|
|
| Back to top |
|
 |
svicent
Joined: 11 Jul 2001 Posts: 413 Helped: 23
|
26 Sep 2005 18:30 Re: Whats the easiest way to convert Binary to BCD |
|
|
|
|
Nike,
The Couleur's Technique (BIDEC) only uses Flip-flops and logic.
Using a PAL22v10 it is possible to convert an 8-bit binary to BCD. Using two PAL22V10 you can convert 16-bit to BCD.
If you think about it, you will see that only a special shift register is needed.
|
|
| Back to top |
|
 |