Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help urgent!!! binary to bcd converter

Status
Not open for further replies.

yein

Technical User
Nov 28, 2007
4
MY
I m curently work out this converter but the compilation is not successful. Below is the codes and error message. And I am using shift add3 algorithm for this.

LIBRARY ieee;
USE ieee.STD_LOGIC_1164.all;
USE ieee.STD_LOGIC_ARITH.all;
USE ieee.STD_LOGIC_UNSIGNED.all;

ENTITY projectTest3 IS
port( D : in std_logic_vector(15 downto 0);
Q : out std_logic_vector(15 downto 0));
END projectTest3;
ARCHITECTURE behavioral OF projectTest3 IS
Begin
PROCESS(D)
variable r: STD_LOGIC_VECTOR (15 DOWNTO 0);
BEGIN
r:=(others=>'0');
r(4 DOWNTO 0):=D(15 DOWNTO 11);
FOR i IN 0 TO 9 loop
IF D(10-i)='1' then
r(5+i DOWNTO 0) := r(4+i DOWNTO 0) & '1';
ELSE
r(4+(i+1) DOWNTO 0) := r(4+i DOWNTO 0) & '0';
END IF;

IF r(3 DOWNTO 0) >= 5 then
r(3 DOWNTO 0) := r(3 DOWNTO 0) + "0011";
IF r(7 DOWNTO 4) >= 5 then
r(7 DOWNTO 4) := r(7 DOWNTO 4) + "0011";
IF r(11 DOWNTO 8) >= 5 then
r(11 DOWNTO 8) := r(11 DOWNTO 8) + "0011";
END IF;
END IF;
END IF;
END LOOP;
Q(15 downto 0) <= r(15 downto 0);
END PROCESS;
end behavioral;


Error: a deferred constant declaration without a full declaration is not supported
ANYone can help?
THANKs in advance
 
Hi,
I think you have recently used the VHDL. Remember that VHDL is the language to design the hardware but not the software. Your program seems to be used for C language in computer. I think the trouble is here :
FOR i IN 0 TO 9 loop
IF D(10-i)='1' then
r(5+i DOWNTO 0) := r(4+i DOWNTO 0) & '1';
ELSE
r(4+(i+1) DOWNTO 0) := r(4+i DOWNTO 0) & '0';
END IF

The compiler cannot generate the hardware to do this. So tell me what your program need to do in detail. I will give you some suggestion.
 
Yes. I'm new to VHDL. Actually i am designing a calculator tht can perform addition, subtraction and multiplication only. User will key in the maximum 2 BCD numbers (56+72, 56*4,...).For addition and subtraction, i can do it in BCD. But for multiplication, I have to convert bcd into binary code then the binary result has to convert it back into bcd. I have stucked in the binary to bcd conversion. Hope u can help me... Thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top