OpenCores
URL https://opencores.org/ocsvn/ethmac/ethmac/trunk

Subversion Repositories ethmac

[/] [ethmac/] [trunk/] [bench/] [verilog/] [eth_phy.v] - Diff between revs 177 and 188

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 177 Rev 188
Line 39... Line 39...
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//
//
// CVS Revision History
// CVS Revision History
//
//
// $Log: not supported by cvs2svn $
// $Log: not supported by cvs2svn $
 
// Revision 1.3  2002/09/13 14:50:15  mohor
 
// Bug in MIIM fixed.
 
//
// Revision 1.2  2002/09/13 12:29:14  mohor
// Revision 1.2  2002/09/13 12:29:14  mohor
// Headers changed.
// Headers changed.
//
//
// Revision 1.1  2002/09/13 11:57:20  mohor
// Revision 1.1  2002/09/13 11:57:20  mohor
// New testbench. Thanks to Tadej M - "The Spammer".
// New testbench. Thanks to Tadej M - "The Spammer".
Line 820... Line 823...
reg             mtxen_d;
reg             mtxen_d;
  // collision signal set or rest within task for controling collision
  // collision signal set or rest within task for controling collision
reg             task_mcoll;
reg             task_mcoll;
  // carrier sense signal set or rest within task for controling carrier sense
  // carrier sense signal set or rest within task for controling carrier sense
reg             task_mcrs;
reg             task_mcrs;
 
reg             task_mcrs_lost;
 
  // do not generate collision in half duplex - not normal operation
 
reg             no_collision_in_half_duplex;
  // generate collision in full-duplex mode also - not normal operation
  // generate collision in full-duplex mode also - not normal operation
reg             collision_in_full_duplex;
reg             collision_in_full_duplex;
 
  // do not generate carrier sense in half duplex mode - not normal operation
 
reg             no_carrier_sense_in_tx_half_duplex;
 
reg             no_carrier_sense_in_rx_half_duplex;
  // generate carrier sense during TX in full-duplex mode also - not normal operation
  // generate carrier sense during TX in full-duplex mode also - not normal operation
reg             carrier_sense_in_tx_full_duplex;
reg             carrier_sense_in_tx_full_duplex;
 
  // do not generate carrier sense during RX in full-duplex mode - not normal operation
 
reg             no_carrier_sense_in_rx_full_duplex;
  // on RX: delay after carrier sense signal; on TX: carrier sense delayed (delay is one clock period)
  // on RX: delay after carrier sense signal; on TX: carrier sense delayed (delay is one clock period)
reg             real_carrier_sense;
reg             real_carrier_sense;
 
 
initial
initial
begin
begin
  mcrs_rx = 0;
  mcrs_rx = 0;
  mcrs_tx = 0;
  mcrs_tx = 0;
  task_mcoll = 0;
  task_mcoll = 0;
  task_mcrs = 0;
  task_mcrs = 0;
 
  task_mcrs_lost = 0;
 
  no_collision_in_half_duplex = 0;
  collision_in_full_duplex = 0;
  collision_in_full_duplex = 0;
 
  no_carrier_sense_in_tx_half_duplex = 0;
 
  no_carrier_sense_in_rx_half_duplex = 0;
  carrier_sense_in_tx_full_duplex = 0;
  carrier_sense_in_tx_full_duplex = 0;
 
  no_carrier_sense_in_rx_full_duplex = 0;
  real_carrier_sense = 0;
  real_carrier_sense = 0;
end
end
 
 
// Collision
// Collision
always@(m_rst_n_i or control_bit8_0 or collision_in_full_duplex or
always@(m_rst_n_i or control_bit8_0 or collision_in_full_duplex or
        mcrs_rx or mcrs_tx or task_mcoll
        mcrs_rx or mcrs_tx or task_mcoll or no_collision_in_half_duplex
        )
        )
begin
begin
  if (!m_rst_n_i)
  if (!m_rst_n_i)
    mcoll_o = 0;
    mcoll_o = 0;
  else
  else
  begin
  begin
    if (control_bit8_0[8]) // full duplex
    if (control_bit8_0[8]) // full duplex
    begin
    begin
      if (collision_in_full_duplex) // collision is usually not asserted in full duplex
      if (collision_in_full_duplex) // collision is usually not asserted in full duplex
      begin
      begin
        mcoll_o = (mcrs_rx && mcrs_tx) || task_mcoll;
        mcoll_o = ((mcrs_rx && mcrs_tx) || task_mcoll);
        `ifdef VERBOSE
        `ifdef VERBOSE
        if (mcrs_rx && mcrs_tx)
        if (mcrs_rx && mcrs_tx)
          $fdisplay(phy_log, "   (%0t)(%m) Collision set in FullDuplex!", $time);
          $fdisplay(phy_log, "   (%0t)(%m) Collision set in FullDuplex!", $time);
        if (task_mcoll)
        if (task_mcoll)
          $fdisplay(phy_log, "   (%0t)(%m) Collision set in FullDuplex from TASK!", $time);
          $fdisplay(phy_log, "   (%0t)(%m) Collision set in FullDuplex from TASK!", $time);
Line 870... Line 886...
        `endif
        `endif
      end
      end
    end
    end
    else // half duplex
    else // half duplex
    begin
    begin
      mcoll_o = (mcrs_rx && mcrs_tx) || task_mcoll;
      mcoll_o = ((mcrs_rx && mcrs_tx && !no_collision_in_half_duplex) ||
 
                  task_mcoll);
      `ifdef VERBOSE
      `ifdef VERBOSE
      if (mcrs_rx && mcrs_tx)
      if (mcrs_rx && mcrs_tx)
        $fdisplay(phy_log, "   (%0t)(%m) Collision set in HalfDuplex!", $time);
        $fdisplay(phy_log, "   (%0t)(%m) Collision set in HalfDuplex!", $time);
      if (task_mcoll)
      if (task_mcoll)
        $fdisplay(phy_log, "   (%0t)(%m) Collision set in HalfDuplex from TASK!", $time);
        $fdisplay(phy_log, "   (%0t)(%m) Collision set in HalfDuplex from TASK!", $time);
Line 883... Line 900...
  end
  end
end
end
 
 
// Carrier sense
// Carrier sense
always@(m_rst_n_i or control_bit8_0 or carrier_sense_in_tx_full_duplex or
always@(m_rst_n_i or control_bit8_0 or carrier_sense_in_tx_full_duplex or
        mcrs_rx or mcrs_tx or task_mcrs
        no_carrier_sense_in_rx_full_duplex or
 
        no_carrier_sense_in_tx_half_duplex or
 
        no_carrier_sense_in_rx_half_duplex or
 
        mcrs_rx or mcrs_tx or task_mcrs or task_mcrs_lost
        )
        )
begin
begin
  if (!m_rst_n_i)
  if (!m_rst_n_i)
    mcrs_o = 0;
    mcrs_o = 0;
  else
  else
  begin
  begin
    if (control_bit8_0[8]) // full duplex
    if (control_bit8_0[8]) // full duplex
    begin
    begin
      if (carrier_sense_in_tx_full_duplex) // carrier sense is usually not asserted during TX in full duplex
      if (carrier_sense_in_tx_full_duplex) // carrier sense is usually not asserted during TX in full duplex
        mcrs_o = mcrs_rx || mcrs_tx || task_mcrs;
        mcrs_o = ((mcrs_rx && !no_carrier_sense_in_rx_full_duplex) ||
 
                   mcrs_tx || task_mcrs) && !task_mcrs_lost;
      else
      else
        mcrs_o = mcrs_rx || task_mcrs;
        mcrs_o = ((mcrs_rx && !no_carrier_sense_in_rx_full_duplex) ||
 
                   task_mcrs) && !task_mcrs_lost;
    end
    end
    else // half duplex
    else // half duplex
    begin
    begin
      mcrs_o = mcrs_rx || mcrs_tx || task_mcrs;
      mcrs_o = ((mcrs_rx && !no_carrier_sense_in_rx_half_duplex) ||
 
                (mcrs_tx && !no_carrier_sense_in_tx_half_duplex) ||
 
                 task_mcrs) && !task_mcrs_lost;
    end
    end
  end
  end
end
end
 
 
// MAC TX CONTROL (RECEIVING AT PHY)
// MAC TX CONTROL (RECEIVING AT PHY)
Line 1265... Line 1289...
begin
begin
  #1 task_mcrs = test_op;
  #1 task_mcrs = test_op;
end
end
endtask
endtask
 
 
 
// Carrier sense lost - higher priority than Carrier sense task
 
task carrier_sense_lost;
 
  input   test_op;
 
begin
 
  #1 task_mcrs_lost = test_op;
 
end
 
endtask
 
 
 
// No collision detection in half duplex
 
task no_collision_hd_detect;
 
  input   test_op;
 
begin
 
  #1 no_collision_in_half_duplex = test_op;
 
end
 
endtask
 
 
// Collision detection in full duplex also
// Collision detection in full duplex also
task collision_fd_detect;
task collision_fd_detect;
  input   test_op;
  input   test_op;
begin
begin
  #1 collision_in_full_duplex = test_op;
  #1 collision_in_full_duplex = test_op;
end
end
endtask
endtask
 
 
 
// No carrier sense detection at TX in half duplex
 
task no_carrier_sense_tx_hd_detect;
 
  input   test_op;
 
begin
 
  #1 no_carrier_sense_in_tx_half_duplex = test_op;
 
end
 
endtask
 
 
 
// No carrier sense detection at RX in half duplex
 
task no_carrier_sense_rx_hd_detect;
 
  input   test_op;
 
begin
 
  #1 no_carrier_sense_in_rx_half_duplex = test_op;
 
end
 
endtask
 
 
// Carrier sense detection at TX in full duplex also
// Carrier sense detection at TX in full duplex also
task carrier_sense_tx_fd_detect;
task carrier_sense_tx_fd_detect;
  input   test_op;
  input   test_op;
begin
begin
  #1 carrier_sense_in_tx_full_duplex = test_op;
  #1 carrier_sense_in_tx_full_duplex = test_op;
end
end
endtask
endtask
 
 
// Set real delay on carrier sense signal
// No carrier sense detection at RX in full duplex
 
task no_carrier_sense_rx_fd_detect;
 
  input   test_op;
 
begin
 
  #1 no_carrier_sense_in_rx_full_duplex = test_op;
 
end
 
endtask
 
 
 
// Set real delay on carrier sense signal (and therefor collision signal)
task carrier_sense_real_delay;
task carrier_sense_real_delay;
  input   test_op;
  input   test_op;
begin
begin
  #1 real_carrier_sense = test_op;
  #1 real_carrier_sense = test_op;
end
end

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.