硬件:音频A律与PCM码之间转换的VHDL的实现A律是按一定规律对PCM码取对数,由于CPLD的强项在于控制,而不是运算,所以在此,我使
用了查表的方法对A律进行了解码。程序如下:
read: process(countr,shou)
variable zhong1: std_logic_vector(7 downto 0);
variable jishu: std_logic_vector(2 downto 0);
begin
if countr < 8 then
shou(countr)<=AM_TX_DO;
end if;
if countr = 0 then
zhong1(7 downto 0) :=shou(6 downto 0)&'0' xor "10101011";
jishu :=zhong1(7 downto 5)-1;
case jishu is
when "000"=>zhong2 <=shou(7) & "0000001" & zhong1(4 downto 0);
when "001"=>zhong2 <=shou(7) & "000001" & zhong1(4 downto 0) & '0';
when "010"=>zhong2 <=shou(7) & "00001" & zhong1(4 downto 0) & "00";
when "011"=>zhong2 <=shou(7) & "0001" & zhong1(4 downto 0) & "000";
when "100"=>zhong2 <=shou(7) & "001" & zhong1(4 downto 0) & "0000";
when "101"=>zhong2 <=shou(7) & "01" & zhong1(4 downto 0) & "00000";
when "110"=>zhong2 <=shou(7) & '1' & zhong1(4 downto 0) & "000000";
when others=>zhong2 <=shou(7) & "0000000"& zhong1(4 downto 0);
end case;
end if;
end process read;