- improved 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@837 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
2010-03-28 17:05:09 +00:00
parent 43085119b7
commit 89b2cdc6f9
+17 -12
View File
@@ -69,12 +69,13 @@ ARCHITECTURE behavior OF pkt_gen IS
signal piso_dout : unsigned(7 downto 0); signal piso_dout : unsigned(7 downto 0);
signal piso_dout_vld : std_logic; signal piso_dout_vld : std_logic;
signal piso_10mbps_din_rdy : std_logic; signal piso_10mbps_din_rdy : std_logic;
signal tx_en : std_logic;
subtype inter_frame_gap_cnt_t is natural; subtype inter_frame_gap_cnt_t is natural;
signal inter_frame_gap_cnt : inter_frame_gap_cnt_t; signal inter_frame_gap_cnt : inter_frame_gap_cnt_t;
signal inter_frame_gap_rdy : std_logic; signal inter_frame_gap_rdy : std_logic;
type xfer_state_t is (xfer_init, xfer_idle, xfer_setup, xfer_wait, xfer_active, xfer_free); type xfer_state_t is (xfer_init, xfer_idle, xfer_setup, xfer_wait, xfer_active, xfer_uncommit, xfer_free);
signal xfer_s, xfer_sn : xfer_state_t; signal xfer_s, xfer_sn : xfer_state_t;
type piso_byte_mask_array_t is array (0 to 3) of unsigned (3 downto 0); type piso_byte_mask_array_t is array (0 to 3) of unsigned (3 downto 0);
@@ -157,13 +158,18 @@ xfer_state:
xfer_cnt_adv <= '0'; xfer_cnt_adv <= '0';
xfer_ptr_adv <= '0'; xfer_ptr_adv <= '0';
if mii_fifo_full = '0' then if mii_fifo_full = '0' then
xfer_sn <= xfer_free; xfer_sn <= xfer_uncommit;
end if; end if;
end if; end if;
when xfer_free => when xfer_uncommit =>
commit_en <= '1'; commit_en <= '1';
xfer_sn <= xfer_idle; xfer_sn <= xfer_free;
when xfer_free =>
if inter_frame_gap_rdy = '0' then
xfer_sn <= xfer_idle;
end if;
when others => when others =>
xfer_sn <= xfer_idle; xfer_sn <= xfer_idle;
@@ -192,7 +198,7 @@ pkt_params:
elsif commit_en = '1' then elsif commit_en = '1' then
uniform(seed1, seed2, krand); uniform(seed1, seed2, krand);
size := to_unsigned(PKT_SIZE_MIN + natural(real(PKT_SIZE_MAX-PKT_SIZE_MIN)*krand), word_ptr_t'length); size := to_unsigned(PKT_SIZE_MIN + natural(real(PKT_SIZE_MAX-PKT_SIZE_MIN)*krand), word_ptr_t'length);
delay := natural(PKT_DLY_MIN + real(PKT_DLY_MAX-PKT_DLY_MIN)*1.0E6*f_sysclk*krand); delay := natural(1.0E6*f_sysclk*(PKT_DLY_MIN + (PKT_DLY_MAX-PKT_DLY_MIN)*krand));
tx_packets <= tx_packets + 1; tx_packets <= tx_packets + 1;
tx_bytes <= tx_bytes + to_integer(pkt_nbytes); tx_bytes <= tx_bytes + to_integer(pkt_nbytes);
end if; end if;
@@ -208,16 +214,15 @@ pkt_params:
------------------------------------------------------------------ ------------------------------------------------------------------
interframe_gap_counter: interframe_gap_counter:
process(clk) process(mii_tx_clk)
begin begin
if rising_edge(clk) then if rising_edge(mii_tx_clk) then
if rst = '1' then if rst = '1' then
inter_frame_gap_rdy <= '1'; inter_frame_gap_rdy <= '1';
elsif mii_fifo_empty = '0' then elsif tx_en = '1' then
inter_frame_gap_rdy <= '0'; inter_frame_gap_rdy <= '0';
inter_frame_gap_cnt <= pkt_delay; inter_frame_gap_cnt <= pkt_delay;
end if; elsif inter_frame_gap_cnt /= 0 then
if inter_frame_gap_cnt /= 0 then
inter_frame_gap_cnt <= inter_frame_gap_cnt - 1; inter_frame_gap_cnt <= inter_frame_gap_cnt - 1;
else else
inter_frame_gap_rdy <= '1'; inter_frame_gap_rdy <= '1';
@@ -343,12 +348,12 @@ inst_piso_10mbps : entity work.piso
din_rdy => piso_10mbps_din_rdy, din_rdy => piso_10mbps_din_rdy,
din_be => "11", din_be => "11",
din => piso_dout, din => piso_dout,
dout_vld => mii_tx_en, dout_vld => tx_en,
dout_en => '1', dout_en => '1',
dout => mii_tx(3 downto 0) dout => mii_tx(3 downto 0)
); );
mii_tx_en <= tx_en;
mii_tx(7 downto 4) <= "0000"; mii_tx(7 downto 4) <= "0000";
end behavior; end behavior;