頭疼了老久編輯可以通過,但無法實作功能,相應mif ROM另生成。
library ieee;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
entity XHFASH is
port(rst : in std_logic;
clk : in std_logic;
M,k0,p0: in std_logic; --模式,調頻,移相位
quot: out std_logic_vector(7 downto 0));
end XHFASH ;
architecture arc of XHFASH is
signal clk1 : std_logic;
signal sel : std_logic_vector(1 downto 0):="00";
signal q_sin : std_logic_vector(7 downto 0); --sin信號
signal q_square : std_logic_vector(7 downto 0); --方波信號
signal q_sawtooth : std_logic_vector(7 downto 0); --鋸齒波信號
signal counter,p1 : std_logic_vector(7 downto 0):="00000000";
signal k1 : std_logic_vector(7 downto 0):="00000001";
signal phase_shift: std_logic_vector(7 downto 0);
component sin --這是正弦波
port (
address : IN STD_LOGIC_VECTOR (7 DOWNTO 0);
clock : IN STD_LOGIC := '1';
q : OUT STD_LOGIC_VECTOR (7 DOWNTO 0)
);
end component sin ;
component square--這是方波
port (
address : IN STD_LOGIC_VECTOR (7 DOWNTO 0);
clock : IN STD_LOGIC := '1';
q : OUT STD_LOGIC_VECTOR (7 DOWNTO 0)
);
end component square ;
component sawtooth --這是鋸齒波
port (
address : IN STD_LOGIC_VECTOR (7 DOWNTO 0);
clock : IN STD_LOGIC := '1';
q : OUT STD_LOGIC_VECTOR (7 DOWNTO 0)
);
end component sawtooth;
begin
u1:sin port map(address=>phase_shift,q=>q_sin ,clock=>clk1);
u2:square port map(address=>phase_shift,q=>q_square,clock=>clk1);
u3:sawtooth port map(address=>phase_shift,q=>q_sawtooth,clock=>clk1);
process (clk)
variable n1:integer range 0 to 2;--1953
begin
if clk'event and clk='1' then
if n1= 2 then n1:=0;--1953
elsif n1< 2 then
n1:=n1+1;--1953
elsif n1> 1 then
clk1<='1';--977
else clk1<='0';
end if;
end if;
end process; --clk1=25600hz
process
begin
wait until clk1'event and clk1='1';
if rst='0' then
K1<="00000001";P1<="00000000";
end if;
if K0='0' then
elsif K1="00001010"
then K1<="00000001";
else
K1<=K1+1;
end if;
if P0='0' then
P1<=P1+16;
end if;
end process;
process
begin --累加器描述
wait until clk1'event and clk1='1';
if rst='0' then
counter<=(others=>'0');
else counter<=counter+K1;
end if;
end process;
--相位加法器描述
process
begin
wait until clk1'event and clk1='1';
if rst='0' then
phase_shift<=(others=>'0');
else phase_shift<=counter+p1;
end if;
end process;
--資料選擇器;
process
begin
wait until clk1'event and clk1='1';
if M='0' then
elsif sel="10"
then sel<="00";
else
sel<=sel+1;
end if;
case sel is
when"00"=>quot<=q_sin ;
when"01"=>quot<=q_square;
when OTHERS=>quot<=q_sawtooth;
end case;
end process;
end arc;
uj5u.com熱心網友回復:
解決了,時鐘問題…………uj5u.com熱心網友回復:

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/123244.html
標籤:硬件設計
上一篇:單片機實作VPDN接入
下一篇:關于stm32下載程式的疑問
