Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
318 views
in Technique[技术] by (71.8m points)

How to convert from integer to Binary in vhdl

I want to convert my Int input to Binary Input This is My Code

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;



entity test is
    Port ( A : in  integer;
           B : in  integer;
           Z : out  STD_LOGIC_VECTOR(7 downto 0)
              );
end test;

architecture Behavioral of test is
begin


end Behavioral;

and i want to convert A , B to binary how can i do that ? and then i want to make an output Z to Dynamic Output


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

First decide your choice of binary representation.

Then see if there's a standard library that supports that one.

If so, there will probably be type conversion operations between integers and those representations, for whatever width of binary output you choose.

The IEEE.numeric_std library supports two commonly used representations, with all the operators and conversions you need.

If you chose a different representation (like sign+magnitude for example) you may have to write your own library along the same lines as IEEE.numeric_std. Most people don't do that.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...