【正文】
(11 DOWNTO 8))+(39。039。amp。 16位BCD碼中的(118位)相加,和大于9進1 sum3=(39。 ELSE c2=00001。data0(7 DOWNTO 4))+c1。039。amp。data2(7 DOWNTO 4))+(39。039。 END IF。 IF sum101010 THEN c1=00000。amp。data1(3 DOWNTO 0))+(39。039。amp。 將高,中,低分別代表的16位BCD(表示為150位)進行加法運算16位BCD碼中的(30位)相加,和大于9進1 sum1=(39。 WHEN OTHERS= data0 = NULL。 WHEN 1110= data0 = 0000000000001000。 WHEN 1100= data0 = 0000000000000111。 WHEN 1010= data0 = 0000000000000110。 WHEN 1000= data0 = 0000000000000101。 WHEN 0110= data0 = 0000000000000100。 WHEN 0100= data0 = 0000000000000010。 WHEN 0010= data0 = 0000000000000001。將低四位二進制數(shù)據(jù)所代表的電壓值轉(zhuǎn)換為16位BCD碼 CASE datain(3 DOWNTO 0) IS WHEN 0000= data0 = 0000000000000000。 WHEN OTHERS= data1 = NULL。 WHEN 1110= data1 = 0000000100110100。 WHEN 1100= data1 = 0000000100010101。 WHEN 1010= data1 = 0000000010010110。 WHEN 1000= data1 = 0000000001110111。 WHEN 0110= data1 = 0000000001011000。 WHEN 0100= data1 = 0000000000111000。 WHEN 0010= data1 = 0000000000011001。將中四位二進制數(shù)據(jù)所代表的電壓值轉(zhuǎn)換為16位BCD碼 CASE datain(7 DOWNTO 4) IS WHEN 0000= data1 = 0000000000000000。 WHEN OTHERS= data2 = NULL。 WHEN 1110= data2 = 0010000101010000。 WHEN 1100= data2 = 0001100001000011。 WHEN 1010= data2 = 0001010100110110。 WHEN 1000= data2 = 0001001000101001。 WHEN 0110= data2 = 0000100100100010。 WHEN 0100= data2 = 0000011000010100。 WHEN 0010= data2 = 0000001100000111。 if (flag=1 and r=0)or(flag=0 and r=1) then –當狀態(tài)為01,10時,開始數(shù)據(jù)轉(zhuǎn)換 將高四位二進制數(shù)據(jù)所代表的電壓值轉(zhuǎn)換為16位BCD碼 CASE datain(11 DOWNTO 8) IS WHEN 0000= data2 = 0000000000000000。 end if。 end if。039。 if (f_reset39。 end if。 end if。139。p3:PROCESS(datain,f_en,f_reset) reset,en組合的4個狀態(tài)00,01,10,11轉(zhuǎn)移關系 BEGIN if (f_en39。 f_reset=clk and reset1 and (not reset2)。 end if。 en2=en1。 then reset2=reset1。event and clk=39。 signal reset1,reset2,f_reset:std_logic。 signal r:integer range 0 to 1。 SIGNAL c1,c2,c3:STD_LOGIC_VECTOR(4 DOWNTO 0)。ARCHITECTURE behave OF deal IS SIGNAL data0,data1,data2:STD_LOGIC_VECTOR(15 DOWNTO 0)。 d2,d3,d4:OUT STD_LOGIC_VECTOR(3 DOWNTO 0))。 reset: in std_logic。 datain:IN STD_LOGIC_VECTOR(11 DOWNTO 0)。USE 。USE 。end behave。 end process。 end if。 t=1時下一次轉(zhuǎn)換開始,cs變?yōu)榈碗娖? when others=null。 t=0時一次轉(zhuǎn)換結(jié)束,cs變?yōu)楦唠娖? when 1=temp_cs=39。 then case t is when 0=temp_cs=39。event and clk=39。 end if。 else t=0。 end case。 da_out=data_out。 when 14=data_out(1)=ad_dat。 when 12=data_out(3)=ad_dat。 when 10=data_out(5)=ad_dat。 when 8=data_out(7)=ad_dat。 when 6=data_out(9)=ad_dat。 then 將ADS輸出的12位串行二進制數(shù)據(jù)轉(zhuǎn)換為12位并行二進制數(shù)據(jù) case t is when 4=data_out(11)=ad_dat。event and clk=39。 end if。139。 p2:process(f_en,clk,oe) begin if (f_en39。 end process。