USE ieee.std_logic_1164.all
LIBRARY altera_mf
USE altera_mf.all
ENTITY mc8051_rom IS
PORT
(
address : IN STD_LOGIC_VECTOR (11 DOWNTO 0)
clock : IN STD_LOGIC
q : OUT STD_LOGIC_VECTOR (7 DOWNTO 0)
)
END mc8051_rom
ARCHITECTURE SYN OF mc8051_rom IS
SIGNAL sub_wire0 : STD_LOGIC_VECTOR (7 DOWNTO 0)
COMPONENT altsyncram
GENERIC (
address_aclr_a : STRING
init_file : STRING
intended_device_family : STRING
lpm_hint : STRING
lpm_type : STRING
numwords_a : NATURAL
operation_mode : STRING
outdata_aclr_a : STRING
outdata_reg_a : STRING
ram_block_type : STRING
widthad_a : NATURAL
width_a : NATURAL
width_byteena_a : NATURAL
)
PORT (
clock0 : IN STD_LOGIC
address_a : IN STD_LOGIC_VECTOR (11 DOWNTO 0)
q_a : OUT STD_LOGIC_VECTOR (7 DOWNTO 0)
)
END COMPONENT
BEGIN
q<= sub_wire0(7 DOWNTO 0)
altsyncram_component : altsyncram
GENERIC MAP (
address_aclr_a =>"NONE",
init_file =>"p1test.hex",
intended_device_family =>"Cyclone",
lpm_hint =>"ENABLE_RUNTIME_MOD=NO",
lpm_type =>"altsyncram",
numwords_a =>4096,
operation_mode =>"ROM"蠢信销,
outdata_aclr_a =>"NONE",
outdata_reg_a =>"UNREGISTERED",
ram_block_type =>"M4K"坦派,
widthad_a =>12,
width_a =>8,
width_byteena_a =>1
)
PORT MAP (
clock0 =>clock,
address_a =>带游 address,
q_a =>sub_wire0
)
END SYN
实体,结构体,库,程序包,配置1、实体:用于描述所设计系统的外部接口特性;即该设计实谈棚体对外的输入、输出端口数量和端口特性。
2、结构体:用于描述实体猛姿所代表的系统内部的结构和行为;它含知则描述设计实体的结构、行为、元件及内部连接关系。
3、库:存放已经编译的实体、构造体、程序包集合和配置。
4、程序包:存放各设计模块可以共享的数据类型、常数、子程序库。
5、配置实体对应多个结构体时,从与某个实体对应的多个结构体中选定一个作为具体实现。
1、freq: IN INTEGER --控制输出波形的频率输入可以定义成integer吗?我觉的不行。
2、Qout : OUT integer
输出可以定拍坦义为integer吗?不知是如何输出的
3、 COMPONENT lpm_rom0
END COMPONENT
这句什么意思,多余的吧,此处定义元件是什么意思?
4、这段程序,逻辑上有问题,乱。
在此我给你一段三角波的程拿闭序:
entity sanjiao is
Port(rst : in std_logic
clk : in std_logic
q : out std_logic_vector(7 downto 0))
end sanjiao
architecture Behavioral of sanjiao is
begin
process(clk,rst)
variable num : std_logic_vector(7 downto 0)
variable ff :std_logic:='0'
begin
if(rst='1')then
num:="00000000"
elsif(clk'event and clk='1')then
if(ff='0')then
if(num="11111110")then
num:="11111111"
ff:='1'
else
num:=num+1
end if
elsif(ff='1')then
if(num="00000001")then
num:="00000000"
ff:='0'
else
num:=num-1
end if
end if
end if
q<=num
end process
end Behavioral
正弦波的程序:
entity sins is
Port ( clk : in std_logic
rst : in std_logic
q : out std_logic_vector(7 downto 0))
end sins
architecture Behavioral of sins is
signal a : std_logic_vector(7 downto 0)
signal b : std_logic_vector(7 downto 0)
begin
process(rst,clk)
begin
if(rst='1')then
a<=(others=>'0')
elsif(clk'event and clk='1')then
if (a="10110011") then
a<= "00000000"
else
a<=a+1
end if
end if
end process
process(a)
begin
case a is
when "00000000"=>b<="00000000"
when "00000001"=>b<="00000100"
when "00000010"=>b<="00001001"
when "00000011"=>b<="00001101"
when "00000100"=>b<="00010001"
when "00000101"=>b<="00010110"
when "00000110"=>b<="00011011"
when "00000111"=>b<="00011111"
when "00001000"=>b<="00100011"
when "00001001"=>b<="00101000"
when "00001010"=>b<="00101100"
when "00001011"=>b<="00110001"
when "00001100"=>b<="00110101"
when "00001101"=>b<="00111001"
when "00001110"=>b<="00111110"
when "00001111"=>b<="01000001"
when "00010000"=>b<="01000110"
when "00010001"袭敏桐=>b<="01001011"
when "00010010"=>b<="01001111"
when "00010011"=>b<="01010011"
when "00010100"=>b<="01010111"
when "00010101"=>b<="01011011"
when "00010110"=>b<="01100000"
when "00010111"=>b<="01100100"
when "00011000"=>b<="01101000"
when "00011001"=>b<="01101100"
when "00011010"=>b<="01110000"
when "00011011"=>b<="01110100"
when "00011100"=>b<="01111000"
when "00011101"=>b<="01111100"
when "00011110"=>b<="10000000"
when "00011111"=>b<="10000011"
when "00100000"=>b<="10000111"
when "00100001"=>b<="10001011"
when "00100010"=>b<="10001111"
when "00100011"=>b<="10010010"
when "00100100"=>b<="10010110"
when "00100101"=>b<="10011001"
when "00100110"=>b<="10011101"
when "00100111"=>b<="10100000"
when "00101000"=>b<="10100100"
when "00101001"=>b<="10100111"
when "00101010"=>b<="10101011"
when "00101011"=>b<="10101110"
when "00101100"=>b<="10110001"
when "00101101"=>b<="10110100"
when "00101110"=>b<="10110111"
when "00101111"=>b<="10111010"
when "00110000"=>b<="10111110"
when "00110001"=>b<="11000000"
when "00110010"=>b<="11000011"
when "00110011"=>b<="11000110"
when "00110100"=>b<="11001001"
when "00110101"=>b<="11001100"
when "00110110"=>b<="11001110"
when "00110111"=>b<="11010001"
when "00111000"=>b<="11010011"
when "00111001"=>b<="11010110"
when "00111010"=>b<="11011000"
when "00111011"=>b<="11011011"
when "00111100"=>b<="11011101"
when "00111101"=>b<="11011111"
when "00111110"=>b<="11100001"
when "00111111"=>b<="11100011"
when "01000000"=>b<="11100101"
when "01000001"=>b<="11100111"
when "01000010"=>b<="11101001"
when "01000011"=>b<="11101011"
when "01000100"=>b<="11101100"
when "01000101"=>b<="11101110"
when "01000110"=>b<="11110000"
when "01000111"=>b<="11110001"
when "01001000"=>b<="11110011"
when "01001001"=>b<="11110100"
when "01001010"=>b<="11110101"
when "01001011"=>b<="11110110"
when "01001100"=>b<="11110111"
when "01001101"=>b<="11111000"
when "01001110"=>b<="11111001"
when "01001111"=>b<="11111010"
when "01010000"=>b<="11111011"
when "01010001"=>b<="11111011"
when "01010010"=>b<="11111101"
when "01010011"=>b<="11111101"
when "01010100"=>b<="11111101"
when "01010101"=>b<="11111110"
when "01010110"=>b<="11111110"
when "01010111"=>b<="11111110"
when "01011000"=>b<="11111111"
when "01011001"=>b<="11111111"
when "01011010"=>b<="11111111"
when "01011011"=>b<="11111111"
when "01011100"=>b<="11111111"
when "01011101"=>b<="11111110"
when "01011110"=>b<="11111110"
when "01011111"=>b<="11111110"
when "01100000"=>b<="11111101"
when "01100001"=>b<="11111101"
when "01100010"=>b<="11111101"
when "01100011"=>b<="11111011"
when "01100100"=>b<="11111011"
when "01100101"=>b<="11111010"
when "01100110"=>b<="11111001"
when "01100111"=>b<="11111000"
when "01101000"=>b<="11110111"
when "01101001"=>b<="11110110"
when "01101010"=>b<="11110101"
when "01101011"=>b<="11110100"
when "01101100"=>b<="11110011"
when "01101101"=>b<="11110001"
when "01101110"=>b<="11110000"
when "01101111"=>b<="11101110"
when "01110000"=>b<="11101110"
when "01110001"=>b<="11101011"
when "01110010"=>b<="11101001"
when "01110011"=>b<="11100111"
when "01110100"=>b<="11100101"
when "01110101"=>b<="11100011"
when "01110110"=>b<="11100001"
when "01110111"=>b<="11011111"
when "01111000"=>b<="11011101"
when "01111001"=>b<="11011011"
when "01111010"=>b<="11011000"
when "01111011"=>b<="11010110"
when "01111100"=>b<="11010011"
when "01111101"=>b<="11010001"
when "01111110"=>b<="11001110"
when "01111111"=>b<="11001100"
when "10000000"=>b<="11001001"
when "10000001"=>b<="11000110"
when "10000010"=>b<="11000011"
when "10000011"=>b<="11000000"
when "10000100"=>b<="10111110"
when "10000101"=>b<="10111010"
when "10000110"=>b<="10110111"
when "10000111"=>b<="10110100"
when "10001000"=>b<="10110001"
when "10001001"=>b<="10101110"
when "10001010"=>b<="10101011"
when "10001011"=>b<="10100111"
when "10001100"=>b<="10100100"
when "10001101"=>b<="10100000"
when "10001110"=>b<="10011101"
when "10001111"=>b<="10011001"
when "10010000"=>b<="10010110"
when "10010001"=>b<="10010010"
when "10010010"=>b<="10001111"
when "10010011"=>b<="10001011"
when "10010100"=>b<="10000111"
when "10010101"=>b<="10000000"
when "10010110"=>b<="10000000"
when "10010111"=>b<="01111100"
when "10011000"=>b<="01111000"
when "10011001"=>b<="01110100"
when "10011010"=>b<="01110000"
when "10011011"=>b<="01101100"
when "10011100"=>b<="01101000"
when "10011101"=>b<="01100100"
when "10011110"=>b<="01100000"
when "10011111"=>b<="01011011"
when "10100000"=>b<="01010111"
when "10100001"=>b<="01010011"
when "10100010"=>b<="01001111"
when "10100011"=>b<="01001011"
when "10100100"=>b<="01000110"
when "10100101"=>b<="01000001"
when "10100110"=>b<="00111110"
when "10100111"=>b<="00111001"
when "10101000"=>b<="00110101"
when "10101001"=>b<="00110001"
when "10101010"=>b<="00101100"
when "10101011"=>b<="00101000"
when "10101100"=>b<="00100011"
when "10101101"=>b<="00011111"
when "10101110"=>b<="00011011"
when "10101111"=>b<="00010110"
when "10110000"=>b<="00010001"
when "10110001"=>b<="00001101"
when "10110010"=>b<="00001001"
when "10110011"=>b<="00000100"
-- when "10110100"=>b<="00000000"
when others=>null
end case
q(7 downto 0)<=b(7 downto 0)
end process
end Behavioral
锯齿波可以有三角波的程序来改。
你将这几段程序合在一起就可以了,可以用拨码开关对输出哪种波形进行选择,频率可以对输入的时钟进行分频来改变。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)