将整数值转换为ASCII字符-VHDL

将整数值转换为ASCII字符-VHDL,vhdl,hardware,Vhdl,Hardware,我需要在2x16显示器上显示一些整数值,但显示器只能识别ASCII字符。所以,在我向显示器发送一些值之前,我需要将其转换为字符串。。。有IDE吗 非常感谢 也许查阅一下表格会很有用。将ASCII字符存储在某个位置,并使用一种方法将ASCII映射到您的“整数”。我想您使用的是标准整数类型?无论哪种方式,它当前的格式都应该能够以某种方式映射到ASCII(如果尚未映射到ASCII)。有一种方法可以做到这一点。所以在开始的时候,你需要将整数转换成一个std_逻辑_向量,然后将该值转换成一个BCD系统,这

我需要在2x16显示器上显示一些整数值,但显示器只能识别ASCII字符。所以,在我向显示器发送一些值之前,我需要将其转换为字符串。。。有IDE吗


非常感谢

也许查阅一下表格会很有用。将ASCII字符存储在某个位置,并使用一种方法将ASCII映射到您的“整数”。我想您使用的是标准整数类型?无论哪种方式,它当前的格式都应该能够以某种方式映射到ASCII(如果尚未映射到ASCII)。

有一种方法可以做到这一点。所以在开始的时候,你需要将整数转换成一个std_逻辑_向量,然后将该值转换成一个BCD系统,这样你就有了一个整数值的每个数字的二进制值。然后只需将每个数字的ASCII值保存到std_logic_vector-s数组中,这样您就可以显示它们

type     x_digits is array ( 3 downto 1) of natural;
signal   x_digit_tb : x_digits;
constant d0 : std_logic_vector (7 downto 0) := "00110000"; -- \\
constant d1 : std_logic_vector (7 downto 0) := "00110001"; -- ||
constant d2 : std_logic_vector (7 downto 0) := "00110010"; -- ||
constant d3 : std_logic_vector (7 downto 0) := "00110011"; -- ||
constant d4 : std_logic_vector (7 downto 0) := "00110100"; -- \\
constant d5 : std_logic_vector (7 downto 0) := "00110101"; --  >> Constant ASCII-binary value of digits 0 to 9
constant d6 : std_logic_vector (7 downto 0) := "00110110"; -- //
constant d7 : std_logic_vector (7 downto 0) := "00110111"; -- ||
constant d8 : std_logic_vector (7 downto 0) := "00111000"; -- ||
constant d9 : std_logic_vector (7 downto 0) := "00111001"; -- //
.
.
  process(CLK)
          ----- Convert X to BCD -----
          if CLK'event and clk = '1' and dX0 = 1 then
                x_shift(7 downto 0) := x_ein_local;
                for l in 0 to 7 loop
                    x_shift := x_shift sll 1;
                    if  l < 7 and x_shift(11 downto 8) > "0100" then
                        x_shift(11 downto  8) := x_shift(11 downto  8) + "0011";
                    end if;
                    if  l < 7 and x_shift(15 downto 12) > "0100" then
                        x_shift(15 downto 12) := x_shift(15 downto 12) + "0011";
                    end if;
                    if  l < 7 and x_shift(19 downto 16) > "0100" then
                        x_shift(19 downto 16) := x_shift(19 downto 16) + "0011";
                    end if;
                end loop;
                x_BCD <= x_shift(19 downto  8);
                x_shift := (others => '0');
                dX0 <= 2;
            ---- Convert X to ASCII --------    
            if CLK'event and clk = '1' and dX0 = 2 then
                for k in 1 to 3 loop
                    case k is
                        when 1 => WW := x_BCD( 3 downto  0);
                        when 2 => WW := x_BCD( 7 downto  4);
                        when 3 => WW := x_BCD(11 downto  8);
                    end case;
                    case WW is
                        when "0000" => x_digit(k) <= d0;
                        when "0001" => x_digit(k) <= d1;
                        when "0010" => x_digit(k) <= d2;
                        when "0011" => x_digit(k) <= d3;
                        when "0100" => x_digit(k) <= d4;
                        when "0101" => x_digit(k) <= d5;
                        when "0110" => x_digit(k) <= d6;
                        when "0111" => x_digit(k) <= d7;
                        when "1000" => x_digit(k) <= d8;
                        when "1001" => x_digit(k) <= d9;
                        when others => null;
                    end case;   
                end loop;
                dX0 <= 3;
            end if;
        end if;
 end process;
类型x_数字是自然数的数组(3到1);
信号x_位\u tb:x_位;
常数d0:std_逻辑_向量(7到0):=“00110000”——\\
常数d1:std_逻辑_向量(7到0):=“00110001”——||
常数d2:std_逻辑_向量(7到0):=“00110010”——||
常数d3:std_逻辑_向量(7到0):=“00110011”——||
常数d4:std_逻辑_向量(7到0):=“00110100”——\\
常数d5:std_逻辑_向量(7到0):=“00110101”-->数字0到9的恒定ASCII二进制值
常数d6:std_逻辑_向量(7到0):=“00110110”——//
常数d7:std_逻辑_向量(7到0):=“00110111”——||
常数d8:std_逻辑_向量(7到0):=“00111000”——||
常数d9:std_逻辑_向量(7到0):=“00111001”——//
.
.
过程(CLK)
-----将X转换为BCD-----
如果CLK'事件且CLK='1'且dX0=1,则
x_移位(7向下到0):=x_ein_local;
对于0到7循环中的l
x_移位:=x_移位sll 1;
如果l<7且x_移位(11向下移动至8)>“0100”,则
x_移位(11向下至8):=x_移位(11向下至8)+“0011”;
如果结束;
如果l<7且x_移位(15向下至12)>“0100”,则
x_移位(15向下至12):=x_移位(15向下至12)+“0011”;
如果结束;
如果l<7且x_移位(19向下至16)>“0100”,则
x_移位(19向下至16):=x_移位(19向下至16)+“0011”;
如果结束;
端环;
x_BCD“0”);

dX0字符的
'pos
'val
属性在这里很有用:答案的剩余部分是“一次一位数”。这只是一个简单的编程。使用整数到BCD的转换可能也很有用。实际上我需要使用实数,但由于无法将数字转换为标准整数,将浮点移到末尾,然后我需要将inter转换为字符串,以便在显示器上显示它。。。查找表的想法是解决这个问题的好方法,但我正在寻找一些自动执行此操作的函数(例如,将整数转换为STD_逻辑_向量的函数)。。。