|
中文部分的实现原理与英文部分大体相同,但是由于VHDL中无法识别中文,因此在使用上不可能做到和英文一样方便。使用时需要参照中文字符表,将需要的字符所对应的数据输入RAM,然后通和英文模块不重复的符号来实现对其的调用。如 “贾”这个中文字符,所对应的数据为16#BCD6,因此在函数部分应为:
when '@' => result := 16#BC#;
when '#' => result := 16#D6#;
调用时的只需将@和#这两个符号来代替中文字符即可
when "000000" =>data<=conv_std_logic_vector (char_to_integer ('@'),8);
when "000001" =>data<=conv_std_logic_vector (char_to_integer ('#'),8);
但是还是遇到问题了,求指教:
附汉字显示的VHDL程序(有问题提示 怎么修改?)
新手急求!
附汉字程序有问题,求分析!
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
package packexp is
function char_to_integer(indata : character) return integer ;
end;
package BODY packexp is
function char_to_integer(indata : character) return integer is
variable result : integer range 0 to 16#FF#;
begin
case indata is
when '@' => result := 16#D7#;
when '#' => result := 16#F6#;
when '@@' => result := 16#D7#;
when '##' => result := 16#FE#;
when '@@@' => result := 16#BA#;
when '###' => result := 16#C3#;
when '@@@@' => result := 16#B5#;
when '####' => result := 16#C4#;
when '@@@@@' => result := 16#D7#;
when '#####' => result := 16#D4#;
when '@@@@@' => result := 16#BC#;
when '#####' => result := 16#BA#;
when '@@@@@@@' => result := 16#A3#;
when '#######' => result := 16#AC#;
when '$' => result := 16#C8#;
when '%' => result := 16#CA#;
when '$$' => result := 16#B4#;
when '%%' => result := 16#C8#;
when '$$$' => result := 16#B5#;
when '%%%' => result := 16#C4#;
when '$$$$' => result := 16#CA#;
when '%%%%' => result := 16#A8#;
when '$$$$$' => result := 16#D7#;
when '%%%%%' => result := 16#D3#;
when '$$$$$$' => result := 16#A3#;
when '%%%%%%' => result := 16#A1#;
when others => result := 16#20#;
end case;
return result;
end function;
end;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use work.packexp.all;
entity HZXS is
port ( clk : in std_logic;
address : in std_logic_vector(5 downto 0);
data: out std_logic_vector(7 downto 0) );
end YWZF;
architecture D of HZXS is
begin
process(clk,address)
begin
if clk'event and clk='1' then
case address is
when "000000" =>data<=conv_std_logic_vector (char_to_integer ('@'),8);
when "000001" =>data<=conv_std_logic_vector (char_to_integer ('#'),8);
when "000010" =>data<=conv_std_logic_vector (char_to_integer ('@@'),8);
when "000011" =>data<=conv_std_logic_vector (char_to_integer ('##'),8);
when "000100" =>data<=conv_std_logic_vector (char_to_integer ('@@@'),8);
when "000101" =>data<=conv_std_logic_vector (char_to_integer ('###'),8);
when "000110" =>data<=conv_std_logic_vector (char_to_integer ('@@@@'),8);
when "000111" =>data<=conv_std_logic_vector (char_to_integer ('####'),8);
when "001000" =>data<=conv_std_logic_vector (char_to_integer ('@@@@@'),8);
when "001001" =>data<=conv_std_logic_vector (char_to_integer ('#####'),8);
when "001010" =>data<=conv_std_logic_vector (char_to_integer ('@@@@@@'),8);
when "001011" =>data<=conv_std_logic_vector (char_to_integer ('######'),8);
when "001100" =>data<=conv_std_logic_vector (char_to_integer ('@@@@@@@'),8);
when "001101" =>data<=conv_std_logic_vector (char_to_integer ('#######'),8);
when "001110" =>data<=conv_std_logic_vector (char_to_integer ('$'),8);
when "001111" =>data<=conv_std_logic_vector (char_to_integer ('%'),8);
when "010000" =>data<=conv_std_logic_vector (char_to_integer ('$$'),8);
when "010001" =>data<=conv_std_logic_vector (char_to_integer ('%%'),8);
when "010010" =>data<=conv_std_logic_vector (char_to_integer ('$$$'),8);
when "010011" =>data<=conv_std_logic_vector (char_to_integer ('%%%'),8);
when "010100" =>data<=conv_std_logic_vector (char_to_integer ('$$$$'),8);
when "010101" =>data<=conv_std_logic_vector (char_to_integer ('%%%%'),8);
when "010110" =>data<=conv_std_logic_vector (char_to_integer ('$$$$$'),8);
when "010111" =>data<=conv_std_logic_vector (char_to_integer ('%%%%%'),8);
when "011000" =>data<=conv_std_logic_vector (char_to_integer ('$$$$$$'),8);
when "011001" =>data<=conv_std_logic_vector (char_to_integer ('%%%%%%'),8);
when others =>data<=conv_std_logic_vector (char_to_integer (' '),8);
end case;
end if;
end process;
end D;
预期汉字显示为: 做最好的自己,
仁慈的狮子!