Binary-to-BCD Converter

Slides:



Advertisements
Similar presentations
Digital Logic with VHDL EE 230 Digital Systems Fall 2006 (10/17/2006)
Advertisements

Quad 2-to-1 and Quad 4-to-1 Multiplexers Discussion D2.4 Example 7.
Arbitrary Waveform Discussion 5.5 Example 34.
Decoders Discussion D9.5 Example 25. Decoders 3-to-8 Decoder decoder38.vhd library IEEE; use IEEE.STD_LOGIC_1164.all; use IEEE.STD_LOGIC_unsigned.all;
Arithmetic Logic Unit (ALU)
Gray Code Converters Discussion D9.1 Example 16.
7-Segment Display: Spartan-3 board
Shifters Discussion D7.1 Example Bit Shifter.
Divider Discussion D7.3 Example 20.
Ring Counter Discussion D5.3 Example 32. Ring Counter if rising_edge(CLK) then for i in 0 to 2 loop s(i)
Adder Discussion D6.2 Example 17. s i = c i ^ (a i ^ b i ) c i+1 = a i * b i + c i * (a i ^ b i ) Full Adder (Appendix I)
Binary-to-BCD Converter Lecture L6.2 Section 6.5 pp
Generic Multiplexers: Parameters Discussion D2.5 Example 8.
Decoders and Encoders Lecture L4.2. Decoders and Encoders Binary Decoders Binary Encoders Priority Encoders.
1 Comparators Discussion D A 1-Bit Comparator The variable Gout is 1 if x > y or if x = y and Gin = 1. The variable Eout is 1 if x = y and Gin =
FPGAs and VHDL Lecture L12.1. FPGAs and VHDL Field Programmable Gate Arrays (FPGAs) VHDL –2 x 1 MUX –4 x 1 MUX –An Adder –Binary-to-BCD Converter –A Register.
Structural VHDL VHDL Tutorial R. E. Haskell and D. M. Hanna T3: ALU Design.
Counters Discussion D5.3 Example 33. Counters 3-Bit, Divide-by-8 Counter 3-Bit Behavioral Counter in Verilog Modulo-5 Counter An N-Bit Counter.
Codes and Code Converters
Lab 2 4-Bit Adder Digilent Spartan 3 Board Lecture L2.3.
Division Lecture L6.3. Division
4-to-1 Multiplexer: case Statement Discussion D2.3 Example 6.
FPGAs and VHDL Lecture L13.1 Sections 13.1 – 13.3.
Sequencing and Control Mano and Kime Sections 8-1 – 8-7.
Logic Design Fundamentals - 2 Lecture L1.2. Logic Design Fundamentals - 2 Basic Gates Basic Combinational Circuits Basic Sequential Circuits.
Digilent Spartan 3 Board Discussion D3.3
7-Segment Displays Digilent Spartan 3 Board Discussion DS-4.2.
Division Discussion D11.3. Division
Binary-to-BCD Converter
Registers Lab 5 Mano and Kime Sections 5-2, 5-3, 5-7.
Arithmetic Logic Unit (ALU) Discussion D4.6. ALU N = negative flag (N=1 if y(n)=0 Z = zero flag (Z = 1 if Y = 0) V = overflow flag C = carry flag.
Binary-to-BCD Converter
4-Bit Binary-to-BCD Converter: case Statement
Shift Registers Discussion D5.2 Example Bit Shift Register qs(3) qs(2) qs(1) qs(0) if rising_edge(CLK) then for i in 0 to 2 loop s(i) := s(i+1);
VHDL Examples Subra Ganesan Reference: Professor Haskell’s Notes,
4-bit Shift Register. 2-bit Register Serial-in-serial-out Shift Register.
Designing Combinational Logic Circuits in Verilog - 2
Binary-to-BCD Converter
Figure 5.1 Conversion from decimal to binary. Table 5.1 Numbers in different systems.
VHDL for Combinational Circuits. VHDL We Know Simple assignment statements –f
Digital Systems Design VHDL simulation of a 3 – Bit Binary Decoder with Enable by Marc A. Mackey.
ECE 331 – Digital System Design Multiplexers and Demultiplexers (Lecture #13)
2’s Complement 4-Bit Saturator Discussion D2.8 Lab 2.
4-to-1 Multiplexer: Module Instantiation Discussion D2.2 Example 5.
2/10/07DSD,USIT,GGSIPU1 BCD adder KB3B2B1B0CD3D2D1D
 Seattle Pacific University EE Logic System DesignCounters-1 Shift Registers DQ clk DQ DQ ShiftIn Q3Q3 Q2Q2 DQ Q1Q1 Q0Q0 A shift register shifts.
VHDL ELEC 311 Digital Logic and Circuits Dr. Ron Hayne Images Courtesy of Cengage Learning.
Number Representation and Arithmetic Circuits
Lecture 8 Review Combinational Devices –Decoder –Multiplexor (Bhasker p-81) –Shifter –Barrel Shifter (Bhasker p-303)
CDA 4253 FPGA System Design Behavioral modeling of Combinational Circuits Hao Zheng Dept of Comp Sci & Eng USF.
Multiplier: Functions Discussion D7.2 Example 19.
EGRE 6311 LHO 04 - Subprograms, Packages, and Libraries EGRE 631 1/26/09.
Registers and Counters Discussion D8.1. Logic Design Fundamentals - 3 Registers Counters Shift Registers.
Describing Combinational Logic Using Processes
Registers and Counters
Figure 7.1 Control of an alarm system
ENG2410 Digital Design “Combinational Logic Design”
Comparators Discussion DS-3.1.
Logic Design Review – 2 Basic Combinational Circuits
Mano and Kime Sections 7-6 – 7-8
VHDL (VHSIC Hardware Description Language)
Concurrent vs Sequential
A Greatest Common Divisor (GCD) Processor
Chapter 5 – Number Representation and Arithmetic Circuits
Fibonacci Sequence Lecture L4.1 Lab 3.
ECE 331 – Digital System Design
High-Low Guessing Game
4-Input Gates VHDL for Loops
디 지 털 시 스 템 설 계 UP2 Kit를 이용한 카운터 설계
Digital Logic with VHDL
Presentation transcript:

Binary-to-BCD Converter Discussion DS-4.1

Shift and Add-3 Algorithm   S1. Shift the binary number left one bit. 22. If 8 shifts have taken place, the BCD number is in the Hundreds, Tens, and Units column. 33. If the binary value in any of the BCD columns is 5 or greater, add 3 to that value in that BCD column. 44. Go to 1.

Steps to convert an 8-bit binary number to BCD

Truth table for Add-3 Module A3 A2 A1 A0 C S3 S2 S1 S0

K-Map for S3 A1 A0 00 01 11 10 A3 A2 00 01 1 1 1 11 X X X X 10 1 1 X X S3 = A3 + A2 * A0 + A2 * A1

S3 Binary-to-BCD Converter

Binary-to-BCD Converter Structural Solution

1. Clear all bits of z to zero 2. Shift B left 3 bits z[8:3] = B[5:0]; Steps to convert a 6-bit binary number to BCD 1. Clear all bits of z to zero 2. Shift B left 3 bits z[8:3] = B[5:0]; 3. Do 3 times if Units >4 then add 3 to Units (note: Units = z[9:6]) Shift z left 1 bit 4. Tens = P[6:4] = z[12:10] Units = P[3:0] = z[9:6]

binbcd6.vhd -- Title: Binary-to-BCD Converter library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all;   entity binbcd6 is port ( B: in STD_LOGIC_VECTOR (5 downto 0); P: out STD_LOGIC_VECTOR (6 downto 0) ); end binbcd6; architecture binbcd6_arch of binbcd6 is begin bcd1: process(B) variable z: STD_LOGIC_VECTOR (12 downto 0);

binbcd6.vhd (cont.) begin for i in 0 to 12 loop z(i) := '0'; end loop; z(8 downto 3) := B;   for i in 0 to 2 loop if z(9 downto 6) > 4 then z(9 downto 6) := z(9 downto 6) + 3; end if; z(12 downto 1) := z(11 downto 0); P <= z(12 downto 6); end process bcd1; end binbcd6_arch;

binbcd6.vhd

8-Bit Binary-to-BCD Converter binbcd8.vhd -- Title: Binary-to-BCD Converter library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all;   entity binbcd is port ( B: in STD_LOGIC_VECTOR (7 downto 0); P: out STD_LOGIC_VECTOR (9 downto 0) ); end binbcd;

binbcd8.vhd (cont.) architecture binbcd_arch of binbcd is begin bcd1: process(B) variable z: STD_LOGIC_VECTOR (17 downto 0); for i in 0 to 17 loop z(i) := '0'; end loop; z(10 downto 3) := B;   for i in 0 to 4 loop if z(11 downto 8) > 4 then z(11 downto 8) := z(11 downto 8) + 3; end if; if z(15 downto 12) > 4 then z(15 downto 12) := z(15 downto 12) + 3; z(17 downto 1) := z(16 downto 0); P <= z(17 downto 8); end process bcd1; end binbcd_arch; binbcd8.vhd (cont.)

binbcd8.vhd

16-bit Binary-to-BCD Converter

binbcd16.vhd -- Title: Binary-to-BCD Converter library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all;   entity binbcd16 is port ( B: in STD_LOGIC_VECTOR (15 downto 0); P: out STD_LOGIC_VECTOR (18 downto 0) ); end binbcd16; architecture binbcd16_arch of binbcd16 is begin bcd1: process(B) variable z: STD_LOGIC_VECTOR (34 downto 0);

binbcd16.vhd (cont.) begin for i in 0 to 34 loop z(i) := '0'; end loop; z(18 downto 3) := B;   for i in 0 to 12 loop if z(19 downto 16) > 4 then z(19 downto 16) := z(19 downto 16) + 3; end if; if z(23 downto 20) > 4 then z(23 downto 20) := z(23 downto 20) + 3; if z(27 downto 24) > 4 then z(27 downto 24) := z(27 downto 24) + 3; if z(31 downto 28) > 4 then z(31 downto 28) := z(31 downto 28) + 3; z(34 downto 1) := z(33 downto 0); P <= z(34 downto 16); end process bcd1; end binbcd16_arch; binbcd16.vhd (cont.)

binbcd16.vhd