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

Reply

VHDL - Decimal to binary for comparison

 
Thread Tools Search this Thread
Old 05-23-2008, 04:20 PM   #1
Default Decimal to binary for comparison


Hi

I have a simple question. I have a 16-bit register that stores me the
information about the usage of 16 registers. If a bit is set the
register is locked else its free to use. Next, I read then in a value
that wants to use one of the registers. The value is a decimal number
between 0 and 15, so I wonder if VHDL offers an easy way to convert from
decimal to binary so that I can compare then values with an AND mask.
This the thing should also be sythesizable on an XIlinx FPGA

Thanks,
Klaus


Klaus Thiele
  Reply With Quote
Old 05-23-2008, 04:40 PM   #2
Mike Treseler
 
Posts: n/a
Default Re: Decimal to binary for comparison
Klaus Thiele wrote:

> The value is a decimal number
> between 0 and 15, so I wonder if VHDL offers an easy way to convert from
> decimal to binary so that I can compare then values with an AND mask.
> This the thing should also be sythesizable on an XIlinx FPGA


I would declare that natural range as a subtype
and use a constant or variable of that subtype
for the comparison. Synthesis will work out
the details.

-- Mike Treseler


Mike Treseler
  Reply With Quote
Old 05-23-2008, 04:42 PM   #3
KJ
 
Posts: n/a
Default Re: Decimal to binary for comparison
On May 23, 11:20*am, Klaus Thiele <Thiel...@gmx.de> wrote:
> Hi
>
> I have a simple question. I have a 16-bit register that stores me the
> information about the usage of 16 registers. If a bit is set the
> register is locked else its free to use. Next, I read then in a value
> that wants to use one of the registers. The value is a decimal number
> between 0 and 15, so I wonder if VHDL offers an easy way to convert from
> decimal to binary so that I can compare then values with an AND mask.
> This the thing should also be sythesizable on an XIlinx FPGA
>


Perhaps you should go back and rethink your question. Inside an FPGA
you only have binary logic, there is no decimal so the number you
'read in' will not be decimal.

Probably what you're trying to say is that you've got a number in the
range 0 to 15 (most likely represented inside the FPGA as a 4 bit
binary number) and you want to decode to select one of 16 different
things. In that case, Google for 4->16 decoders, de-multiplexers,
etc. You'll likely implement something like this...

process
begin
Select_This <= (others => '0');
Select_This(Index) <= '1'
end process;


KJ
  Reply With Quote
Old 05-23-2008, 04:45 PM   #4
Klaus Thiele
 
Posts: n/a
Default Re: Decimal to binary for comparison
> Probably what you're trying to say is that you've got a number in the
> range 0 to 15 (most likely represented inside the FPGA as a 4 bit
> binary number) and you want to decode to select one of 16 different
> things. In that case, Google for 4->16 decoders, de-multiplexers,
> etc. You'll likely implement something like this...
>
> process
> begin
> Select_This <= (others => '0');
> Select_This(Index) <= '1'
> end process;


Yes, that it is what I am looking for! A 4->16 decoder




Klaus Thiele
  Reply With Quote
Old 05-23-2008, 05:22 PM   #5
Klaus Thiele
 
Posts: n/a
Default Re: Decimal to binary for comparison

> process
> begin
> Select_This <= (others => '0');
> Select_This(Index) <= '1'
> end process;


that looks like a nice one

process (A, E)
begin
if (E='0') then
D <= "0000000000000000";
else
case A is
when "0000" =>
D <= "0000000000000001";
when "0001" =>
D <= "0000000000000010";
when "0010" =>
D <= "0000000000000100";
when "0011" =>
D <= "0000000000001000";
when "0100" =>
D <= "0000000000010000";
when "0101" =>
D <= "0000000000100000";
when "0110" =>
D <= "0000000001000000";
when "0111" =>
D <= "0000000010000000";
when "1000" =>
D <= "0000000100000000";
when "1001" =>
D <= "0000001000000000";
when "1010" =>
D <= "0000010000000000";
when "1011" =>
D <= "0000100000000000";
when "1100" =>
D <= "0001000000000000";
when "1101" =>
D <= "0010000000000000";
when "1110" =>
D <= "0100000000000000";
when "1111" =>
D <= "1000000000000000";
when others =>
D <= "0000000000000000";
end case;
end if;
end process;
end Behavioral;

http://toolbox.xilinx.com/docsan/xil...b0126_110.html


Klaus Thiele
  Reply With Quote
Old 05-24-2008, 08:42 PM   #6
jeppe
Senior Member
 
Join Date: Mar 2008
Location: Denmark
Posts: 245
Default
Well this page gives a metode (hmmm) for bin to bcd but the same circuit can be used for bcd to bin
http://www.jjmk.dk/MMMI/Lessons/06_A...sion/Index.htm

Your welcome
Jeppe


jeppe
jeppe is offline   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
how to round off decimal point arianne75 General Help Related Topics 0 06-08-2007 07:17 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




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