基于fpga的波形发生器、频率计和数字电压表毕业设计内容摘要:

ck1=lock1,start=start,oe=oe,ale=ale,access1=access1, dd1=data1,dd2=data2,dd3=data3,dd4=data4,dd5=data5,dd6=data6)。 u2:lcd port map(reset=reset,clk=clk,d1=data1,d2=data2,d3=data3, d4=data4,d5=data5,d6=data6,data=data,lcdda=lcdda,lcdrw=lcdrw,lcden=lcden)。 end Behavioral。 ADC0809 驱动 library IEEE。 use。 use。 use。 entity ad is Port (clk,reset,eoc:in std_logic。 clk50mhz是外部 32MHZ 时钟信号 d:in std_logic_vector(7 downto 0)。 ADC0809 的 8 位转换数据输出 lock1,start,oe,ale:out std_logic。 access1:out std_logic_vector(2 downto 0)。 输出到 ADC0809的控制信号 dd1,dd2,dd3,dd4,dd5,dd6: out std_logic_vector(3 downto 0))。 最终输出信号 end ad。 architecture Behavioral of ad is signal lock: std_logic。 signal qq:std_logic_vector(7 downto 0)。 type state is (st0,st1,st2,st3)。 signal current_state1:state。 type states is (st0,st1,st2,st3,st4,st5,st6)。 定义 7 个状态子类型 signal state1,state2:states:=st0。 初始化 states signal reg:std_logic_vector(7 downto 0)。 signal clk10k: std_logic。 signal access2: std_logic_vector(2 downto 0)。 signal reg2,reg1,regg,reg3: integer range 255 downto 0。 signal oe1:std_logic。 type states1 is (st0,st1)。 signal states2:states1:=st0。 begin process(clk,reset) fen pin 5k variable t: integer range 2500 downto 0。 begin if reset=39。 039。 then t:=0。 clk10k=39。 039。 elsif rising_edge(clk) then t:=t+1。 if t=2500 then clk10k=39。 139。 t:=0。 else clk10k=39。 039。 end if。 end if。 end process。 pro1:process(state1,eoc,d) 进程 2,主控组合和时序进程,规定各个状态转换方式 begin case state1 is when st0=state2=st1。 ale=39。 039。 start=39。 039。 oe=39。 039。 oe1=39。 039。 when st1=state2=st2。 ale=39。 139。 start=39。 039。 oe=39。 039。 when st2=state2=st3。 ale=39。 039。 start=39。 139。 oe=39。 039。 when st3= ale=39。 039。 start=39。 039。 oe=39。 039。 if eoc=39。 139。 then state2=st3。 测试 eoc 的下降沿 else state2=st4。 end if。 when st4= ale=39。 039。 start=39。 039。 oe=39。 039。 测试 eoc 的上升沿, =1 表明转换结束 if eoc=39。 039。 then state2=st4。 继续等待 else state2=st5。 end if。 when st5=state2=st6。 ale=39。 039。 start=39。 039。 oe=39。 139。 when st6=state2=st0。 ale=39。 039。 start=39。 039。 oe=39。 139。 reg=d。 oe1=39。 139。 when others=state2=st0。 ale=39。 039。 start=39。 039。 oe=39。 039。 end case。 end process。 process(clk,lock) begin if clk39。 event and clk=39。 139。 then qq=qq+1。 if qq=01111111 then lock=39。 139。 state1=state2。 01111111 elsif qq01111111 then lock=39。 039。 end if。 end if。 end process。 pro2:process(clk10k,reset,access2) begin if reset=39。 039。 then access2=000。 elsif rising_edge(clk10k) then case states2 is when st0= if regg=reg3 then states2=st0。 else states2=st1。 end if。 when st1= access2=011。 when others=states2=st0。 end case。 case access2 is when 011 = if regg=127 then access2=010。 else reg2=regg。 end if。 reg3=regg。 when 010 =if regg=102 then access2=001。 else reg2=regg。 end if。 reg3=regg。 when 001= if regg=127 then access2=000。 else reg2=regg。 end if。 reg3=regg。 reg2=regg。 reg3=regg。 when 000 = when others =null。 end case。 end if。 access1=access2。 end process。 lock1=lock。 reg2=conv_integer(reg)。 十进制- BCD 码转换; process(clk10k) variable reg1 : integer range 0 to 800000。 variable d1,d2,d3,d4,d5,d6 : std_logic_vector(3 downto 0)。 begin access2=000。 if reset=39。 039。 then d1:=0000。 d2:=0000。 d3:=0000。 d4:=0000。 d5:=0000。 d6:=0000。 if clk10k39。 event and clk10k=39。 139。 then case current_state1 is when st0=access1=access2。 if oe1=39。 139。 then current_state1=st1。 end if。 when st1= case access1 is when 011 = reg1:=reg2*1961。 1960 when 010 = reg1:=reg2*980。 980 980 when 001 = reg1:=reg2*392。 392 392 reg1:=reg2*196。 196 when 000 = when others=null。 end case。 d1:=0000。 d2:=0000。 d3:=0000。 d4:=0000。 d5:=0000。 d6:=0000。 current_state1=st2。 when st2= if reg199999 then reg1:=reg1100000。 d1:=d1+1。 elsif reg19999 then reg1:=reg110000。 d2:=d2+1。 elsif reg1999 then reg1:=reg11000。 d3:=d3+1。 elsif reg199 then reg1:=reg1100。 d4:=d4+1。 elsif reg19 then reg1:=reg110。 d5:=d5+1。 elsif reg10 then reg1:=reg11。 d6:=d6+1。 else current_state1=st3。 end if。 when st3= access2=011。 dd1=d1。 dd2=d2。 dd3=d3。 dd4=d4。 dd5=d5。 dd6=d6。 current_state1=st0。 when others= current_state1=st0。 end case。 end if。 end if。 end process。 end Behavioral。 LCD 驱动 程序 library IEEE。 use。 use。 use。 Unment the following lines to use the declarations that are provided for instantiating Xilinx primitive ponents. library UNISIM。 use。 entity lcd is generic(N:integer:=5000。 delay:integer:=100)。 Port ( clk,reset: in std_logic。 d1,d2,d3,d4,d5,d6: in std_logic_vector(3 downto 0)。 lcdda : out std_logic。 lcdrw : out std_logic。 lcden : out std_logic。 data : inout std_logic_vector(7 downto 0) )。 end lcd。 architecture Behavioral of lcd is type state is (set_dlnf,clear_lcd,set_cursor,set_dcb,set_location_cgram,write_data_cgram,set_location,write_data, set_location2,wri。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。