我使用FPGA直接向上位机传输8位不断循环自加的数据...然后通过68013不断向PC传输这些数据...可是我用Streamer观察数据的发现数据"跳"了,或者说丢失了吧。。反正不连续~请问这是什么问题?上源代码~----------------------------------------------------------------------------------
-- Company: Cypress Semiconductors
-- Engineer: Hridya Valsaraju
--
-- Create Date: 03:28:52 12/18/2009
-- Design Name: FX2LP-FPGA interface
-- Module Name: test - 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;
entity fpga_master is
Port (
fdata : inout STD_LOGIC_VECTOR(15 downto 0); -- FIFO data lines.
faddr : out STD_LOGIC_VECTOR(1 downto 0); -- FIFO select lines
slrd : out STD_LOGIC; -- Read control line
slwr : out STD_LOGIC; -- Write control line
gstate : out STD_LOGIC_VECTOR(3 downto 0); -- debug lines
flagd : in STD_LOGIC; --EP6 full flag
flaga : in STD_LOGIC; --EP2 empty flag
clk : in STD_LOGIC; --Interface Clock
sloe : out STD_LOGIC --Slave Output Enable control
);
end fpga_master;
architecture rtl of fpga_master is
signal faddr_i : STD_LOGIC_VECTOR(1 downto 0);
signal slrd_i : STD_LOGIC;
signal slwr_i : STD_LOGIC;
signal gstate_i : STD_LOGIC_VECTOR(3 downto 0);
signal MasterState : STD_LOGIC_VECTOR(3 downto 0); -- Counter to sequence the fifo signals.
signal sloe_i : STD_LOGIC;
shared variable cnt : integer range 0 to 9 := 0 ;
CONSTANT A: STD_LOGIC_VECTOR (3 DownTo 0) := "0000";
CONSTANT B: STD_LOGIC_VECTOR (3 DownTo 0) := "0001";
CONSTANT C: STD_LOGIC_VECTOR (3 DownTo 0) := "0010";
CONSTANT D: STD_LOGIC_VECTOR (3 DownTo 0) := "0011";
CONSTANT E: STD_LOGIC_VECTOR (3 DownTo 0) := "0100";
CONSTANT F: STD_LOGIC_VECTOR (3 DownTo 0) := "0101";
CONSTANT G: STD_LOGIC_VECTOR (3 DownTo 0) := "0110";
CONSTANT H: STD_LOGIC_VECTOR (3 DownTo 0) := "0111";
begin
slrd <= slrd_i;
slwr <= slwr_i;
faddr <= faddr_i;
gstate<= gstate_i;
sloe <= sloe_i;
process(clk)
variable fdatawe : natural := 0;
variable fifodatabyte : STD_LOGIC_VECTOR(15 downto 0) := "0000000000000000"; -- Local for now.
begin
if(rising_edge(clk)) then
case MasterState(3 downto 0) is
when A => -- IDLE STATE
sloe_i <= '1';
faddr_i <= "10";
slrd_i <= '1';
slwr_i <= '1';
MasterState <= E;
fdatawe := 0;
gstate_i <= "0001";
when E =>
faddr_i <= "10";
slrd_i <= '1';
sloe_i <= '1';
if (flagd = '1') then -- if Full flag is in a deasserted state
slwr_i <= '0'; --assert slave write control signal
fdatawe := 0 ;
fdata <= fifodatabyte;
fifodatabyte := fifodatabyte + '1';
MasterState <= E; -- stay in state E
else
slwr_i <= '1';
MasterState <= A; --when Full flag gets asserted, move to state A
end if;
gstate_i <= "0110";
when others =>--if an undefined state move to IDLE
faddr_i <= "00";
slrd_i <= '1';
sloe_i <= '1';
slwr_i <= '1';
gstate_i <= "1000";
MasterState <= A;
end case;
end if;
end process;
end rtl;
|