| ²é¿´: 2095 | »Ø¸´: 2 | |||
fxx5013572гæ (³õÈëÎÄ̳)
|
[ÇóÖú]
VHDL״̬»úA/D²ÉÑù¿ØÖƵç·ʵÏÖ
|
(ÀÏʦ˵³ÌÐòÓдí Çë¸ßÊÖÖ¸µã!лл! Çë°ïæ¸ø¸öÕýÈ·µÄ³ÌÐò! ÄöÊäÈëÐèÒª×Ô¼ºÉèÖõÄ???)LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; ENTITY ADCINT IS PORT(D : IN STD_LOGIC_VECTOR(7 DOWNTO 0); --À´×Ô0809ת»»ºÃµÄ8λÊý¾Ý CLK : IN STD_LOGIC; --״̬»ú¹¤×÷ʱÖÓ EOC : IN STD_LOGIC; --ת»»×´Ì¬Ö¸Ê¾£¬µÍµçƽ±íʾÕýÔÚת»» ALE : OUT STD_LOGIC; --8¸öÄ£ÄâÐźÅͨµÀµØÖ·Ëø´æÐźŠSTART : OUT STD_LOGIC; --ת»»¿ªÊ¼ÐźŠOE : OUT STD_LOGIC; --Êý¾ÝÊä³ö3̬¿ØÖÆÐźŠADDA : OUT STD_LOGIC; --ÐźÅͨµÀ×îµÍλ¿ØÖÆÐźŠLOCK0 : OUT STD_LOGIC; --¹Û²ìÊý¾ÝËø´æÊ±ÖÓ Q : OUT STD_LOGIC_VECTOR(7 DOWNTO 0)); --8λÊý¾ÝÊä³ö END ADCINT; ARCHITECTURE behav OF ADCINT IS TYPE states IS (st0, st1, st2, st3,st4) ; --¶¨Òå¸÷״̬×ÓÀàÐÍ SIGNAL current_state, next_state: states :=st0 ; SIGNAL REGL : STD_LOGIC_VECTOR(7 DOWNTO 0); SIGNAL LOCK : STD_LOGIC; -- ת»»ºóÊý¾ÝÊä³öËø´æÊ±ÖÓÐźŠBEGIN ADDA <= '1';--µ±ADDA<='0'£¬Ä£ÄâÐźŽøÈëͨµÀIN0£»µ±ADDA<='1'£¬Ôò½øÈëͨµÀIN1 Q <= REGL; LOCK0 <= LOCK ; COM: PROCESS(current_state,EOC) BEGIN --¹æ¶¨¸÷״̬ת»»·½Ê½ CASE current_state IS WHEN st0=>ALE<='0';START<='0';LOCK<='0';OE<='0'; next_state <= st1; --0809³õʼ»¯ WHEN st1=>ALE<='1';START<='1';LOCK<='0';OE<='0'; next_state <= st2; --Æô¶¯²ÉÑù WHEN st2=> ALE<='0';START<='0';LOCK<='0';OE<='0'; IF (EOC='1') THEN next_state <= st3; --EOC=1±íÃ÷ת»»½áÊø ELSE next_state <= st2; END IF ; --ת»»Î´½áÊø£¬¼ÌÐøµÈ´ý WHEN st3=> ALE<='0';START<='0';LOCK<='0';OE<='1'; next_state <= st4;--¿ªÆôOE,Êä³öת»»ºÃµÄÊý¾Ý WHEN st4=> ALE<='0';START<='0';LOCK<='1';OE<='1'; next_state <= st0; WHEN OTHERS => next_state <= st0; END CASE ; END PROCESS COM ; REG: PROCESS (CLK) BEGIN IF (CLK'EVENT AND CLK='1') THEN current_state<=next_state; END IF; END PROCESS REG ; -- ÓÉÐźÅcurrent_state½«µ±Ç°×´Ì¬Öµ´ø³ö´Ë½ø³Ì:REG LATCH1: PROCESS (LOCK) -- ´Ë½ø³ÌÖУ¬ÔÚLOCKµÄÉÏÉýÑØ£¬½«×ª»»ºÃµÄÊý¾ÝËøÈë BEGIN IF LOCK='1' AND LOCK'EVENT THEN REGL <= D ; END IF; END PROCESS LATCH1 ; END behav;[ Last edited by fxx5013572 on 2011-8-31 at 10:02 ] |
» ÊÕ¼±¾ÌûµÄÌÔÌûר¼ÍƼö
ÎÒºÍÎÒרҵµÄÄÇЩÊ |
» ²ÂÄãϲ»¶
²ÄÁÏ/ũҵרҵ£¬07/08¿ªÍ·¾ù¿É£¬¹ýÏß¾ÍÐÐ
ÒѾÓÐ4È˻ظ´
327Çóµ÷¼Á
ÒѾÓÐ5È˻ظ´
361Çóµ÷¼Á
ÒѾÓÐ3È˻ظ´
Ò»Ö¾Ô¸ÖÐÄÏ´óѧ»¯Ñ§Ñ§Ë¶0703×Ü·Ö337Çóµ÷¼Á
ÒѾÓÐ5È˻ظ´
Ò»Ö¾Ô¸±±¾©»¯¹¤´óѧ 070300 ѧ˶ 336·Ö Çóµ÷¼Á
ÒѾÓÐ6È˻ظ´
²ÄÁÏרҵÇóµ÷¼Á
ÒѾÓÐ10È˻ظ´
341Çóµ÷¼Á(Ò»Ö¾Ô¸ºþÄÏ´óѧ070300)
ÒѾÓÐ5È˻ظ´
0854 ¿¼Ñе÷¼Á ÕÐÉúÁË£¡AI ·½Ïò
ÒѾÓÐ15È˻ظ´
384Çóµ÷¼Á
ÒѾÓÐ6È˻ظ´
ÉúÎïѧѧ˶Çóµ÷¼Á
ÒѾÓÐ4È˻ظ´
» ±¾Ö÷ÌâÏà¹Ø¼ÛÖµÌùÍÆ¼ö£¬¶ÔÄúͬÑùÓаïÖú:
ÈçºÎ¿ØÖÆÄãµÄÉú»î
ÒѾÓÐ21È˻ظ´
¡¾Ô´´¡¿Ò»¿é»ùÓÚ8051µÄ¿ª·¢°åµç·ͼ
ÒѾÓÐ16È˻ظ´
ÓÐÈËÖªµÀ¹ãÖÝÐËÉ¿ì½Ýµç·¿Æ¼¼ÓÐÏÞ¹«Ë¾µÄ²»£¿
ÒѾÓÐ8È˻ظ´

zyj8119
ľ³æ (ÖøÃûдÊÖ)
- Ó¦Öú: 65 (³õÖÐÉú)
- ¹ó±ö: 0.003
- ½ð±Ò: 915.1
- É¢½ð: 1440
- ºì»¨: 35
- Ìû×Ó: 2936
- ÔÚÏß: 1329.4Сʱ
- ³æºÅ: 664177
- ×¢²á: 2008-11-29
- ÐÔ±ð: GG
- רҵ: ÀíÂۺͼÆË㻯ѧ

2Â¥2011-11-23 16:29:48
ºÚÉ«·çÐÅ×Ó
ÈÙÓþ°æÖ÷ (ÎÄ̳¾«Ó¢)
»Ê¼ÒÉñýˆ½ÌKOKO»òKOKOÖí
- Ó¦Öú: 9 (Ó×¶ùÔ°)
- ¹ó±ö: 2.206
- ½ð±Ò: 12754
- É¢½ð: 40066
- ºì»¨: 193
- ɳ·¢: 77
- Ìû×Ó: 13143
- ÔÚÏß: 1172.7Сʱ
- ³æºÅ: 1109772
- ×¢²á: 2010-09-28
- רҵ: µç·Óëϵͳ
- ¹ÜϽ: µçÄÔʹÓÃ
¡¾´ð°¸¡¿Ó¦Öú»ØÌû
¸Ðл²ÎÓ룬ӦÖúÖ¸Êý +1
|
ÎÒ¸øÄã¸ö¿ÉÓõÄADC0804Ö±Á÷²ÉÑùºÍÏÔʾµÄ³ÌÐò°É --ADC0804Ö±Á÷²ÉÑùºÍÏÔʾ --ÊäÈëµçѹ·¶Î§0-5V£¬ÏÔʾ0-255Êýλ --**************¿â¶¨Òå¡¢ °ü¶¨Òå******************** library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; --******************ʵÌ嶨Òå*********************** entity adc0804_new is port( reset : in std_logic;--¸´Î»ÊäÈë clk : in std_logic;--Ö÷ʱÖÓÊäÈë intr : in std_logic;--ADת»»½áÊøÊäÈë data_i : in std_logic_vector(7 downto 0);--Êý¾ÝÊäÈë data_o : out std_logic_vector(7 downto 0);--ÊýÂë¹ÜÊý¾ÝÊä³ö l : out STD_LOGIC_VECTOR(5 downto 0);--Êä³öÊýÂë¹Üλѡ bell : out std_logic;--·äÃùÆ÷ cs : out std_logic;--ʹÄÜ wr : out std_logic;--д¿ØÖÆ rd : out std_logic--¶Á¿ØÖÆ ); end adc0804_new; --******************½á¹¹Ìå*********************** architecture Behavioral of adc0804_new is type state is (start, convert, read1, read2);--״̬»ú¶¨Òå signal current_state, next_state : state;--״̬¶¨Òå signal read_data : std_logic;--¶ÁÊý¾Ý¼Ä´æÆ÷ signal clock : std_logic;--ɨÃèʱÖÓ signal p : integer range 0 to 255;--Êý¾Ý¼Ä´æÆ÷ signal b0,b1,b2 : integer range 0 to 9;--3λÊýÂë¹ÜÏÔʾÊý¾Ý¼Ä´æÆ÷ signal cnt : integer range 0 to 3:=0;--ɨÃè¼Ä´æÆ÷ begin bell<='1'; --********************ÏÔʾ½ø³Ì********************************** process(p,clk) begin case p is when 0|10|20|30|40|50|60|70|80|90|100|110|120|130|140|150|160|170|180|190|200|210|220|230|240|250=>b0<=0; when 1|11|21|31|41|51|61|71|81|91|101|111|121|131|141|151|161|171|181|191|201|211|221|231|241|251=>b0<=1; when 2|12|22|32|42|52|62|72|82|92|102|112|122|132|142|152|162|172|182|192|202|212|222|232|242|252=>b0<=2; when 3|13|23|33|43|53|63|73|83|93|103|113|123|133|143|153|163|173|183|193|203|213|223|233|243|253=>b0<=3; when 4|14|24|34|44|54|64|74|84|94|104|114|124|134|144|154|164|174|184|194|204|214|224|234|244|254=>b0<=4; when 5|15|25|35|45|55|65|75|85|95|105|115|125|135|145|155|165|175|185|195|205|215|225|235|245|255=>b0<=5; when 6|16|26|36|46|56|66|76|86|96|106|116|126|136|146|156|166|176|186|196|206|216|226|236|246=>b0<=6; when 7|17|27|37|47|57|67|77|87|97|107|117|127|137|147|157|167|177|187|197|207|217|227|237|247=>b0<=7; when 8|18|28|38|48|58|68|78|88|98|108|118|128|138|148|158|168|178|188|198|208|218|228|238|248=>b0<=8; when 9|19|29|39|49|59|69|79|89|99|109|119|129|139|149|159|169|179|189|199|209|219|229|239|249=>b0<=9; when others=>--b0<=10; end case; case p is when 0|1|2|3|4|5|6|7|8|9|100|101|102|103|104|105|106|107|108|109|200|201|202|203|204|205|206|207|208|209=>b1<=0; when 10|11|12|13|14|15|16|17|18|19|110|111|112|113|114|115|116|117|118|119|210|211|212|213|214|215|216|217|218|219=>b1<=1; when 20|21|22|23|24|25|26|27|28|29|120|121|122|123|124|125|126|127|128|129|220|221|222|223|224|225|226|227|228|229=>b1<=2; when 30|31|32|33|34|35|36|37|38|39|130|131|132|133|134|135|136|137|138|139|230|231|232|233|234|235|236|237|238|239=>b1<=3; when 40|41|42|43|44|45|46|47|48|49|140|141|142|143|144|145|146|147|148|149|240|241|242|243|244|245|246|247|248|249=>b1<=4; when 50|51|52|53|54|55|56|57|58|59|150|151|152|153|154|155|156|157|158|159|250|251|252|253|254|255=>b1<=5; when 60|61|62|63|64|65|66|67|68|69|160|161|162|163|164|165|166|167|168|169=>b1<=6; when 70|71|72|73|74|75|76|77|78|79|170|171|172|173|174|175|176|177|178|179=>b1<=7; when 80|81|82|83|84|85|86|87|88|89|180|181|182|183|184|185|186|187|188|189=>b1<=8; when 90|91|92|93|94|95|96|97|98|99|190|191|192|193|194|195|196|197|198|199=>b1<=9; when others=>--b0<=10; end case; if p<100 then b2<=0; elsif p>=100 and p<200 then b2<=1; elsif p>=200 then b2<=2; end if; end process; --**********************·ÖƵ½ø³Ì************************* process(clk) variable cnt1 : integer range 0 to 100; variable cnt2 : integer range 0 to 20; begin if clk'event and clk='1' then if cnt1=100 then cnt1:=0; if cnt2=20 then cnt2:=0; clock<=not clock; if(cnt=3)then cnt<=0; else cnt<=cnt+1; end if; else cnt2:=cnt2+1; end if; else cnt1:=cnt1+1; end if; end if; end process; --**************״̬Çý¶¯½ø³Ì********************** sync :process(clock,reset) begin if(reset = '0') then current_state <= start; elsif(clock'event and clock='1') then current_state <= next_state; end if; end process sync; --***************adc0804Çý¶¯½ø³Ì******************* comb :process(current_state, intr) begin case current_state is when start => --Æô¶¯×´Ì¬ next_state <= convert; cs <= '0'; wr <= '0'; rd <= '1'; read_data <= '0'; when convert =>--³õʼ»¯ if(intr = '0') then next_state <= read1; else next_state <= convert; end if; cs <= '1'; wr <= '1'; rd <= '1'; read_data <= '0'; when read1 =>--¶Á״̬1 next_state <= read2; cs <= '0'; wr <= '1'; rd <= '0'; read_data <= '1'; when read2 =>--¶Á״̬2 next_state <= start; cs <= '1'; wr <= '1'; rd <= '1'; read_data <= '0'; when others =>--ÆäËû״̬ next_state <= start; end case; end process comb; --****************¶ÁÈ¡ADÊý¾Ý******************** get_data: process(clock,reset) begin if(reset = '0') then p<=0; elsif(clock'event and clock='1') then if(read_data = '1') then p<=conv_integer(data_i); end if; end if; end process; --********************ÏÔʾ½ø³Ì*************************************** process(cnt) FUNCTION b_to_s7(bcd8421:INTEGER RANGE 0 TO 9) RETURN STD_LOGIC_VECTOR IS VARIABLE smg7: STD_LOGIC_VECTOR(7 DOWNTO 0); BEGIN CASE bcd8421 IS --¼ÆËãÊä³öÖµ WHEN 0 => smg7:="11111100"; --abcdefgh WHEN 1 => smg7:="01100000"; WHEN 2 => smg7:="11011010"; WHEN 3 => smg7:="11110010"; WHEN 4 => smg7:="01100110"; WHEN 5 => smg7:="10110110"; WHEN 6 => smg7:="10111110"; WHEN 7 => smg7:="11100000"; WHEN 8 => smg7:="11111110"; WHEN 9 => smg7:="11110110"; WHEN OTHERS=>smg7:="10001110"; END CASE; RETURN smg7; END b_to_s7; begin case cnt is when 0 => l<="111110";data_o<=b_to_s7(b0); when 1 => l<="111101";data_o<=b_to_s7(b1); when 2 => l<="111011";data_o<=b_to_s7(b2); when others=>l<="111111";--data_o<=b_to_s7(8); end case; end process; end Behavioral; ÒÔºó¶à½»Á÷Ŷ£¬Èç¹ûÓÐʶù£¬¿ÉÕ¾ÄÚÁªÏµÎÒ |

3Â¥2012-02-10 15:50:25













Çë°ïæ¸ø¸öÕýÈ·µÄ³ÌÐò! ÄöÊäÈëÐèÒª×Ô¼ºÉèÖõÄ???)
»Ø¸´´ËÂ¥