Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - 8 bit binary to 2 digit BCD

 
Thread Tools Search this Thread
Old 06-05-2006, 01:02 PM   #1
Default 8 bit binary to 2 digit BCD


Hi all,

I have to make the following:

An 8 bit binary comes in "Parallel" May not be bigger then 99. When its
binair 23 for example I have to split it.. 1 register have to hold the
'2' and another register have to hold the '3'.
When that is done... Register1 and Register2 need to be send out
serial.

1(start bit) 3 2 1 0(Register1) 3 2 1 0 (Register2) 3 2 1 0 (Stop bit )
0

Tried to make it but cannot get it working. splitting up the binary
already go's wrong

Appreciate some help



Yama
  Reply With Quote
Old 06-05-2006, 01:17 PM   #2
Yama
 
Posts: n/a
Default Re: 8 bit binary to 2 digit BCD
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.NUMERIC_STD.ALL;

entity BtoB is
Port ( Data_in : in STD_LOGIC_VECTOR (7 downto 0);
Clk : in STD_LOGIC;
Reset : in STD_LOGIC;
Button : in STD_LOGIC;
Busy : out STD_LOGIC;
Data_uit : out STD_LOGIC;
end BtoB;

architecture Gedrag of BtoB is

shared variable Value: integer;
shared variable ValueGr: integer;
shared variable ValueKl: integer;


signal Register_1: STD_LOGIC_VECTOR(3 downto 0);
signal Register_2: STD_LOGIC_VECTOR(3 downto 0);
signal Register_3: STD_LOGIC_VECTOR(9 downto 0);

type STATE_T is (GOT0,GOT1,GOT2,GOT03,GOT4);
signal State: STATE_T;


begin

----------------------------------------------------------------------
-- Verwerk_dat_in
----------------------------------------------------------------------
Verwerk_data_in: process(Clk, Data_in,Button, Reset,Counter)

begin
if Clk ' event and Clk = '1' then
case State is
when GOT0 =>
null;
when GOT1 =>
ValueKl:= Value mod 10;
-- TempValue:= Value - ValueKl;
-- ValueGr := TempValue * (10/100);
Register_1<= conv_std_logic_vector(ValueKl, 4);
Register_2<= conv_std_logic_vector(ValueGr, 4);
Register_3 <= '1' & Register_1 & Register_2 & '0';
State <= GOT2;
when GOT2 =>
Data_uit<=Register_3(regVar);
regVar := regVar - 1;
if regVar = 0 then
State <= GOT0;
regVar := 9;
end if;
when others => State <= GOT0;
end case;
end if;
if Button = '1' then
Value:= 26;
State <= GOT1;
end if;
if Reset = '1' then

end if;
end process;



Yama
  Reply With Quote
Old 06-05-2006, 01:18 PM   #3
Yama
 
Posts: n/a
Default Re: 8 bit binary to 2 digit BCD
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.NUMERIC_STD.ALL;

entity BtoB is
Port ( Data_in : in STD_LOGIC_VECTOR (7 downto 0);
Clk : in STD_LOGIC;
Reset : in STD_LOGIC;
Button : in STD_LOGIC;
Busy : out STD_LOGIC;
Data_uit : out STD_LOGIC;
end BtoB;

architecture Gedrag of BtoB is

shared variable Value: integer;
shared variable ValueGr: integer;
shared variable ValueKl: integer;


signal Register_1: STD_LOGIC_VECTOR(3 downto 0);
signal Register_2: STD_LOGIC_VECTOR(3 downto 0);
signal Register_3: STD_LOGIC_VECTOR(9 downto 0);

type STATE_T is (GOT0,GOT1,GOT2,GOT03,GOT4);
signal State: STATE_T;


begin

----------------------------------------------------------------------
-- Verwerk_dat_in
----------------------------------------------------------------------
Verwerk_data_in: process(Clk, Data_in,Button, Reset,Counter)

begin
if Clk ' event and Clk = '1' then
case State is
when GOT0 =>
null;
when GOT1 =>
ValueKl:= Value mod 10;
-- TempValue:= Value - ValueKl;
-- ValueGr := TempValue * (10/100);
Register_1<= conv_std_logic_vector(ValueKl, 4);
Register_2<= conv_std_logic_vector(ValueGr, 4);
Register_3 <= '1' & Register_1 & Register_2 & '0';
State <= GOT2;
when GOT2 =>
Data_uit<=Register_3(regVar);
regVar := regVar - 1;
if regVar = 0 then
State <= GOT0;
regVar := 9;
end if;
when others => State <= GOT0;
end case;
end if;
if Button = '1' then
Value:= 26;
State <= GOT1;
end if;
if Reset = '1' then

end if;
end process;



Yama
  Reply With Quote
Old 06-09-2006, 08:48 PM   #4
Dave Pollum
 
Posts: n/a
Default Re: 8 bit binary to 2 digit BCD
Yama wrote:
> library IEEE;
> use IEEE.STD_LOGIC_1164.ALL;
> use IEEE.STD_LOGIC_ARITH.ALL;
> use IEEE.STD_LOGIC_UNSIGNED.ALL;
> use IEEE.NUMERIC_STD.ALL;
>
> entity BtoB is
> Port ( Data_in : in STD_LOGIC_VECTOR (7 downto 0);
> Clk : in STD_LOGIC;
> Reset : in STD_LOGIC;
> Button : in STD_LOGIC;
> Busy : out STD_LOGIC;
> Data_uit : out STD_LOGIC;
> end BtoB;
>
> architecture Gedrag of BtoB is
>
> shared variable Value: integer;
> shared variable ValueGr: integer;
> shared variable ValueKl: integer;
>
>
> signal Register_1: STD_LOGIC_VECTOR(3 downto 0);
> signal Register_2: STD_LOGIC_VECTOR(3 downto 0);
> signal Register_3: STD_LOGIC_VECTOR(9 downto 0);
>
> type STATE_T is (GOT0,GOT1,GOT2,GOT03,GOT4);
> signal State: STATE_T;
>
>
> begin
>
> ----------------------------------------------------------------------
> -- Verwerk_dat_in
> ----------------------------------------------------------------------
> Verwerk_data_in: process(Clk, Data_in,Button, Reset,Counter)
>
> begin
> if Clk ' event and Clk = '1' then
> case State is
> when GOT0 =>
> null;
> when GOT1 =>
> ValueKl:= Value mod 10;
> -- TempValue:= Value - ValueKl;
> -- ValueGr := TempValue * (10/100);
> Register_1<= conv_std_logic_vector(ValueKl, 4);
> Register_2<= conv_std_logic_vector(ValueGr, 4);
> Register_3 <= '1' & Register_1 & Register_2 & '0';
> State <= GOT2;
> when GOT2 =>
> Data_uit<=Register_3(regVar);
> regVar := regVar - 1;
> if regVar = 0 then
> State <= GOT0;
> regVar := 9;
> end if;
> when others => State <= GOT0;
> end case;
> end if;
> if Button = '1' then
> Value:= 26;
> State <= GOT1;
> end if;
> if Reset = '1' then
>
> end if;
> end process;


To find out how to convert binary to decimal, do a search in this
newsgroup for "binary to decimal" or "binary to BCD". Also, it's best
to only use the libraries: STD_LOGIC_1164 and NUMERIC_STD, and to not
use STD_LOGIC_ARITH and STD_LOGIC_UNSIGNED.
BTW, what happens when Reset is '1'? Usually the starting state is
assigned, for example:

if Reset = '1' then
State <= GOT0;
elsif rising_edge( clk ) then
case State is
...
end case;
end if;



Dave Pollum
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
image (jpg,bmp,gif, etc.) convert to equivalent binary representation using vb.net? archieSupremo Software 0 09-06-2009 12:20 PM
reading mp3 file in binary format in vhdl latheesh General Help Related Topics 0 02-05-2008 05:40 AM
dvd in binary newsgroups gord1234@yahoo.com DVD Video 1 11-06-2005 09:46 AM
Counting In Binary Raymond A+ Certification 13 03-07-2004 07:28 PM
POLL: BEST BINARY PROG Jet DVD Video 0 01-26-2004 09:35 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46