基于VHDL语言的EDA实验报告

  • 格式:doc
  • 大小:13.22 MB
  • 文档页数:19

EDA实验报告班级:电科五班姓名:张红义学号: 1008101143十进制计数器实验源码:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY CNT10 ISPORT (CLK,RST,EN,LOAD:IN STD_LOGIC;DATA:IN STD_LOGIC_VECTOR(3 DOWNTO 0);DOUT:OUT STD_LOGIC_VECTOR(3 DOWNTO 0);COUT:OUT STD_LOGIC );END CNT10;ARCHITECTURE behav OF CNT10 ISBEGINPROCESS(CLK,RST,EN,LOAD)V ARIABLE Q:STD_LOGIC_VECTOR(3 DOWNTO 0); BEGINIF RST='0' THEN Q:=(OTHERS=>'0');ELSIF CLK'EVENT AND CLK='1' THENIF EN='1' THENIF (LOAD='0') THEN Q:=DATA;ELSEIF Q<9 THEN Q:=Q+1;ELSE Q:=(OTHERS=>'0');END IF;END IF;END IF;END IF;IF Q="1001" THEN COUT<='1';ELSE COUT<='0';END IF;DOUT<=Q;END PROCESS;END behav;仿真波形:封装图:3-8译码器实验源码:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY YM38 ISPORT (A:IN STD_LOGIC_VECTOR(2 DOWNTO 0);EN:IN STD_LOGIC;Y:OUT STD_LOGIC_VECTOR(7 DOWNTO 0) ); END YM38;ARCHITECTURE BEHA V OF YM38 ISSIGNAL CLK: STD_LOGIC_VECTOR(3 DOWNTO 0); BEGINCLK<=A&EN;PROCESS(CLK)BEGINCASE CLK ISWHEN "0001" => Y<="00000001";WHEN "0011" => Y<="00000010";WHEN "0101" => Y<="00000100";WHEN "0111" => Y<="00001000";WHEN "1001" => Y<="00010000";WHEN "1011" => Y<="00100000"; WHEN "1101" => Y<="01000000"; WHEN "1111" => Y<="10000000"; WHEN OTHERS=> Y<="00000000";END CASE;END PROCESS;END BEHA V;仿真波形:封装图:MEALY型有限状态机实验源码:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;ENTITY MEALY1 ISPORT(CLK,DIN1,DIN2,RST : IN STDD_LOGIC;Q : OUT STD_LOGIC_VECTOR(4 DOWNTO 0));END MEALY1;ARCHITECTURE BEHA V OF MEALY1 ISTYPE STATES IS (ST0, ST1, ST2, ST3,ST4);SIGNAL PST :STATES ;BEGINREGCOM: PROCESS(CLK,RST,PST,DIN1) BEGINIF RST='1' THEN PST <=ST0; ELSIF RISING_EDGE(CLK) THENCASE PST ISWHEN ST0=> IF DIN1='1' THEN PST<=ST1 ; ELSE PST<=ST0 ; END IF ;WHEN ST1=> IF DIN1='1' THEN PST<=ST2 ; ELSE PST<=ST1 ; END IF ;WHEN ST2=> IF DIN1='1' THEN PST<=ST3 ; ELSE PST<=ST2 ; END IF ;WHEN ST3=> IF DIN1='1' THEN PST<=ST4 ; ELSE PST<=ST3 ; END IF ;WHEN ST4=> IF DIN1='0' THEN PST<=ST0 ; ELSE PST<=ST4 ; END IF ;WHEN OTHERS => PST<=ST0 ;END CASE; END IF;END PROCESS REGCOM:;COM: PROCESS(PST,DIN2) BEGINCASE PST ISWHEN ST0=> IF DIN2='1' THEN Q<="10000" ; ELSE Q<="01010" ; END IF;WHEN ST1=> IF DIN2='0' THEN Q<="10111" ; ELSE Q<="10100" ; END IF;WHEN ST2=> IF DIN2='1' THEN Q<="10101" ; ELSE Q<="10011" ; END IF;WHEN ST3=> IF DIN2='0' THEN Q<="11011" ; ELSE Q<="01001" ; END IF;WHEN ST4=> IF DIN2='1' THEN Q<="11101" ; ELSE Q<="01101" ; END IF; WHEN OTHERS => Q<="00000" ;END CASE ;END PROCESS COM ;END;跑马灯实验源码:Library ieee;use ieee.std_logic_1164.all;entity cyc_led isport( clr,clk:in std_logic;led1,led2,led3:out std_logic);end;architecture a of cyc_led istype states is(s0,s1,s2,s3,s4,s5);signal q:std_logic_vector(0 to 2);signal state: states;beginp1:process(clk,clr)beginif (clr='0') thenstate<=s0; led1<='0'; led2<='0'; led3<='0';elsif(clk'event and clk='1') thencase state iswhen s0=> state<=s1; led1<='1';led2<='0';led3<='0';when s1=> state<=s2; led1<='0';led2<='1';led3<='0';when s2=> state<=s3; led1<='0';led2<='1';led3<='0';when s3=> state<=s4; led1<='0';led2<='0';led3<='1';when s4=> state<=s5; led1<='0';led2<='0';led3<='1';when s5=> state<=s0; led1<='0';led2<='0';led3<='1';end case;end if;end process;end;实验图:LED数码管循环显示0~9 实验源码:LIBRARY IEEE;USE IEEE.std_logic_1164.all;USE IEEE.std_logic_arith.all;USE IEEE.std_logic_unsigned.all;ENTITY xianshi ISPORT(clk:in std_logic;Led7s:out std_logic_vector(6 downto 0));--sel:out std_logic_vector(1 downto 0));END ENTITY ;ARCHITECTURE func OF xianshi ISSIGNAL fp,tmp:std_logic;SIGNAL count:std_logic_vector(9 downto 0); SIGNAL sl:std_logic_vector(3 downto 0);--sl1:std_logic_vector(1 downto 0);BEGINPROCESS(clk)BEGINIF(clk'EVENT AND clk = '1') THENIF(count = "1111100111") THENcount <= (OTHERS => '0');tmp <= NOT tmp;ELSEcount <= count + 1;END IF;END IF;fp <= tmp;END PROCESS;counter1:PROCESS(fp)BEGINIF(fp'EVENT AND fp = '1') THENIF(sl = "1001") THEN sl <= "0000";ELSE sl <= sl + 1;END IF;END IF;END PROCESS;diplay:PROCESS(sl)BEGINCASE sl ISwhen "0000" => led7s<="0111111";when "0001" => led7s<="0000110";when "0010" => led7s<="1011011";when "0011" => led7s<="1001111";when "0100" => led7s<="1100110";when "0101" => led7s<="1101101";when "0110" => led7s<="1111101";when "0111" => led7s<="0000111";when "1000" => led7s<="1111111";when "1001" => led7s<="1101111";WHEN OTHERS => NULL;END CASE;END PROCESS;END ARCHITECTURE;实验图:16*16点阵显示_北京欢迎实验源码:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity test_led1 isport(clk:in std_logic;dotout:out std_logic_vector(15 downto 0);--行驱动信号输出selout:out std_logic_vector(3 downto 0));--列选信号号输出end test_led1;architecture behave of test_led1 issignal count:std_logic_vector(11 downto 0);signal q:std_logic_vector(10 downto 0);signal cnt16:std_logic_vector(3 downto 0);signal dout:std_logic_vector(15 downto 0);signal a:integer range 0 to 15;signal tmp:std_logic_vector(1 downto 0):="00";beginreg:PROCESS(clk)BEGINIF(clk'EVENT AND clk = '1') THENIF(count = "111110100000") THENcount <= (OTHERS => '0');if (tmp="11")then tmp<="00";else tmp <= tmp+1;end if;ELSEcount <= count + 1;END IF;END IF;END PROCESS;p1: process(cnt16)beginif tmp="00" thencase cnt16 iswhen"0000"=>dout<="0010000000000000"; a<=0; when"0001"=>dout<="0011000000100000"; a<=1; when"0010"=>dout<="0001100000100000"; a<=2; when"0011"=>dout<="0000100000100000"; a<=3; when"0100"=>dout<="0000010000100000"; a<=4; when"0101"=>dout<="0111111111111111"; a<=5; when"0110"=>dout<="0000000000000000"; a<=6; when"0111"=>dout<="0000000000000000"; a<=7; --北when"1000"=>dout<="0000000000000000"; a<=8; when"1001"=>dout<="0011111111111111"; a<=9; when"1010"=>dout<="0100000001000000"; a<=10; when"1011"=>dout<="0100000000100000"; a<=11; when"1100"=>dout<="0100000000011000"; a<=12; when"1101"=>dout<="0100000000001100"; a<=13; when"1110"=>dout<="0111100000001000"; a<=14; when"1111"=>dout<="0000000000000000"; a<=15; when others=>null;end case;elsif tmp="01" thencase cnt16 iswhen"0001"=>dout<="0000000000000100"; a<=1; when"0010"=>dout<="0000000000000100"; a<=2; when"0011"=>dout<="0010000000000100"; a<=3; when"0100"=>dout<="0001000000000100"; a<=4; when"0101"=>dout<="0000100111110100"; a<=5; when"0110"=>dout<="0000000100010101"; a<=6; when"0111"=>dout<="1100000100010101"; a<=7; --京when"1000"=>dout<="1111110100010101"; a<=8; when"1001"=>dout<="0000000100010100"; a<=9; when"1010"=>dout<="0000000100010100"; a<=10; when"1011"=>dout<="0000100111110100"; a<=11; when"1100"=>dout<="0001000000000100"; a<=12; when"1101"=>dout<="0010000000000100"; a<=13; when"1110"=>dout<="0000000000000100"; a<=14; when"1111"=>dout<="0000000000000000"; a<=15; when others=>null;end case;elsif tmp="10"thencase cnt16 iswhen"0000"=>dout<="0000000000000000"; a<=0; when"0001"=>dout<="0000000000000000"; a<=1; when"0010"=>dout<="0000001000011000"; a<=2; when"0011"=>dout<="0000000100101000"; a<=3; when"0100"=>dout<="0000000001001000"; a<=4; when"0101"=>dout<="0000000010011000"; a<=5; when"0110"=>dout<="0000100100000100"; a<=6; when"0111"=>dout<="0000001000000011"; a<=7; --欢when"1000"=>dout<="0000000010000010"; a<=8; when"1001"=>dout<="0000000000100010"; a<=9; when"1010"=>dout<="0000000000001010"; a<=10; when"1011"=>dout<="0000000001000010"; a<=11; when"1100"=>dout<="0000000010000010"; a<=12; when"1101"=>dout<="0000000100001010"; a<=13; when"1110"=>dout<="0000001000000110"; a<=14; when"1111"=>dout<="0000000000000000"; a<=15; when others=>null;end case;elsif tmp="11"thencase cnt16 iswhen"0000"=>dout<="1000000000010010"; a<=0; when"0001"=>dout<="0111111111110100"; a<=1;when"0011"=>dout<="0100000000000000"; a<=3; when"0100"=>dout<="1000111111111100"; a<=4; when"0101"=>dout<="1000100000000010"; a<=5; when"0110"=>dout<="1000110000000010"; a<=6; when"0111"=>dout<="1000000000000000"; a<=7; --迎when"1000"=>dout<="1000000000000000"; a<=8; when"1001"=>dout<="1001111111111110"; a<=9; when"1010"=>dout<="1000000000000010"; a<=10; when"1011"=>dout<="1000100001000010"; a<=11; when"1100"=>dout<="1000111111110010"; a<=12; when"1101"=>dout<="1000000000000000"; a<=13; when"1110"=>dout<="1000000000000000"; a<=14; when"1111"=>dout<="0000000000000000"; a<=15; when others=>null;end case;end if;dotout<=dout;end process p1;p2: process(clk)beginif clk'event and clk='1' then q<=q+1;end if;cnt16<=q(3 downto 0);end process p2;p3: process(a)--4/16译码电路begincase a iswhen 0 => selout<="0000";when 1 => selout<="0001";when 2 => selout<="0010";when 3 => selout<="0011";when 4 => selout<="0100";when 5 => selout<="0101";when 6 => selout<="0110";when 7 => selout<="0111";when 8 => selout<="1000";when 9 => selout<="1001";when 10 => selout<="1010";when 11 => selout<="1011";when 12 => selout<="1100";when 13 => selout<="1101";when 14 => selout<="1110";when 15 => selout<="1111";when others => null;end case;end process p3;end behave;实验图:16*16点阵显示_河南农大实验源码:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity test_led1 isport(clk:in std_logic;dotout:out std_logic_vector(15 downto 0);--行驱动信号输出selout:out std_logic_vector(3 downto 0));--列选信号号输出end test_led1;architecture behave of test_led1 issignal count:std_logic_vector(11 downto 0);signal q:std_logic_vector(10 downto 0);signal cnt16:std_logic_vector(3 downto 0);signal dout:std_logic_vector(15 downto 0);signal a:integer range 0 to 15;signal tmp:std_logic_vector(1 downto 0):="00";beginreg:PROCESS(clk)BEGINIF(clk'EVENT AND clk = '1') THENIF(count = "111110100000") THENcount <= (OTHERS => '0');if (tmp="11")thentmp<="00";else tmp <= tmp+1;end if;ELSE count <= count + 1;END IF;END IF;END PROCESS;p1: process(cnt16)beginif tmp="00" thencase cnt16 iswhen"0000"=>dout<="0000000000000000"; a<=0; when"0001"=>dout<="0100000000100010"; a<=1; when"0010"=>dout<="0011000001000100"; a<=2; when"0011"=>dout<="0000110010001000"; a<=3; when"0100"=>dout<="0000000000000000"; a<=4; when"0101"=>dout<="0000000000000010"; a<=5; when"0110"=>dout<="0000000111110010"; a<=6; when"0111"=>dout<="0000000100010010"; a<=7; --河when"1000"=>dout<="0000000100010010"; a<=8; when"1001"=>dout<="0001000100010010"; a<=9; when"1010"=>dout<="0010000111110010"; a<=10; when"1011"=>dout<="0100000000000010"; a<=11; when"1100"=>dout<="0111111111111110"; a<=12; when"1101"=>dout<="0000000000000010"; a<=13; when"1110"=>dout<="0000000000000010"; a<=14; when"1111"=>dout<="0000000000000000"; a<=15; when others=>null;end case;elsif tmp="01" thencase cnt16 iswhen"0000"=>dout<="0000000000000000"; a<=0; when"0001"=>dout<="0111111111100000"; a<=1; when"0010"=>dout<="0000000000100000"; a<=2; when"0011"=>dout<="0000010000100100"; a<=3; when"0100"=>dout<="0000010101100100"; a<=4; when"0101"=>dout<="0000010110100100"; a<=5; when"0110"=>dout<="0000010100110100"; a<=6; when"0111"=>dout<="0000010100101100"; a<=7; --南when"1000"=>dout<="0111111100100111"; a<=8; when"1001"=>dout<="0000010100100100"; a<=9; when"1010"=>dout<="0000010110100100"; a<=10; when"1011"=>dout<="0000010101100100"; a<=11; when"1100"=>dout<="0010010000100100"; a<=12; when"1101"=>dout<="0100000000100000"; a<=13; when"1110"=>dout<="0111111111100000"; a<=14; when"1111"=>dout<="0000000000000000"; a<=15; when others=>null;end case;elsif tmp="10"thencase cnt16 iswhen"0000"=>dout<="0000000000000000"; a<=0; when"0001"=>dout<="0001000000011000"; a<=1; when"0010"=>dout<="0000100000000100"; a<=2; when"0011"=>dout<="0000011000000100"; a<=3; when"0100"=>dout<="0000000110000100"; a<=4; when"0101"=>dout<="0000000001000100"; a<=5; when"0110"=>dout<="0111111110110100"; a<=6; when"0111"=>dout<="0100000001001111"; a<=7; --农when"1000"=>dout<="0010000010000100"; a<=8; when"1001"=>dout<="0000000100000100"; a<=9; when"1010"=>dout<="0000011011000100"; a<=10; when"1011"=>dout<="0001100000110100"; a<=11; when"1100"=>dout<="0010000000000100"; a<=12; when"1101"=>dout<="0010000000000100"; a<=13; when"1110"=>dout<="0010000000011000"; a<=14; when"1111"=>dout<="0000000000000000"; a<=15; when others=>null;end case;elsif tmp="11"thencase cnt16 iswhen"0000"=>dout<="0000000000000000"; a<=0; when"0001"=>dout<="0110000000100000"; a<=1; when"0010"=>dout<="0001100000100000"; a<=2; when"0011"=>dout<="0000011000100000"; a<=3; when"0100"=>dout<="0000000110100000"; a<=4; when"0101"=>dout<="0000000001100000"; a<=5; when"0110"=>dout<="0000000000111110"; a<=6; when"0111"=>dout<="0000000001100000"; a<=7; --大when"1000"=>dout<="0000000010100000"; a<=8; when"1001"=>dout<="0000001100100000"; a<=9;when"1010"=>dout<="0000010000100000"; a<=10; when"1011"=>dout<="0001100000100000"; a<=11; when"1100"=>dout<="0010000000100000"; a<=12; when"1101"=>dout<="0100000000100000"; a<=13; when"1110"=>dout<="0100000000100000"; a<=14; when"1111"=>dout<="0000000000000000"; a<=15; when others=>null;end case;end if;dotout<=dout;end process p1;p2: process(clk)beginif clk'event and clk='1' then q<=q+1;end if;cnt16<=q(3 downto 0);end process p2;p3: process(a)--4/16译码电路begincase a iswhen 0 => selout<="0000";when 1 => selout<="0001";when 2 => selout<="0010";when 3 => selout<="0011";when 4 => selout<="0100";when 5 => selout<="0101";when 6 => selout<="0110";when 7 => selout<="0111";when 8 => selout<="1000";when 9 => selout<="1001";when 10 => selout<="1010";when 11 => selout<="1011";when 12 => selout<="1100";when 13 => selout<="1101";when 14 => selout<="1110";when 15 => selout<="1111";when others => null;end case;end process p3;end behave;实验图:。