|
程序如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity pulse is
port ( clk: In std_logic;
d : IN std_logic_vector(13 downto 0);
fout: out std_logic);
end pulse;
architecture behav of pulse is
signal count : std_logic_vector (13 downto 0);
signal cao, cao1,cao2,load: std_logic;
begin
process(clk,load,d)
begin
if clk'event and clk = '1' then
if load = '1' then count <=d;
else count <= count - 1;
end if;
end if;
end process;
process(count)
begin
if count = 0 then cao <= '1';
else cao <='0'; end if;
load <= cao;
end process;
process(clk)
begin
if clk'event and clk = '1' then
cao1 <=cao;
end if;
end process;
process(cao1)
begin
if cao1'event and cao1 = '1' then
cao2 <= not cao2;
end if;
fout <= cao2;
end process;
end behav;
library ieee;
use ieee.std_logic.1164.all;
entity table is
port ( clk : in std_logic;
af: out integer range 0 to 16#3FFF# );
end;
architecture one of table is
constant low_3: integer:=9100;
constant low_5: integer:=7652;
constant low_6: integer:=6817;
constant low_7: integer:=6073;
constant mid_1: integer:=5732;
constant mid_2: integer:=5107;
constant mid_3: integer:=4550;
constant mid_5: integer:=3826;
constant mid_6: integer:=3408;
constant high1: integer:=2996;
constant stop : integer:=0;
signal counter[/COLOR] : integer range 0 to 138;
begin
process(clk)
begin
if counter =138 then counter <=0;
elsif (clk'event and clk = '1') then
counter <= counter + 1 ;
end if;
end process;
process(counter)
begin
case counter is
when 00 => af <= low_3;
when 01 => af <= low_3;
when 02 => af <= low_3;
when 03 => af <= low_3;
when 04 => af <= low_5;
when 05 => af <= low_5;
when 06 => af <= low_5;
when 07 => af <= low_6;
when 08 => af <= mid_1;
when 09 => af <= mid_1;
when 10 => af <= mid_1;
when 11 => af <= mid_2;
when 12 => af <= low_6;
when 13 => af <= mid_1;
when 14 => af <= low_5;
when 15 => af <= low_5;
when 16 => af <= mid_5;
when 17 => af <= mid_5;
when 18 => af <= mid_5;
when 19 => af <= hig_1;
when 20 => af <= mid_6;
when 21 => af <= mid_5;
when 22 => af <= mid_3;
when 23 => af <= mid_5;
when 24 => af <= mid_2;
when 25 => af <= mid_2;
when 26 => af <= mid_2;
when 27 => af <= mid_2;
when 28 => af <= mid_2;
when 29 => af <= mid_2;
when 30 => af <= mid_2;
when 31 => af <= stop;
when 32 => af <= mid_2;
when 33 => af <= mid_2;
when 34 => af <= mid_2;
when 35 => af <= mid_3;
when 36 => af <= low_7;
when 37 => af <= low_7;
when 38 => af <= low_6;
when 39 => af <= low_6;
when 40 => af <= low_5;
when 41 => af <= low_5;
when 42 => af <= low_5;
when 43 => af <= low_6;
when 44 => af <= mid_1;
when 45 => af <= mid_1;
when 46 => af <= mid_2;
when 47 => af <= mid_2;
when 48 => af <= low_3;
when 49 => af <= low_3;
when 50 => af <= mid_1:
when 51 => af <= mid_1:
when 52 => af <= low_6:
when 53 => af <= low_5:
when 54 => af <= low_6:
when 55 => af <= low_1:
when 56 => af <= low_5:
when 57 => af <= low_5:
when 58 => af <= low_5:
when 59 => af <= low_5:
when 60 => af <= low_5:
when 61 => af <= low_5:
when 62 => af <= low_5:
when 63 => af <= low_5:
when 64 => af <= mid_3:
when 65 => af <= mid_3:
when 66 => af <= mid_3:
when 67 => af <= mid_5:
when 68 => af <= low_7:
when 69 => af <= low_7:
when 70 => af <= mid_2;
when 71 => af <= mid_2;
when 72 => af <= low_6;
when 73 => af <= mid_1;
when 74 => af <= low_5;
when 75 => af <= low_5;
when 76 => af <= low_5;
when 77 => af <= low_5;
when 78 => af <= low_5;
when 79 => af <= low_5;
when 80 => af <= low_3;
when 81 => af <= low_5;
when 82 => af <= low_3;
when 83 => af <= low_3;
when 84 => af <= low_5;
when 85 => af <= low_6;
when 86 => af <= low_7;
when 87 => af <= mid_2;
when 88 => af <= low_6;
when 89 => af <= low_6;
when 90 => af <= low_6;
when 91 => af <= low_6;
when 92 => af <= low_6;
when 93 => af <= low_6;
when 94 => af <= low_5;
when 95 => af <= low_6;
when 96 => af <= mid_1;
when 97 => af <= mid_1;
when 98 => af <= mid_1;
when 99 => af <= mid_2;
when 100 => af <= mid_5;
when 101=> af <= mid_5;
when 102=> af <= mid_5;
when 103=> af <= mid_3;
when 104=> af <= mid_2;
when 105=> af <= mid_2;
when 106=> af <= mid_3;
when 107=> af <= mid_2;
when 108=> af <= mid_1;
when 109=> af <= mid_1;
when 110=> af <= low_6;
when 111=> af <= low_5;
when 112=> af <= low_3;
when 113=> af <= low_3;
when 114=> af <= low_3;
when 115=> af <= low_3;
when 116=> af <= mid_1;
when 117=> af <= mid_1;
when 118=> af <= mid_1;
when 119=> af <= mid_1;
when 120=> af <= low_6;
when 121=> af <= mid_1;
when 122=> af <= low_6;
when 123=> af <= low_5;
when 124=> af <= low_3;
when 125=> af <= low_5;
when 126=> af <= low_6;
when 127=> af <= mid_1;
when 128=> af <= mid_5;
when 129=> af <= mid_5;
when 130=> af <= mid_5;
when 131=> af <= mid_5;
when 132=> af <= mid_5;
when 133=> af <= mid_5;
when 134=> af <= mid_5;
when 135=> af <= mid_5;
when 136=> af <= stop;
when 137=> af <= stop;
when 138=> af <= stop;
when 139 => af <= stop;
when 140 => af <= stop;
when others => null;
end case;
end process;
end;
编译后,在上面兰色部分出现counter 未定义变量,不知道如何改,望遇高人,不吝赐教,感激万分!这个题目是本人的毕业设计,程序是在网站上找的,我看了半天也没有看出错误! |
|