Chapter 5. Code converter

Slides:



Advertisements
Similar presentations
KFUPM COE 202: Digital Logic Design Number Systems Part 3 Courtesy of Dr. Ahmad Almulhem.
Advertisements

1 Lecture 13 VHDL 3/16/09. 2 VHDL VHDL is a hardware description language. The behavior of a digital system can be described (specified) by writing a.
Quad 2-to-1 and Quad 4-to-1 Multiplexers Discussion D2.4 Example 7.
Gray Code Converters Discussion D9.1 Example 16.
1 VLSI DESIGN USING VHDL Part II A workshop by Dr. Junaid Ahmed Zubairi.
Top-level VHDL Designs
2.3 Binary Codes for Decimal Numbers ReturnNext Code: A set of n-bit strings in which different bit strings represent different numbers or other things.
Digilent Spartan 3 Board Lecture L2.2
Digilent Spartan 3 Board Discussion D3.3
Introduction to VHDL Multiplexers Discussion D1.1.
Binary-to-BCD Converter
Binary-to-BCD Converter
4-Bit Binary-to-BCD Converter: case Statement
CSET 4650 Field Programmable Logic Devices Dan Solarek VHDL Behavioral & Structural.
Binary-to-BCD Converter
A little bit of exercise.. ;). Exercise Given to you are some binary to decimal examples : Given to you are some binary to decimal examples : Tens Units.
Digital Arithmetic and Arithmetic Circuits
UNIVERSAL COLLEGE OF ENGINEERING AND TECHNOLOGY PREPARED BY:- Chirag Parmar ( ) Kashish Soni ( ) Maitrey Bhatt( )
Figure 5.1 Conversion from decimal to binary. Table 5.1 Numbers in different systems.
ENG241 Digital Design Week #8 Registers and Counters.
ENG2410 Digital Design LAB #5 Modular Design and Hierarchy using VHDL.
Reaction Timer Project
Introduction to FPGA Tools
2’s Complement 4-Bit Saturator Discussion D2.8 Lab 2.
2/10/07DSD,USIT,GGSIPU1 BCD adder KB3B2B1B0CD3D2D1D
Dept. of Electrical and Computer Eng., NCTU 1 Lab 4. BCD Adder Presenter: Chun-Hsien Ko Contributors: Chung-Ting Jiang and Lin-Kai Chiu.
CS/EE 3700 : Fundamentals of Digital System Design
Number Representation and Arithmetic Circuits
Section 5 Digital Electronic Circuits. Chapter 32 Binary Number System.
Cis303a_chapt03_exam1_answer.ppt CIS303A: System Architecture Exam 1: Chapter 3 Answer List the characters (digits) for the following bases. 1) Decimal:
Decoders A decoder is a logic circuit that detects the presence of a specific combination of bits at its input. Two simple decoders that detect the presence.
How to use ISE Dept. of Info & Comm. Eng. Prof. Jongbok Lee.
1 Introduction to Engineering Spring 2007 Lecture 19: Digital Tools 3.
LAB #5 Modular Design and Hierarchy using VHDL
Dept. of Electronics. & Info. Eng. Prof. Jongbok Lee
Combinational logic circuit
ECE 2110: Introduction to Digital Systems
Describing Combinational Logic Using Processes
Registers and Counters
ENG2410 Digital Design “Combinational Logic Design”
Dept. of Electronics & Info. Eng. Prof. Jongbok Lee
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
Number systems and codes
Dept. of Electronics & Info. Eng. Prof. Jongbok Lee
Dept. of Info. & Comm. Eng. Prof. Jongbok Lee
Dept. of Electrical and Computer Eng., NCTU
ENG6530 Reconfigurable Computing Systems
Advanced Digital design
Complement Theory 1’s and, 2’s complement operation
ECE 434 Advanced Digital System L08
ECE 331 – Digital System Design
BCD = Binary Coded Decimal
Logic Design Review – 2 Basic Combinational Circuits
Developing More Advanced Testbenches
Binary-to-BCD Converter
3-bit calculator using 7-segment LEDs
Chapter 5 – Number Representation and Arithmetic Circuits
Chapter 1 Number System RGGP, Narwana.
Founded in Silicon Valley in 1984
Table 1.1 Powers of Two.
Digital System Design Combinational Logic
Single bit comparator Single bit comparator 4/10/2007 DSD,USIT,GGSIPU
Arithmetic Circuits.
Four Bit Adder Sum A Cin B Cout 10/9/2007 DSD,USIT,GGSIPU.
Chapter 1 (Part c) Digital Systems and Binary Numbers
High-Low Guessing Game
4-Input Gates VHDL for Loops
System Controller Approach
디 지 털 시 스 템 설 계 UP2 Kit를 이용한 카운터 설계
EEL4712 Digital Design (Lab 1)
Presentation transcript:

Chapter 5. Code converter Dept. of Info. & Comm. Eng. Prof. Jongbok Lee

Code converter Usage : When exchanging information among systems which have different code systems, must convert codes Types BCD code Excess-3 code Gray code

1. BCD Code Alias : Binary Coded Decimal, 8421 code Meaning : represent each decimal to four-digit Feature : weighted code(can be used for calculation) Example : 0~9 same as binaries 10 : 0001 0000 11 : 0001 0001

Decimal Binary BCD 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 10 1010 0001 0000 11 1011 0001 0001

2. Excess-3 code Meaning : add 3 to BCD code Feature : Self-complement code Non-weighted code

Decimal Excess-3 0011 1 0100 2 0101 3 0110 4 0111 5 1000 6 1001 7 1010 8 1011 9 1100 10 0100 0011 11 0100 0100

entity bcd2excess3 is port ( bcd : in std_logic_vector(3 downto 0); excess3 : out std_logic_vector(3 downto 0)); end bcd2excess3; architecture behavioral of bcd2excess3 is begin excess3 <= “0011” when (bcd=“0000”) else “0100” when (bcd=“0001”) else “0101” when (bcd=“0010”) else “0110” when (bcd=“0011”) else “0111” when (bcd=“0100”) else “1000” when (bcd=“0101”) else “1001” when (bcd=“0110”) else “1010” when (bcd=“0111”) else “1011” when (bcd=“1000”) else “1100”; end behavioral;

entity bcd2excess3 is port ( bcd : in std_logic_vector(3 downto 0); excess3 : out std_logic_vector(3 downto 0)); end bcd2excess3; architecture behavioral of bcd2excess3 is begin process(bcd) case (bcd) is when “0000” => excess3 <= “0011”; when “0001” => excess3 <= “0100”; when “0010” => excess3 <= “0101” ; when “0011” => excess3 <= “0110” ; when “0100” => excess3 <= “0111” ; when “0101” => excess3 <= “1000” ; when “0110” => excess3 <= “1001” ; when “0111” => excess3 <= “1010” ; when “1000” => excess3 <= “1011”; when others => excess3 <= “1100”; end case; end process; end behavioral; % 실험 손을 떼면 1111 입력 : LED on-on-off-off 출력 1100 모두 누르면 0000입력 : LED off-off-on-on 출력 0011 양쪽 끝을 누르면 0110 입력 : LED on-off-off-on 출력 1001

#PACE: Start of Constraints generated by PACE #PACE: Start of PACE I/O Pin Assignments NET "bcd<0>" LOC = "H4" ; NET "bcd<1>" LOC = "H3" ; NET "bcd<2>" LOC = "G4" ; NET "bcd<3>" LOC = "G3" ; NET "excess3<0>" LOC = "A12" ; NET "excess3<1>" LOC = "A14" ; NET "excess3<2>" LOC = "B14" ; NET "excess3<3>" LOC = "B13" ; #PACE: Start of PACE Area Constraints #PACE: Start of PACE Prohibit Constraints #PACE: End of Constraints generated by PACE P16 D9 C9 C12 B13 B14 A14 A12 G3 G4 H3 H4

signal pin (push) pin (DPS) cable connection bcd(0) JP4.0 CN3.22 excess(0) A12 JP6.0 CN1.17 excess(1) A14 JP6.1 CN1.18 excess(2) B14 JP6.2 CN1.19 excess(3) B13 JP6.3 CN1.20

3. Gray Code Meaning : For the adjacent digits, only 1 bit is different Feature Non-weighted code (cannot be used for calculation) minimum chage code

Decimal Gray 0 (0000) 0000 1 (0001) 0001 2 (0010) 0011 3 (0011) 0010 4 (0100) 0110 5 (0101) 0111 6 (0110) 0101 7 (0111) 0100 8 (1000) 1100 9 (1001) 1101 10 (1010) 1111 11 (1011) 1110 % 실험 (1) 모두 누르면 off-off-off-off (2) 누르고-누르고-누르고-떼면 off-off-off-on (3) 누르고-떼고-떼고-누르면 off-on-off-on

entity bin2gray is port (binary : in std_logic_vector(3 downto 0); gray : out std_logic_vector(3 downto 0)); end bin2gray; architecture behavioral of bin2gray is begin gray(3) <= binary(3); gray(2) <= binary(2) xor binary(3); gray(1) <= binary(1) xor binary(2); gray(0) <= binary(0) xor binary(1); end behavioral;

signal pin (push) pin (DPS) cable connection binary(0) JP4.0 CN3.22 gray(0) A12 JP6.0 CN1.17 gray(1) A14 JP6.1 CN1.18 gray(2) B14 JP6.2 CN1.19 gray(3) B13 JP6.3 CN1.20

entity gray2bin is port ( gray : in std_logic_vector(3 downto 0); binary : out std_logic_vector(3 downto 0)); end gray2bin; architecture Behavioral of gray2bin is signal tmp : std_logic_vector(3 downto 0); begin tmp(3) <= gray(3); tmp(2) <= gray(2) xor tmp(3); tmp(1) <= gray(1) xor tmp(2); tmp(0) <= gray(0) xor tmp(1); binary <= tmp; end Behavioral;

signal pin (push) pin (DPS) cable connection gray(0) JP4.0 CN3.22 binary(0) A12 JP6.0 CN1.17 binary(1) A14 JP6.1 CN1.18 binary(2) B14 JP6.2 CN1.19 binary(3) B13 JP6.3 CN1.20

entity pin_test is port ( input : in std_logic_vector(7 downto 0); led : out std_logic_vector(7 downto 0)); end pin_test; architecture behavioral of pin_test is begin led <= input; end test;

signal pin no. cable connection input(0) D7 JP4.0 CN3.22 input(1) C7 led(0) A12 JP6.0 CN1.17 led(1) A14 JP6.1 CN1.18 led(2) B14 JP6.2 CN1.19 led(3) B13 JP6.3 CN1.20 led(4) C12 JP6.4 CN1.21 led(5) C9 JP6.5 CN1.22 led(6) D9 JP6.6 CN1.23 led(7) P16 JP6.7 CN1.24

% The emulation hexa inputs for Design Pro Shop 00 55 AA 01 02 04 08 10 20 40 80