刚开始学vhdl,想写一个波形发生器的代码,但过程中编译老是出现Cri
tical Warning (332148): Timing requirements not met的警告,想用modelsim
仿真,但是时钟也都是未知信号,想知道是和这个警告有关系吗?还是我的testbench写错了。之后用自己这个程序,把
FPGA输出接到dac0832波形能正常输出方波正弦波以及三角波。以及突然发现不论是自己写的,还是网上直接复制粘贴的都有这个警告:Critical Warning (332148): Timing requirements not met,这又是为何呢?本人真真是萌新中的萌新啊~学了几天懂得也不多,就是按网上的代码改改~求各位前辈指点指点~积分什么的各路大神也会太在意的吧~~~(只有2个哭~)
以下是代码:
----------------------------------------------------
--正弦波
--
----------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity sin is
port(clk_sin:in std_logic;
--reset:in std_logic;
dd4:out std_logic_vector(7 downto 0));--———输出范围为0到255
end;
architecture dacc of sin is
signal q: integer range 63 downto 0;
signal clk4:std_logic;
begin
lcd_clk:
process(clk_sin)
variable count:integer range 0 to 50000000;
variable clk1:std_logic;
begin
-- if reset='0'then
-- count:=0;
--els
if(clk_sin'event and clk_sin='1')then --rising_edge(clk)
--if(count="100110001001011001111111")then
--count<=(others=>'0');
if(count=24000)then
count:=0;
clk1:=not clk1;
else count:=count+1;
end if;
end if;
clk4<=clk1;
end process;
process(clk4)
begin
if (clk4'event and clk4='1') then
q<=q+1;
end if;
end process;
process(q)
begin
case q is
when 00=>dd4<="11111111";
when 01=>dd4<="11111110";
when 02=>dd4<="11111101";
when 03=>dd4<="11111010";
when 04=>dd4<="11110101";--245;
when 05=>dd4<="11110000";--240;
when 06=>dd4<="11101010";--234;
when 07=>dd4<="11100010";--226
when 08=>dd4<="11011010";--218
when 09=>dd4<="11010000";--208;
when 10=>dd4<="11000110";--198;
when 11=>dd4<="10111100";--188;
when 12=>dd4<="10110000";--176;
when 13=>dd4<="10100101";--165;
when 14=>dd4<="10011000";--152;
when 15=>dd4<="10001100";--140;
when 16=>dd4<="10000000";--128;
when 17=>dd4<="01110011";--115;
when 18=>dd4<="01100111";--103;
when 19=>dd4<="01011010";--90;
when 20=>dd4<="01001111";--79;
when 21=>dd4<="01000011";--67;
when 22=>dd4<="00111001";--57;
when 23=>dd4<="00101111";--47;
when 24=>dd4<="00100101";--37;
when 25=>dd4<="00011101";--29;
when 26=>dd4<="00010101";--21;
when 27=>dd4<="00001111";--15;
when 28=>dd4<="00001010";--10;
when 29=>dd4<="00000101";--5;
when 30=>dd4<="00000010";--2;
when 31=>dd4<="00000001";--1;
when 32=>dd4<="00000000";--0;
when 33=>dd4<="00000001";--1;
when 34=>dd4<="00000010";--2;
when 35=>dd4<="00000101";--5;
when 36=>dd4<="00001010";--10;
when 37=>dd4<="00001111";--15;
when 38=>dd4<="00010101";--21;
when 39=>dd4<="00011101";--29;
when 40=>dd4<="00100101";--37;
when 41=>dd4<="00101111";--47;
when 42=>dd4<="00111001";--57;
when 43=>dd4<="01000011";--67;
when 44=>dd4<="01001111";--79;
when 45=>dd4<="01011010";--90;
when 46=>dd4<="01100111";--103;
when 47=>dd4<="01110011";--115;
when 48=>dd4<="10000000";--128;
when 49=>dd4<="10001100";--140;
when 50=>dd4<="10100101";--165;
when 51=>dd4<="10110000";--176;
when 52=>dd4<="10111100";--188;
when 53=>dd4<="11000110";--198;
when 54=>dd4<="11010000";--208;
when 55=>dd4<="11011010";--218;
when 56=>dd4<="11100010";--226;
when 57=>dd4<="11101010";--234;
when 58=>dd4<="11110000";--240;
when 59=>dd4<="11110101";--245;
when 60=>dd4<="11111010";--250;
when 61=>dd4<="11111101";--253;
when 62=>dd4<="11111110";--254;
when 63=>dd4<="11111111";--255;
when others=>null;
end case;
end process;
end architecture dacc;
----------------------------------------------------
--三角波
--
----------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity san is
port(clk_san:in std_logic;
--reset:in std_logic;
dd3:out std_logic_vector(7 downto 0));
end san;
architecture art of san is
signal b:std_logic;
signal clk3:std_logic;
signal c:std_logic_vector(7 downto 0);
begin
lcd_clk:
process(clk_san)
variable count:integer range 0 to 50000000;
variable clk1:std_logic;
begin
-- if reset='0'then
-- count:=0;
--els
if(clk_san'event and clk_san='1')then --rising_edge(clk)
--if(count="100110001001011001111111")then
--count<=(others=>'0');
if(count=24000/8)then
count:=0;
clk1:=not clk1;
else count:=count+1;
end if;
end if;
clk3<=clk1;
end process;
process(clk3)
begin
if (clk3'event and clk3='1') then
if(b='0') then
c<=c+1;
if(c=255) then
b<='1';
end if;
elsif(b='1') then
c<=c-1;
if(c=1) then
b<='0';
end if;
end if;
dd3<=c;
end if;
end process;
end art;
-----------------------------------------------------
--方波
--
------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity fan is
port(
clk_fan : in std_logic;
--reset:std_logic;
dd1: out std_logic_vector(7 downto 0));
end;
architecture dacc of fan is
signal q: integer range 1 downto 0;
signal clk1:std_logic;
begin
process(clk_fan)
variable count:integer range 0 to 50000000;
variable clk0:std_logic;
begin
-- if reset='0'then
-- count:=0;
--els
if(clk_fan'event and clk_fan='1')then --rising_edge(clk)
--if(count="100110001001011001111111")then
--count<=(others=>'0');
if(count=2400*32)then
count:=0;
clk0:=not clk0;
else count:=count+1;
end if;
end if;
clk1<=clk0;
end process;
process(clk1)
begin
if (clk1'event and clk1='1') then
q<=q+1;
end if;
end process;
process(q)
begin
case q is
when 0=>dd1<="11111111";
when 1=>dd1<="00000000";
when others=>null;
end case;
end process;
end architecture;
-------------------------------------------------------
--波形选择
--
--------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity ch is
port(cdd1,cdd3,cdd4 : in std_logic_vector (7 downto 0);
s: in std_logic_vector(1 downto 0);
y: out std_logic_vector (7 downto 0));
end entity ch;
architecture art of ch is
begin
process(s,cdd1,cdd3,cdd4)
begin
case s is
when "00"=>y<=cdd1;
when "01"=>y<=cdd1;
when "10"=>y<=cdd3;
when "11"=>y<=cdd4;
when others=>null;
end case;
end process;
end architecture art;
--------------------------------------------------------
--主模块
--
--------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity gen is
port(clk:in std_logic;
data :out std_logic_vector(7 downto 0);
s:in std_logic_vector(1 downto 0));
end gen;
architecture art of gen is
component sin
port(clk_sin:in std_logic;
dd4:out std_logic_vector(7 downto 0));
end component;
component san
port(clk_san:in std_logic;
dd3:out std_logic_vector(7 downto 0));
end component;
component fan
port(
clk_fan : in std_logic;
dd1 : out std_logic_vector(7 downto 0));
end component;
component ch
port(cdd1,cdd3,cdd4 : in std_logic_vector (7 downto 0);
s: in std_logic_vector(1 downto 0);
y: out std_logic_vector (7 downto 0));
end component;
-- component f
-- port(clk : in std_logic;
--s: in std_logic_vector(1 downto 0);
--z1,z2,z3,z4: out std_logic);
-- end component;
--signal _clk:std_logic;
-- signal ch:std_logic_vector (1 downto 0);
signal da4: std_logic_vector(7 downto 0);
signal da3: std_logic_vector(7 downto 0);
signal da1: std_logic_vector(7 downto 0);
begin
U1: sin port map(clk,da4);
U2: san port map(clk,da3);
U3: fan port map(clk,da1);
U4: ch port map(da1,da3,da4,s,data);
end architecture art;
------------------------------------------------------------------------------
testbench代码 :
-- Copyright (C) 1991-2012 Altera Corporation
-- Your use of Altera Corporation's design tools, logic functions
-- and other software and tools, and its AMPP partner logic
-- functions, and any output files from any of the foregoing
-- (including device programming or simulation files), and any
-- associated documentation or information are expressly subject
-- to the terms and conditions of the Altera Program License
-- Subscription Agreement, Altera MegaCore Function License
-- Agreement, or other applicable license agreement, including,
-- without limitation, that your use is for the sole purpose of
-- programming logic devices manufactured by Altera and sold by
-- Altera or its authorized distributors. Please refer to the
-- applicable agreement for further details.
-- ***************************************************************************
-- This file contains a Vhdl test bench template that is freely editable to
-- suit user's needs .Comments are provided in each section to help the user
-- fill out necessary details.
-- ***************************************************************************
-- Generated on "12/10/2016 11:23:16"
-- Vhdl Test Bench template for design : gen
--
-- Simulation tool : ModelSim-Altera (VHDL)
--
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY gen_vhd_tst IS
END gen_vhd_tst;
ARCHITECTURE gen_arch OF gen_vhd_tst IS
-- constants
-- signals
SIGNAL clk : STD_LOGIC;
SIGNAL data : STD_LOGIC_VECTOR(7 DOWNTO 0);
SIGNAL s : STD_LOGIC_VECTOR(1 DOWNTO 0);
COMPONENT gen
PORT (
clk : IN STD_LOGIC;
data : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
s : IN STD_LOGIC_VECTOR(1 DOWNTO 0)
);
END COMPONENT;
constant clk_period :time :=20 ns;
BEGIN
i1 : gen
PORT MAP (
-- list connections between master ports and signals
clk => clk,
data => data,
s => s
);
init : PROCESS
-- variable declarations
BEGIN
s<="11";-- code that executes only once
WAIT;
END PROCESS init;
always : PROCESS
-- optional sensitivity list
-- ( )
-- variable declarations
BEGIN
wait for clk_period/2;
clk<='1';
wait for clk_period/2;
clk<='0'; -- code executes for every event on sensitivity list
WAIT;
END PROCESS always;
END gen_arch;
萌新求助~~~哇哇哇~
一周热门 更多>