你好,我想问一下如何把数字解调后的数据读到PC端,这是部分VHDL程序
时间:10-02
整理:3721RD
点击:
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 11:13:45 03/09/2017
-- Design Name:
-- Module Name: top - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_arith.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
library UNISIM;
use UNISIM.VComponents.all;
entity top is
Port (
clk : in STD_LOGIC;
-- data_in : in STD_LOGIC_VECTOR (13 downto 0);
-- clk8k: out STD_LOGIC;--AD时钟
-- dds_rdy : OUT STD_LOGIC;
--
--
-- accumulate1_SCLR:IN STD_LOGIC;
-- accumulate1_S:OUT STD_LOGIC_VECTOR(31 downto 0);
-- accumulate2_SCLR:IN STD_LOGIC;
-- accumulate2_S:OUT STD_LOGIC_VECTOR(31 downto 0);
pdb : inout std_logic_vector(7 downto 0);
astb : in std_logic;
dstb : in std_logic;
pwr : in std_logic;
pwait: out std_logic;
Q: out STD_LOGIC_VECTOR (31 downto 0)
);
end top;
architecture Behavioral of top is
COMPONENT dds
PORT (
clk : IN STD_LOGIC;
ce : IN STD_LOGIC;
we : IN STD_LOGIC;
sclr : IN STD_LOGIC;
data : IN STD_LOGIC_VECTOR(24 DOWNTO 0);
rdy : OUT STD_LOGIC;
cosine : OUT STD_LOGIC_VECTOR(13 DOWNTO 0);
sine : OUT STD_LOGIC_VECTOR(13 DOWNTO 0);
phase_out : OUT std_logic_vector(24 downto 0)
);
END COMPONENT;
component accumulate1
port(
CLK:In STD_LOGIC;
A:IN STD_LOGIC_VECTOR(13 downto 0);
B:IN STD_LOGIC_VECTOR(13 downto 0);
CE:IN STD_LOGIC;
SCLR:IN STD_LOGIC;
S:OUT STD_LOGIC_VECTOR(31 downto 0)
);
END component;
component accumulate2
port(
CLK:In STD_LOGIC;
A:IN STD_LOGIC_VECTOR(13 downto 0);
B:IN STD_LOGIC_VECTOR(13 downto 0);
CE:IN STD_LOGIC;
SCLR:IN STD_LOGIC;
S:OUT STD_LOGIC_VECTOR(31 downto 0)
);
END component;
constant stEppReady : std_logic_vector(7 downto 0) := "0000" & "0000" ;
constant stEppAwrA : std_logic_vector(7 downto 0) := "0001" & "0100" ;
constant stEppAwrB : std_logic_vector(7 downto 0) := "0010" & "0001" ;
constant stEppArdA : std_logic_vector(7 downto 0) := "0011" & "0010" ;
constant stEppArdB : std_logic_vector(7 downto 0) := "0100" & "0011" ;
constant stEppDwrA : std_logic_vector(7 downto 0) := "0101" & "1000" ;
constant stEppDwrB : std_logic_vector(7 downto 0) := "0110" & "0001" ;
constant stEppDrdA : std_logic_vector(7 downto 0) := "0111" & "0010" ;
constant stEppDrdB : std_logic_vector(7 downto 0) := "1000" & "0011" ;
signal stEppCur : std_logic_vector(7 downto 0) := stEppReady;
signal stEppNext : std_logic_vector(7 downto 0) ;
signal clkMain : std_logic; --usb时钟
signal ctlEppWait : std_logic;
signal ctlEppAstb : std_logic;
signal ctlEppDstb : std_logic;
signal ctlEppDir : std_logic;
signal ctlEppWr : std_logic;
signal ctlEppAwr : std_logic;
signal ctlEppDwr : std_logic;
signal busEppOut : std_logic_vector(7 downto 0);
signal busEppIn : std_logic_vector(7 downto 0);
signal busEppData : std_logic_vector(7 downto 0);
signal regEppAdr : std_logic_vector(3 downto 0);
-- Registers
signal regData0 : std_logic_vector(7 downto 0);
signal regData1 : std_logic_vector(7 downto 0);
signal regData2 : std_logic_vector(7 downto 0);
signal regData3 : std_logic_vector(7 downto 0);
signal regData4 : std_logic_vector(7 downto 0);
signal regData5 : std_logic_vector(7 downto 0);
signal regData6 : std_logic_vector(7 downto 0);
signal regData7 : std_logic_vector(7 downto 0);
signal regLed : std_logic_vector(7 downto 0);
signal dout1,dout2,data_out,sine,cosine : std_logic_vector(13 downto 0);--dout1是参考sine dout2是参考cosine data_out是AD转换后序列
----signal cntr: std_logic_vector(23 downto 0);
signal dds_we,dds_sclr,dds_ce,clk_8k : std_logic;
signal accumulate1_ce,accumulate2_ce,rdy: std_logic;
signal flag: std_logic:='1';
signal dds_data,phase_out: std_logic_vector(24 downto 0);
signal dataout1,dataout2 : std_logic_vector(31 downto 0);
begin
ctlEppAstb clk_8k,
sclr=>flag,
ce=>not flag,
we =>not flag,
data => dds_data,
rdy=>rdy,
cosine => cosine,
sine => sine,
phase_out => phase_out
);
Inst_accumulate1 : accumulate1
port map (
CLK=>clk_8k, --成累加一次周期
A=>dout1,
B=>dout2,
CE=>rdy,
SCLR=> flag,
S=>dataout1
);
--Inst_accumulate2 : accumulate2
--port map (
--CLK=>clk_8k, --成累加一次周期
--A=>dout2,
--B=>data_out,
--CE=>rdy,
--SCLR=> reset,
--S=>dataout2
--);
------------------------------------------------
dout1(13)
if ctlEppAstb = '0' then
if ctlEppWr = '0' then
stEppNext
stEppNext -- xie地址线
if ctlEppAstb = '0' then
stEppNext
stEppNext
if ctlEppAstb = '0' then --读地址线
stEppNext
stEppNext --写数据线
if ctlEppDstb = '0' then
stEppNext
stEppNext
if ctlEppDstb = '0' then --写地址线
stEppNext
stEppNext <= stEppReady;
end case;
end process;
process (clk, ctlEppAwr) --?
begin
if clk = '1' and clk'Event then
if ctlEppAwr = '1' then
regEppAdr <= busEppIn (3 downto 0);
end if;
end if;
end process;
process (clk, regEppAdr, ctlEppDwr, busEppIn)
begin
if clk = '1' and clk'Event then
if ctlEppDwr = '1' and regEppAdr = "0001" then --地址为1时,写入控制第一个dds
regData1 <= dataout1(7 downto 0); --这里怎么写?
end if;
end if;
end process;
process (clk, regEppAdr, ctlEppDwr, busEppIn)
begin
if clk = '1' and clk'Event then
if ctlEppDwr = '1' and regEppAdr = "0010" then --地址为2
regData2 <= dataout1(15 downto 8);
end if;
end if;
end process;
process (clk, regEppAdr, ctlEppDwr, busEppIn)
begin
if clk= '1' and clk'Event then
if ctlEppDwr = '1' and regEppAdr = "0011" then --地址为3
regData3 <= dataout1(23 downto 16);
end if;
end if;
end process;
process (clk, regEppAdr, ctlEppDwr, busEppIn)
begin
if clk = '1' and clk'Event then
if ctlEppDwr = '1' and regEppAdr = "0100" then --地址为4
regData4 <= dataout1(31 downto 24);
end if;
end if;
end process;
Q <= dataout1;
--R <= dataout2;
dds_data <= "0000000000001000001100010"; --1k
--ad9240clk<=clk_8k;
--dds_ce<='1';
--dds_we <= '1';
--ce<='1';
--clk8k<=clk_8k;
--dds_rdy<=rdy;
--dds_sclr<=flag;
--dds_we<=not flag;
--dds_ce<=not flag;
--accumulate1_ce<=not flag;
--accumulate2_ce<=not flag;
end Behavioral;
-- Company:
-- Engineer:
--
-- Create Date: 11:13:45 03/09/2017
-- Design Name:
-- Module Name: top - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_arith.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
library UNISIM;
use UNISIM.VComponents.all;
entity top is
Port (
clk : in STD_LOGIC;
-- data_in : in STD_LOGIC_VECTOR (13 downto 0);
-- clk8k: out STD_LOGIC;--AD时钟
-- dds_rdy : OUT STD_LOGIC;
--
--
-- accumulate1_SCLR:IN STD_LOGIC;
-- accumulate1_S:OUT STD_LOGIC_VECTOR(31 downto 0);
-- accumulate2_SCLR:IN STD_LOGIC;
-- accumulate2_S:OUT STD_LOGIC_VECTOR(31 downto 0);
pdb : inout std_logic_vector(7 downto 0);
astb : in std_logic;
dstb : in std_logic;
pwr : in std_logic;
pwait: out std_logic;
Q: out STD_LOGIC_VECTOR (31 downto 0)
);
end top;
architecture Behavioral of top is
COMPONENT dds
PORT (
clk : IN STD_LOGIC;
ce : IN STD_LOGIC;
we : IN STD_LOGIC;
sclr : IN STD_LOGIC;
data : IN STD_LOGIC_VECTOR(24 DOWNTO 0);
rdy : OUT STD_LOGIC;
cosine : OUT STD_LOGIC_VECTOR(13 DOWNTO 0);
sine : OUT STD_LOGIC_VECTOR(13 DOWNTO 0);
phase_out : OUT std_logic_vector(24 downto 0)
);
END COMPONENT;
component accumulate1
port(
CLK:In STD_LOGIC;
A:IN STD_LOGIC_VECTOR(13 downto 0);
B:IN STD_LOGIC_VECTOR(13 downto 0);
CE:IN STD_LOGIC;
SCLR:IN STD_LOGIC;
S:OUT STD_LOGIC_VECTOR(31 downto 0)
);
END component;
component accumulate2
port(
CLK:In STD_LOGIC;
A:IN STD_LOGIC_VECTOR(13 downto 0);
B:IN STD_LOGIC_VECTOR(13 downto 0);
CE:IN STD_LOGIC;
SCLR:IN STD_LOGIC;
S:OUT STD_LOGIC_VECTOR(31 downto 0)
);
END component;
constant stEppReady : std_logic_vector(7 downto 0) := "0000" & "0000" ;
constant stEppAwrA : std_logic_vector(7 downto 0) := "0001" & "0100" ;
constant stEppAwrB : std_logic_vector(7 downto 0) := "0010" & "0001" ;
constant stEppArdA : std_logic_vector(7 downto 0) := "0011" & "0010" ;
constant stEppArdB : std_logic_vector(7 downto 0) := "0100" & "0011" ;
constant stEppDwrA : std_logic_vector(7 downto 0) := "0101" & "1000" ;
constant stEppDwrB : std_logic_vector(7 downto 0) := "0110" & "0001" ;
constant stEppDrdA : std_logic_vector(7 downto 0) := "0111" & "0010" ;
constant stEppDrdB : std_logic_vector(7 downto 0) := "1000" & "0011" ;
signal stEppCur : std_logic_vector(7 downto 0) := stEppReady;
signal stEppNext : std_logic_vector(7 downto 0) ;
signal clkMain : std_logic; --usb时钟
signal ctlEppWait : std_logic;
signal ctlEppAstb : std_logic;
signal ctlEppDstb : std_logic;
signal ctlEppDir : std_logic;
signal ctlEppWr : std_logic;
signal ctlEppAwr : std_logic;
signal ctlEppDwr : std_logic;
signal busEppOut : std_logic_vector(7 downto 0);
signal busEppIn : std_logic_vector(7 downto 0);
signal busEppData : std_logic_vector(7 downto 0);
signal regEppAdr : std_logic_vector(3 downto 0);
-- Registers
signal regData0 : std_logic_vector(7 downto 0);
signal regData1 : std_logic_vector(7 downto 0);
signal regData2 : std_logic_vector(7 downto 0);
signal regData3 : std_logic_vector(7 downto 0);
signal regData4 : std_logic_vector(7 downto 0);
signal regData5 : std_logic_vector(7 downto 0);
signal regData6 : std_logic_vector(7 downto 0);
signal regData7 : std_logic_vector(7 downto 0);
signal regLed : std_logic_vector(7 downto 0);
signal dout1,dout2,data_out,sine,cosine : std_logic_vector(13 downto 0);--dout1是参考sine dout2是参考cosine data_out是AD转换后序列
----signal cntr: std_logic_vector(23 downto 0);
signal dds_we,dds_sclr,dds_ce,clk_8k : std_logic;
signal accumulate1_ce,accumulate2_ce,rdy: std_logic;
signal flag: std_logic:='1';
signal dds_data,phase_out: std_logic_vector(24 downto 0);
signal dataout1,dataout2 : std_logic_vector(31 downto 0);
begin
ctlEppAstb clk_8k,
sclr=>flag,
ce=>not flag,
we =>not flag,
data => dds_data,
rdy=>rdy,
cosine => cosine,
sine => sine,
phase_out => phase_out
);
Inst_accumulate1 : accumulate1
port map (
CLK=>clk_8k, --成累加一次周期
A=>dout1,
B=>dout2,
CE=>rdy,
SCLR=> flag,
S=>dataout1
);
--Inst_accumulate2 : accumulate2
--port map (
--CLK=>clk_8k, --成累加一次周期
--A=>dout2,
--B=>data_out,
--CE=>rdy,
--SCLR=> reset,
--S=>dataout2
--);
------------------------------------------------
dout1(13)
if ctlEppAstb = '0' then
if ctlEppWr = '0' then
stEppNext
stEppNext -- xie地址线
if ctlEppAstb = '0' then
stEppNext
stEppNext
if ctlEppAstb = '0' then --读地址线
stEppNext
stEppNext --写数据线
if ctlEppDstb = '0' then
stEppNext
stEppNext
if ctlEppDstb = '0' then --写地址线
stEppNext
stEppNext <= stEppReady;
end case;
end process;
process (clk, ctlEppAwr) --?
begin
if clk = '1' and clk'Event then
if ctlEppAwr = '1' then
regEppAdr <= busEppIn (3 downto 0);
end if;
end if;
end process;
process (clk, regEppAdr, ctlEppDwr, busEppIn)
begin
if clk = '1' and clk'Event then
if ctlEppDwr = '1' and regEppAdr = "0001" then --地址为1时,写入控制第一个dds
regData1 <= dataout1(7 downto 0); --这里怎么写?
end if;
end if;
end process;
process (clk, regEppAdr, ctlEppDwr, busEppIn)
begin
if clk = '1' and clk'Event then
if ctlEppDwr = '1' and regEppAdr = "0010" then --地址为2
regData2 <= dataout1(15 downto 8);
end if;
end if;
end process;
process (clk, regEppAdr, ctlEppDwr, busEppIn)
begin
if clk= '1' and clk'Event then
if ctlEppDwr = '1' and regEppAdr = "0011" then --地址为3
regData3 <= dataout1(23 downto 16);
end if;
end if;
end process;
process (clk, regEppAdr, ctlEppDwr, busEppIn)
begin
if clk = '1' and clk'Event then
if ctlEppDwr = '1' and regEppAdr = "0100" then --地址为4
regData4 <= dataout1(31 downto 24);
end if;
end if;
end process;
Q <= dataout1;
--R <= dataout2;
dds_data <= "0000000000001000001100010"; --1k
--ad9240clk<=clk_8k;
--dds_ce<='1';
--dds_we <= '1';
--ce<='1';
--clk8k<=clk_8k;
--dds_rdy<=rdy;
--dds_sclr<=flag;
--dds_we<=not flag;
--dds_ce<=not flag;
--accumulate1_ce<=not flag;
--accumulate2_ce<=not flag;
end Behavioral;
已退回2积分