Line 46... |
Line 46... |
E_TXD : out std_logic_vector(3 downto 0)); --transmit nibble
|
E_TXD : out std_logic_vector(3 downto 0)); --transmit nibble
|
end; --entity eth_dma
|
end; --entity eth_dma
|
|
|
architecture logic of eth_dma is
|
architecture logic of eth_dma is
|
signal rec_clk : std_logic_vector(1 downto 0); --receive
|
signal rec_clk : std_logic_vector(1 downto 0); --receive
|
signal rec_valid : std_logic;
|
|
signal rec_latch : std_logic_vector(3 downto 0);
|
|
signal rec_store : std_logic_vector(31 downto 0); --to DDR
|
signal rec_store : std_logic_vector(31 downto 0); --to DDR
|
signal rec_data : std_logic_vector(27 downto 0);
|
signal rec_data : std_logic_vector(27 downto 0);
|
signal rec_cnt : std_logic_vector(2 downto 0); --nibbles
|
signal rec_cnt : std_logic_vector(2 downto 0); --nibbles
|
signal rec_words : std_logic_vector(13 downto 0);
|
signal rec_words : std_logic_vector(13 downto 0);
|
signal rec_dma : std_logic_vector(1 downto 0); --active & request
|
signal rec_dma : std_logic_vector(1 downto 0); --active & request
|
Line 69... |
Line 67... |
begin --architecture
|
begin --architecture
|
|
|
dma_proc: process(clk, reset, enable_eth, select_eth,
|
dma_proc: process(clk, reset, enable_eth, select_eth,
|
data_read, pause_in, mem_address, mem_byte_we, data_w,
|
data_read, pause_in, mem_address, mem_byte_we, data_w,
|
E_RX_CLK, E_RX_DV, E_RXD, E_TX_CLK,
|
E_RX_CLK, E_RX_DV, E_RXD, E_TX_CLK,
|
rec_clk, rec_valid, rec_latch, rec_store, rec_data,
|
rec_clk, rec_store, rec_data,
|
rec_cnt, rec_words, rec_dma, rec_done,
|
rec_cnt, rec_words, rec_dma, rec_done,
|
send_clk, send_read, send_data, send_cnt, send_words,
|
send_clk, send_read, send_data, send_cnt, send_words,
|
send_level, send_dma, send_enable)
|
send_level, send_dma, send_enable)
|
begin
|
begin
|
|
|
if rising_edge(E_RX_CLK) then
|
|
rec_valid <= E_RX_DV;
|
|
rec_latch <= E_RXD;
|
|
end if;
|
|
|
|
if reset = '1' then
|
if reset = '1' then
|
rec_clk <= "00";
|
rec_clk <= "00";
|
rec_cnt <= "000";
|
rec_cnt <= "000";
|
rec_words <= ZERO(13 downto 0);
|
rec_words <= ZERO(13 downto 0);
|
rec_dma <= "00";
|
rec_dma <= "00";
|
Line 97... |
Line 90... |
elsif rising_edge(clk) then
|
elsif rising_edge(clk) then
|
|
|
--Receive nibble on low->high E_RX_CLK. Send to DDR every 32 bits.
|
--Receive nibble on low->high E_RX_CLK. Send to DDR every 32 bits.
|
rec_clk <= rec_clk(0) & E_RX_CLK;
|
rec_clk <= rec_clk(0) & E_RX_CLK;
|
if rec_clk = "01" and enable_eth = '1' then
|
if rec_clk = "01" and enable_eth = '1' then
|
if rec_valid = '1' or rec_cnt /= "000" then
|
if E_RX_DV = '1' or rec_cnt /= "000" then
|
if rec_cnt = "111" then
|
if rec_cnt = "111" then
|
rec_store <= rec_data & rec_latch;
|
rec_store <= rec_data & E_RXD;
|
rec_dma(0) <= '1'; --request DMA
|
rec_dma(0) <= '1'; --request DMA
|
end if;
|
end if;
|
rec_data <= rec_data(23 downto 0) & rec_latch;
|
rec_data <= rec_data(23 downto 0) & E_RXD;
|
rec_cnt <= rec_cnt + 1;
|
rec_cnt <= rec_cnt + 1;
|
end if;
|
end if;
|
end if;
|
end if;
|
|
|
--Set transmit count or clear receive interrupt
|
--Set transmit count or clear receive interrupt
|
Line 141... |
Line 134... |
--Pick which type of DMA operation: bit0 = request; bit1 = active
|
--Pick which type of DMA operation: bit0 = request; bit1 = active
|
if pause_in = '0' then
|
if pause_in = '0' then
|
if rec_dma(1) = '1' then
|
if rec_dma(1) = '1' then
|
rec_dma <= "00"; --DMA done
|
rec_dma <= "00"; --DMA done
|
rec_words <= rec_words + 1;
|
rec_words <= rec_words + 1;
|
if rec_valid = '0' then
|
if E_RX_DV = '0' then
|
rec_done <= '1';
|
rec_done <= '1';
|
end if;
|
end if;
|
elsif send_dma(1) = '1' then
|
elsif send_dma(1) = '1' then
|
send_dma <= "00";
|
send_dma <= "00";
|
send_words <= send_words + 1;
|
send_words <= send_words + 1;
|