- different IFG for gigabit and 10/100mbps
- combines MII-FIFO read delay with IFG-Function - removed IFG-counter Committed on the Free edition of March Hare Software CVSNT Server. Upgrade to CVS Suite for more features and support: http://march-hare.com/cvsnt/ git-svn-id: http://moon:8086/svn/vhdl/trunk@903 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
+42
-35
@@ -116,13 +116,9 @@ ARCHITECTURE behavior OF emac_tx IS
|
|||||||
signal mii_fifo_re : std_logic;
|
signal mii_fifo_re : std_logic;
|
||||||
signal mii_fifo_full : std_logic;
|
signal mii_fifo_full : std_logic;
|
||||||
signal mii_fifo_empty : std_logic;
|
signal mii_fifo_empty : std_logic;
|
||||||
signal mii_fifo_re_dly : unsigned(7 downto 0);
|
signal mii_fifo_re_dly : unsigned(23 downto 0);
|
||||||
|
|
||||||
subtype ifg_cnt_t is natural range 0 to 23; -- 10/100 mbps
|
signal mii_bsy : std_logic;
|
||||||
-- subtype ifg_cnt_t is natural range 0 to 11; -- 1000 mbps
|
|
||||||
|
|
||||||
signal ifg_cnt : ifg_cnt_t;
|
|
||||||
signal ifg_idle : std_logic;
|
|
||||||
|
|
||||||
type host_state_t is (host_init, host_idle, host_alloc, host_setup, host_arm, host_fill, host_commit);
|
type host_state_t is (host_init, host_idle, host_alloc, host_setup, host_arm, host_fill, host_commit);
|
||||||
signal host_s, host_sn : host_state_t;
|
signal host_s, host_sn : host_state_t;
|
||||||
@@ -340,6 +336,7 @@ mem_free_counter:
|
|||||||
end if;
|
end if;
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
|
------------------------------------------------------------------
|
||||||
mem_free_mii:
|
mem_free_mii:
|
||||||
process(mii_tx_clk)
|
process(mii_tx_clk)
|
||||||
begin
|
begin
|
||||||
@@ -356,6 +353,7 @@ mem_free_mii:
|
|||||||
end if;
|
end if;
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
|
------------------------------------------------------------------
|
||||||
mem_free_host:
|
mem_free_host:
|
||||||
process(clk)
|
process(clk)
|
||||||
begin
|
begin
|
||||||
@@ -373,15 +371,6 @@ mem_free_host:
|
|||||||
end if;
|
end if;
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
host2xfer_sync_register:
|
|
||||||
process(mii_tx_clk)
|
|
||||||
begin
|
|
||||||
if rising_edge(mii_tx_clk) then
|
|
||||||
Gbps_en <= ctrl_in.Gbps_en;
|
|
||||||
fcs_gen_en <= ctrl_in.fcs_gen_en;
|
|
||||||
end if;
|
|
||||||
end process;
|
|
||||||
|
|
||||||
------------------------------------------------------------------
|
------------------------------------------------------------------
|
||||||
-- Fill stuff
|
-- Fill stuff
|
||||||
------------------------------------------------------------------
|
------------------------------------------------------------------
|
||||||
@@ -411,6 +400,7 @@ fill_counter:
|
|||||||
end if;
|
end if;
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
|
------------------------------------------------------------------
|
||||||
fill_pointer:
|
fill_pointer:
|
||||||
process(clk)
|
process(clk)
|
||||||
begin
|
begin
|
||||||
@@ -426,20 +416,14 @@ fill_pointer:
|
|||||||
------------------------------------------------------------------
|
------------------------------------------------------------------
|
||||||
-- Transfer stuff
|
-- Transfer stuff
|
||||||
------------------------------------------------------------------
|
------------------------------------------------------------------
|
||||||
interframe_gap_counter:
|
host2xfer_sync_register:
|
||||||
process(mii_tx_clk)
|
process(mii_tx_clk)
|
||||||
begin
|
begin
|
||||||
if rising_edge(mii_tx_clk) then
|
if rising_edge(mii_tx_clk) then
|
||||||
ifg_idle <= '0';
|
Gbps_en <= ctrl_in.Gbps_en;
|
||||||
if reset_en = '1' or mii_fifo_empty = '0' then
|
fcs_gen_en <= ctrl_in.fcs_gen_en;
|
||||||
ifg_cnt <= ifg_cnt_t'high;
|
end if;
|
||||||
elsif ifg_cnt /= 0 then
|
end process;
|
||||||
ifg_cnt <= ifg_cnt - 1;
|
|
||||||
else
|
|
||||||
ifg_idle <= '1';
|
|
||||||
end if;
|
|
||||||
end if;
|
|
||||||
end process;
|
|
||||||
|
|
||||||
------------------------------------------------------------------
|
------------------------------------------------------------------
|
||||||
xfer_counter:
|
xfer_counter:
|
||||||
@@ -465,6 +449,7 @@ xfer_counter:
|
|||||||
|
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
|
------------------------------------------------------------------
|
||||||
xfer_pointer:
|
xfer_pointer:
|
||||||
process(mii_tx_clk)
|
process(mii_tx_clk)
|
||||||
begin
|
begin
|
||||||
@@ -494,7 +479,7 @@ xfer_state_next:
|
|||||||
end process;
|
end process;
|
||||||
|
|
||||||
xfer_state:
|
xfer_state:
|
||||||
process(xfer_s, ifg_idle, cmd_fifo_empty, piso32_din_rdy, piso32_dout_vld, xfer_bsy, fcs_gen_en)
|
process(xfer_s, mii_bsy, cmd_fifo_empty, piso32_din_rdy, piso32_dout_vld, xfer_bsy, fcs_gen_en)
|
||||||
begin
|
begin
|
||||||
|
|
||||||
piso32_din_vld <= '0';
|
piso32_din_vld <= '0';
|
||||||
@@ -515,12 +500,12 @@ xfer_state:
|
|||||||
xfer_sn <= xfer_idle;
|
xfer_sn <= xfer_idle;
|
||||||
|
|
||||||
when xfer_idle =>
|
when xfer_idle =>
|
||||||
if cmd_fifo_empty = '0' then
|
if cmd_fifo_empty = '0' and mii_bsy = '0' then
|
||||||
xfer_sn <= xfer_start;
|
xfer_sn <= xfer_start;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
when xfer_start =>
|
when xfer_start =>
|
||||||
if cmd_fifo_empty = '0' and ifg_idle = '1' then
|
if cmd_fifo_empty = '0' then
|
||||||
xfer_sn <= xfer_preamble0;
|
xfer_sn <= xfer_preamble0;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
@@ -596,6 +581,7 @@ inst_ram : entity work.dpram_1w1r
|
|||||||
dout_b => ram_dout_b
|
dout_b => ram_dout_b
|
||||||
);
|
);
|
||||||
|
|
||||||
|
------------------------------------------------------------------
|
||||||
-- Instantiate synchronous FIFO
|
-- Instantiate synchronous FIFO
|
||||||
inst_cmd_fifo: entity work.fifo_async
|
inst_cmd_fifo: entity work.fifo_async
|
||||||
GENERIC MAP
|
GENERIC MAP
|
||||||
@@ -619,6 +605,7 @@ inst_cmd_fifo: entity work.fifo_async
|
|||||||
data_r => cmd_fifo_dout
|
data_r => cmd_fifo_dout
|
||||||
);
|
);
|
||||||
|
|
||||||
|
------------------------------------------------------------------
|
||||||
inst_piso32 : entity work.piso
|
inst_piso32 : entity work.piso
|
||||||
GENERIC MAP
|
GENERIC MAP
|
||||||
(
|
(
|
||||||
@@ -642,6 +629,7 @@ inst_piso32 : entity work.piso
|
|||||||
|
|
||||||
piso32_dout_en <= not mii_fifo_full; --'1' when Gbps_en = '1' else piso8_din_rdy;
|
piso32_dout_en <= not mii_fifo_full; --'1' when Gbps_en = '1' else piso8_din_rdy;
|
||||||
|
|
||||||
|
------------------------------------------------------------------
|
||||||
fcs_enable_gen:
|
fcs_enable_gen:
|
||||||
process(mii_tx_clk)
|
process(mii_tx_clk)
|
||||||
begin
|
begin
|
||||||
@@ -653,8 +641,8 @@ fcs_enable_gen:
|
|||||||
end if;
|
end if;
|
||||||
end if;
|
end if;
|
||||||
end process;
|
end process;
|
||||||
fcs_din_vld <= fcs_en(fcs_en'left) and piso32_dout_vld and piso32_dout_en;
|
|
||||||
|
------------------------------------------------------------------
|
||||||
inst_fcs: entity work.crc32
|
inst_fcs: entity work.crc32
|
||||||
GENERIC MAP
|
GENERIC MAP
|
||||||
(
|
(
|
||||||
@@ -671,17 +659,29 @@ inst_fcs: entity work.crc32
|
|||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
fcs_din_vld <= fcs_en(fcs_en'left) and piso32_dout_vld and piso32_dout_en;
|
||||||
|
|
||||||
|
------------------------------------------------------------------
|
||||||
|
-- ensures continous MII-data stream and also acts as Inter Frame Gap delay
|
||||||
mii_fifo_re_dly_gen:
|
mii_fifo_re_dly_gen:
|
||||||
process(mii_tx_clk)
|
process(mii_tx_clk)
|
||||||
begin
|
begin
|
||||||
if rising_edge(mii_tx_clk) then
|
if rising_edge(mii_tx_clk) then
|
||||||
mii_fifo_re_dly <= mii_fifo_re_dly(mii_fifo_re_dly'left-1 downto 0) & not mii_fifo_empty;
|
if mii_fifo_empty = '1' then
|
||||||
|
if Gbps_en = '0' then
|
||||||
|
mii_fifo_re_dly <= X"000000"; -- 100 mbps
|
||||||
|
else
|
||||||
|
mii_fifo_re_dly <= X"000FFF"; -- Gigabit
|
||||||
|
end if;
|
||||||
|
else
|
||||||
|
mii_fifo_re_dly <= mii_fifo_re_dly(mii_fifo_re_dly'left-1 downto 0) & not mii_fifo_empty;
|
||||||
|
end if;
|
||||||
end if;
|
end if;
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
mii_fifo_re <= mii_fifo_re_dly(mii_fifo_re_dly'left) when Gbps_en = '1' else (piso8_din_rdy and mii_fifo_re_dly(mii_fifo_re_dly'left));
|
mii_bsy <= mii_fifo_re_dly(mii_fifo_re_dly'left);
|
||||||
mii_fifo_we <= piso32_dout_vld;
|
|
||||||
|
|
||||||
|
------------------------------------------------------------------
|
||||||
-- Instantiate synchronous FIFO
|
-- Instantiate synchronous FIFO
|
||||||
inst_mii_fifo: entity work.fifo_sync
|
inst_mii_fifo: entity work.fifo_sync
|
||||||
GENERIC MAP
|
GENERIC MAP
|
||||||
@@ -704,6 +704,10 @@ inst_mii_fifo: entity work.fifo_sync
|
|||||||
data_r => piso8_din
|
data_r => piso8_din
|
||||||
);
|
);
|
||||||
|
|
||||||
|
mii_fifo_re <= mii_bsy when Gbps_en = '1' else (piso8_din_rdy and mii_bsy);
|
||||||
|
mii_fifo_we <= piso32_dout_vld;
|
||||||
|
|
||||||
|
------------------------------------------------------------------
|
||||||
inst_piso8 : entity work.piso
|
inst_piso8 : entity work.piso
|
||||||
GENERIC MAP
|
GENERIC MAP
|
||||||
(
|
(
|
||||||
@@ -724,8 +728,10 @@ inst_piso8 : entity work.piso
|
|||||||
dout => piso8_dout
|
dout => piso8_dout
|
||||||
|
|
||||||
);
|
);
|
||||||
piso8_din_vld <= not mii_fifo_empty and mii_fifo_re_dly(mii_fifo_re_dly'left);
|
|
||||||
|
piso8_din_vld <= not mii_fifo_empty and mii_bsy;
|
||||||
|
|
||||||
|
------------------------------------------------------------------
|
||||||
mii_output_register:
|
mii_output_register:
|
||||||
process(mii_tx_clk)
|
process(mii_tx_clk)
|
||||||
begin
|
begin
|
||||||
@@ -741,4 +747,5 @@ mii_output_register:
|
|||||||
end if;
|
end if;
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
|
------------------------------------------------------------------
|
||||||
end behavior;
|
end behavior;
|
||||||
|
|||||||
Reference in New Issue
Block a user