Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Whats the easiest way to convert Binary to BCD

Status
Not open for further replies.

Nike

Newbie level 4
Joined
Sep 26, 2005
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,356
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.
 

you may simply a micro controller code to convert binary to BCD. are you familiar with microcontroller?
 

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.
 

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.
 

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.
 

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?
 

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 basic digital design....
31 bits to two 7 segments is making K-Map and do the boolean.
 

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.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top