- added gigabit--mode

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@860 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
2010-04-06 18:30:31 +00:00
parent d7b6040c38
commit d1e30cfa5c
7 changed files with 151 additions and 102 deletions
+48 -27
View File
@@ -67,6 +67,8 @@ ARCHITECTURE behavior OF emac_rx IS
signal ram_en_b : std_logic;
signal ram_addr_b : word_ptr_t;
signal sipo32_din : unsigned(7 downto 0);
signal sipo32_din_vld : std_logic;
signal sipo32_dout : unsigned(31 downto 0);
signal sipo32_dout_be : unsigned(3 downto 0);
signal sipo32_dout_vld : std_logic;
@@ -78,7 +80,6 @@ ARCHITECTURE behavior OF emac_rx IS
signal sipo8_rst : std_logic;
signal sipo8_dout_vld : std_logic;
signal sipo8_dout_en : std_logic;
signal sipo8_en : std_logic;
signal byte_count_en : std_logic;
signal byte_count : word_ptr_t;
@@ -98,8 +99,12 @@ ARCHITECTURE behavior OF emac_rx IS
signal mac_chk_num_OK : natural range 0 to 6;
signal mac_chk_num_BC : natural range 0 to 6;
signal mac_chk_cnt : natural range 0 to 5;
signal mac_addr : mac_addr_t;
signal mac_chk_addr : mac_addr_t;
signal rx_en : std_logic;
signal Gbps_en : std_logic;
type host_state_t is (host_init, host_flush, host_idle);
signal host_s, host_sn : host_state_t;
@@ -108,13 +113,13 @@ ARCHITECTURE behavior OF emac_rx IS
alias cmd_mac_ok_in is cmd_fifo_din(cmd_fifo_din'left);
alias cmd_bcast_in is cmd_fifo_din(cmd_fifo_din'left-1);
alias cmd_pkt_lost_in is cmd_fifo_din(cmd_fifo_din'left-2);
alias cmd_pkt_valid_in is cmd_fifo_din(cmd_fifo_din'left-2);
alias cmd_nbytes_in is cmd_fifo_din(word_ptr_t'length-1 downto 0);
alias cmd_base_in is cmd_fifo_din(2*word_ptr_t'length-1 downto word_ptr_t'length);
alias cmd_mac_ok_out is cmd_fifo_dout(cmd_fifo_dout'left);
alias cmd_bcast_out is cmd_fifo_dout(cmd_fifo_dout'left-1);
alias cmd_pkt_lost_out is cmd_fifo_dout(cmd_fifo_dout'left-2);
alias cmd_pkt_valid_out is cmd_fifo_dout(cmd_fifo_dout'left-2);
alias cmd_nbytes_out is cmd_fifo_dout(word_ptr_t'length-1 downto 0);
alias cmd_base_out is cmd_fifo_dout(2*word_ptr_t'length-1 downto word_ptr_t'length);
@@ -122,11 +127,11 @@ begin
ctrl_out.rx_size <= resize(cmd_nbytes_out, 16);
ctrl_out.pkt_avail <= not cmd_fifo_empty;
ctrl_out.rx_er <= mii_rx_er;
ctrl_out.reset_busy <= reset_en;
ctrl_out.pkt_valid <= cmd_pkt_valid_out;
ctrl_out.pkt_bcast <= cmd_bcast_out;
ctrl_out.pkt_mac_match <= cmd_mac_ok_out;
ctrl_out.pkt_lost <= cmd_pkt_lost_out;
ctrl_out.rx_er <= mii_rx_er;
ctrl_out.reset_busy <= reset_en;
dout <= ram_dout_b;
@@ -138,15 +143,15 @@ begin
ram_addr_a <= xfer_ptr;
ram_we_a <= xfer_en and sipo32_dout_vld;
xfer_vld <= not xfer_ram_full and (mac_chk_OK or mac_chk_BC or ctrl_in.promiscious);
xfer_vld <= not xfer_ram_full and (mac_chk_OK or mac_chk_BC or xfer_promiscious);
cmd_fifo_we <= commit_en;
cmd_fifo_re <= ctrl_in.pkt_free_en;
cmd_pkt_valid_in <= '1';
cmd_mac_ok_in <= mac_chk_OK;
cmd_bcast_in <= mac_chk_BC;
cmd_nbytes_in <= byte_count_reg;
cmd_base_in <= xfer_base;
cmd_pkt_lost_in <= xfer_ram_full;
reset_en <= reset_pipe(reset_pipe'left);
@@ -188,6 +193,8 @@ host2xfer_sync_register:
begin
if rising_edge(mii_rx_clk) then
xfer_promiscious <= ctrl_in.promiscious;
Gbps_en <= ctrl_in.Gbps_en;
mac_addr <= ctrl_in.mac_addr;
end if;
end process;
@@ -253,7 +260,7 @@ byte_counter:
if rising_edge(mii_rx_clk) then
if sipo8_rst = '1' then
byte_count <= (others => '0');
elsif byte_count_en = '1' and sipo8_dout_vld = '1' then
elsif byte_count_en = '1' and sipo32_din_vld = '1' then
byte_count <= byte_count + 1;
end if;
end if;
@@ -277,13 +284,13 @@ preamble_sync_logic:
preamble_rdy <= '0';
preamble_bsy <= '0';
preamble_OK <= '0';
elsif sipo8_dout_vld = '1' then
elsif sipo32_din_vld = '1' then
if preamble_bsy = '1' then
if sipo8_dout = X"D5" then
if sipo32_din = X"D5" then
preamble_OK <= '1';
end if;
end if;
if sipo8_dout /= X"55" then
if sipo32_din /= X"55" then
preamble_bsy <= '0';
preamble_rdy <= preamble_bsy;
else
@@ -304,7 +311,7 @@ mac_check_logic:
mac_chk_cnt <= 0;
mac_chk_num_OK <= 0;
mac_chk_num_BC <= 0;
mac_chk_addr <= ctrl_in.mac_addr;
mac_chk_addr <= mac_addr;
elsif mac_chk_rdy = '1' then
if mac_chk_num_OK = 6 then
mac_chk_OK <= '1';
@@ -312,11 +319,11 @@ mac_check_logic:
if mac_chk_num_BC = 6 then
mac_chk_BC <= '1';
end if;
elsif sipo8_dout_vld = '1' then
if sipo8_dout = mac_chk_addr(mac_chk_cnt) then
elsif sipo32_din_vld = '1' then
if sipo32_din = mac_chk_addr(mac_chk_cnt) then
mac_chk_num_OK <= mac_chk_num_OK + 1;
end if;
if sipo8_dout = X"FF" then
if sipo32_din = X"FF" then
mac_chk_num_BC <= mac_chk_num_BC + 1;
end if;
if mac_chk_cnt /= 5 then
@@ -342,7 +349,7 @@ xfer_state_next:
end process;
xfer_state:
process(xfer_s, reset_en, sipo8_dout_en, sipo8_dout, sipo32_dout_en, sipo32_dout_vld, preamble_rdy, preamble_OK, xfer_ram_full, xfer_vld)
process(xfer_s, reset_en, rx_en, sipo32_dout_en, sipo32_dout_vld, preamble_rdy, preamble_OK, xfer_ram_full, xfer_vld)
begin
commit_en <= '0';
@@ -355,14 +362,14 @@ xfer_state:
preamble_rst <= reset_en;
mac_chk_rst <= reset_en;
sipo32_en <= sipo8_dout_en;
sipo32_en <= rx_en;
xfer_sn <= xfer_s;
case xfer_s is
when xfer_init =>
if sipo8_dout_en = '0' then
if rx_en = '0' then
xfer_sn <= xfer_reset;
end if;
@@ -387,22 +394,22 @@ xfer_state:
when xfer_setup =>
xfer_set <= '1';
xfer_en <= sipo32_dout_en;
byte_count_en <= sipo8_dout_en;
byte_count_en <= rx_en;
xfer_sn <= xfer_active;
when xfer_active =>
xfer_en <= sipo32_dout_en;
byte_count_en <= sipo8_dout_en;
byte_count_en <= rx_en;
if xfer_ram_full = '1' then
xfer_sn <= xfer_finish;
elsif sipo8_dout_en = '0' then
elsif rx_en = '0' then
xfer_sn <= xfer_stop;
sipo8_rst <= '1';
end if;
when xfer_stop =>
xfer_en <= sipo32_dout_en;
byte_count_en <= sipo8_dout_en;
byte_count_en <= rx_en;
if sipo32_dout_en = '0' then
xfer_sn <= xfer_finish;
end if;
@@ -471,9 +478,9 @@ inst_sipo32 : entity work.sipo
(
rst => sipo32_rst,
clk => mii_rx_clk,
din_vld => sipo8_dout_vld,
din_vld => sipo32_din_vld,
din_en => sipo32_en,
din => sipo8_dout,
din => sipo32_din,
dout_be => sipo32_dout_be,
dout_vld => sipo32_dout_vld,
dout => sipo32_dout,
@@ -481,6 +488,21 @@ inst_sipo32 : entity work.sipo
);
mii_input_register:
process(mii_rx_clk)
begin
if rising_edge(mii_rx_clk) then
if Gbps_en = '1' then
sipo32_din <= mii_rx;
sipo32_din_vld <= mii_rx_dv;
rx_en <= mii_rx_dv;
else
sipo32_din <= sipo8_dout;
sipo32_din_vld <= sipo8_dout_vld;
rx_en <= sipo8_dout_en;
end if;
end if;
end process;
inst_sipo_8bit : entity work.sipo
GENERIC MAP
@@ -494,7 +516,7 @@ inst_sipo_8bit : entity work.sipo
rst => sipo8_rst,
clk => mii_rx_clk,
din_vld => mii_rx_dv,
din_en => sipo8_en,
din_en => mii_rx_dv,
din => mii_rx(3 downto 0),
dout_be => open,
dout_vld => sipo8_dout_vld,
@@ -502,6 +524,5 @@ inst_sipo_8bit : entity work.sipo
dout_en => sipo8_dout_en
);
sipo8_en <= mii_rx_dv;
end behavior;