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

Subversion Repositories uart2bus_testbench

[/] [uart2bus_testbench/] [trunk/] [tb/] [defin_lib.svh] - Diff between revs 2 and 3

Only display areas with differences | Details | Blame | View Log

Rev 2 Rev 3
//-----------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
//
//
//                             UART2BUS VERIFICATION
//                             UART2BUS VERIFICATION
//
//
//-----------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
// CREATOR    : HANY SALAH
// CREATOR    : HANY SALAH
// PROJECT    : UART2BUS UVM TEST BENCH
// PROJECT    : UART2BUS UVM TEST BENCH
// UNIT       : DEFINITION LIBRARY
// UNIT       : DEFINITION LIBRARY
//-----------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
// TITLE      : UART Definition Library
// TITLE      : UART DEFINITION LIBRARY
// DESCRIPTION: This
// DESCRIPTION: THIS LIBRARY INCLUDES ALL THE USER MACROSES, TIMESCALE, TRANSACTION DATA TYPES,
//-----------------------------------------------------------------------------
//              GLOBAL FUNCTIONS AND CONFIGURATION DATA TYPES
 
//-------------------------------------------------------------------------------------------------
// LOG DETAILS
// LOG DETAILS
//-------------
//-------------
// VERSION      NAME        DATE        DESCRIPTION
// VERSION      NAME        DATE        DESCRIPTION
//    1       HANY SALAH    25122015    FILE CREATION
//    1       HANY SALAH    25122015    FILE CREATION
//    2       HANY SALAH    31122015    ADD DATA TYPE DEFINITIONS
//    2       HANY SALAH    31122015    ADD DATA TYPE DEFINITIONS
//    3       HANY SALAH    11012016    ADD TIMING PARAMETERS DEFINITION
//    3       HANY SALAH    11012016    ADD TIMING PARAMETERS DEFINITION
//-----------------------------------------------------------------------------
//    4       HANY SALAH    18022016    IMPROVE BLOCK DESCRIPTION
// ALL COPYRIGHTS ARE RESERVED FOR THE PRODUCER ONLY .THIS FILE IS PRODUCED FOR
//-------------------------------------------------------------------------------------------------
// OPENCORES MEMBERS ONLY AND IT IS PROHIBTED TO USE THIS MATERIAL WITHOUT THE
// ALL COPYRIGHTS ARE RESERVED FOR THE PRODUCER ONLY .THIS FILE IS PRODUCED FOR OPENCORES MEMBERS
// CREATOR'S PERMISSION
// ONLY AND IT IS PROHIBTED TO USE THIS MATERIAL WITHOUT THE CREATOR'S PERMISSION
//-----------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
 
 
`timescale 1ns/1ns
`timescale 1ns/1ns
//------------------------------------------
 
 
//-------------------------------------------------------------------------------------------------
//
//
//  Definition Identifiers
//                               Definition Identifiers
//
//
//------------------------------------------
//-------------------------------------------------------------------------------------------------
 
 
 
  // Define high value
 
  `define one 1'b1
 
 
 
  // Define low value
 
  `define zero 1'b0
 
 
  // Define size of address line
  // Define size of address line
  `define size  16
  `define size  16
  // 2 power size
  // 2 power size
  `define mem_size 65536
  `define mem_size 65536
  // ASCII of 'r'
  // ASCII of 'r'
  `define r   8'h72
  `define r   8'h72
  // ASCII of 'R'
  // ASCII of 'R'
  `define R   8'h52
  `define R   8'h52
  // ASCII of 'w'
  // ASCII of 'w'
  `define w   8'h77
  `define w   8'h77
  // ASCII of 'W'
  // ASCII of 'W'
  `define W   8'h57
  `define W   8'h57
  // BINARY COMMAND PREFIX
  // BINARY COMMAND PREFIX
  `define bin_prfx 8'h0
  `define bin_prfx 8'h0
  // Single Space
  // Single Space
  `define space 8'h20
  `define space 8'h20
  // Signel Tab
  // Signel Tab
  `define tab   8'h09
  `define tab   8'h09
  // LF
  // LF
  `define LF    8'h0A
  `define LF    8'h0A
  // CR
  // CR
  `define CR    8'h0D
  `define CR    8'h0D
  //UNIFIED ACK
  //UNIFIED ACK
  `define ACK   8'h5A
  `define ACK   8'h5A
  // work on positive edge
  // work on positive edge
  `define _posedge      1
  `define _posedge      1
  // work on negative edge
  // work on negative edge
  `define _negedge      2
  `define _negedge      2
  // start with MSB
  // start with MSB
  `define msb_first     1
  `define msb_first     1
  // start with LSB
  // start with LSB
  `define lsb_first     2
  `define lsb_first     2
  // Text Mode Command
  // Text Mode Command
  `define text_mode     1
  `define text_mode     1
  // Binary Mode Command
  // Binary Mode Command
  `define binary_mode   2
  `define binary_mode   2
 
 
  // Wrong Mode Command
  // Wrong Mode text Command
  `define wrong_mode    3
  `define wrong_mode_txt 3
 
 
 
  // Wrong Mode bin Command
 
  `define wrong_mode_binry 4
 
 
  // Read Command
  // Read Command
  `define read_comm     1
  `define read_comm     1
  // write Command
  // write Command
  `define write_comm    2
  `define write_comm    2
  // nop Command
  // nop Command
  `define nop_comm      3
  `define nop_comm      3
 
 
  // wrong Command
  // wrong Read Command
  `define wrong_comm    4
  `define wrong_comm_read 4
 
 
 
  // wrong Write Command
 
  `define wrong_comm_write 5
 
 
  // Use single white space
  // Use single white space
  `define single_space  1
  `define single_space  1
  // Use multiple white space
  // Use multiple white space
  `define tab_space     2
  `define tab_space     2
  // Use wrong space character
  // Use wrong space character
  `define space_wrong   3
  `define space_wrong   3
  // use cr as eol
  // use cr as eol
  `define cr_eol        1
  `define cr_eol        1
  // use lf as eol
  // use lf as eol
  `define lf_eol        2
  `define lf_eol        2
  // Use wrong eol
  // Use wrong eol
  `define eol_wrong     3
  `define eol_wrong     3
  // request either address increment or acknowledge
  // request either address increment or acknowledge
  `define _yes          1
  `define _yes          1
  // don't request either address increment or acknowledge
  // don't request either address increment or acknowledge
  `define _no           2
  `define _no           2
  // Use capital Leter
  // Use capital Leter
  `define capital_let   1
  `define capital_let   1
  // Use small letter
  // Use small letter
  `define small_let     2
  `define small_let     2
  // accept arbitration
  // accept arbitration
  `define accept        1
  `define accept        1
  // declain arbitration
  // declain arbitration
  `define declain       2
  `define declain       2
  // Binary represnetation
  // Binary represnetation
  `define binary_rep    1
  `define binary_rep    1
  // ASCII Representation
  // ASCII Representation
  `define ascii_rep     2
  `define ascii_rep     2
  // NOP Control
  // NOP Control
  `define nop_ctrl      2'b00
  `define nop_ctrl      2'b00
  // Read Control
  // Read Control
  `define read_ctrl     2'b01
  `define read_ctrl     2'b01
  // Write Control
  // Write Control
  `define write_ctrl    2'b10
  `define write_ctrl    2'b10
//------------------------------------------
 
 
  // Invalid Control
 
  `define invalid_ctrl  2'b11
 
 
 
  `define _parityoff    1
 
 
 
  `define _parityeven   2
 
 
 
  `define _parityodd    3
 
//-------------------------------------------------------------------------------------------------
//
//
//  Timing Defines
//                                    Timing Defines
//
//
//------------------------------------------
//-------------------------------------------------------------------------------------------------
  // Define stability time
  // Define stability time
  `define stab               10
  `define stab               10
  // Define the period of global clock in terms of ns
  // Define the period of global clock in terms of ns
  `define glob_clk_period    25
  `define glob_clk_period    25
  // Define the period of baud clock in terms of ns
  // Define the period of baud clock in terms of ns
  `define buad_clk_period    8680
  `define buad_clk_period    8680
//------------------------------------------
 
 
//-------------------------------------------------------------------------------------------------
//
//
//  Configuration Data Type
//                                Configuration Data Type
//
//
//------------------------------------------
//-------------------------------------------------------------------------------------------------
 
 
// Represents the active edge
  // Represents the active edge
typedef enum {pos_edge=1,            // Based on positive edge
  typedef enum {pos_edge=1,            // Based on positive edge
              neg_edge=2} act_edge;  // Based on negative edge
                neg_edge=2} act_edge;  // Based on negative edge
// Represent the starting bit
  // Represent the starting bit
typedef enum {msb=1,                 // Most Significant bit first
  typedef enum {msb=1,                 // Most Significant bit first
              lsb=2}  start_bit;     // Least Significant bit first
                lsb=2}  start_bit;     // Least Significant bit first
 
 
//------------------------------------------
//-------------------------------------------------------------------------------------------------
//
//
//  New Data Type Definitions
//                               New Data Type Definitions
//
//
//------------------------------------------
//-------------------------------------------------------------------------------------------------
 
 
  // Represents the mode of command to be one of the following options {text, command, wrong}. Wrong
  // Represents the mode of command to be one of the following options {text, command, wrong}.
  // command mode is used to send a tricky fault command to test our DUT.
  // Wrong command mode is used to send a tricky fault command to test our DUT.
  typedef enum {text=1,                    // Communicate using text mode
  typedef enum {text=1,                    // Communicate using text mode
                binary=2,                  // Communicate using command mode
                binary=2,                  // Communicate using command mode
                wrong_mode=3} mode;        // Communicate using wrong prefix
                wrong_mode_text=3,              // Communicate using wrong prefix(text mode)
 
                wrong_mode_bin=4} mode;         // Communicate using wrong prefix(binary mode)
 
 
  // Represents the type of the used white space to be one of the following options {single, tab, wrong}.
  // Represents the type of the used white space to be one of the following options {single, tab,
  // Wrong type also is used to push tricky byte in the text mode.
  // wrong}. Wrong type also is used to push tricky byte in the text mode.
  typedef enum {single=1,             // Using single space as a white space
  typedef enum {single=1,             // Using single space as a white space
                tab=2,                // Using tab as a white space
                tab=2,                // Using tab as a white space
                wrong_space=3} space_type;  // Using wrong white space
                wrong_space=3} space_type;  // Using wrong white space
  // Represents the type of end of line used to be one of the following choices{cr, lf, wrong}.
  // Represents the type of end of line used to be one of the following choices{cr, lf, wrong}.
  // Wrong type is also used to push DUT in tricky manner.
  // Wrong type is also used to push DUT in tricky manner.
  typedef enum {cr=1,                      // Using CR as EOL
  typedef enum {cr=1,                      // Using CR as EOL
                lf=2,                      // Using LF as EOL
                lf=2,                      // Using LF as EOL
                wrong_eol=3} eol_type;    // Using wrong EOL
                wrong_eol=3} eol_type;    // Using wrong EOL
  // Represents the command either to be one of the following choices {read, write, NOP}
  // Represents the command either to be one of the following choices {read, write, NOP}
  typedef enum {read=1,               // Read Command
  typedef enum {read=1,                     // Read Command
                write=2,              // Write Command
                write=2,                    // Write Command
                nop=3,                // Make No Operation
                nop=3,                // Make No Operation
                invalid=4} command;   // Invalid command value
                invalid_read=4,             // Invalid Command with read data
 
                invalid_write=5} command;   // Invalid Command with write data
 
 
  // Represents both acknowledge and incremental address request{yes, no}
  // Represents both acknowledge and incremental address request{yes, no}
  typedef enum {yes=1,                // Request Acknowledge
  typedef enum {yes=1,                // Request Acknowledge
                no=2} req;            // Request No Acknowledge
                no=2} req;            // Request No Acknowledge
  // Represents the type of prefix in text mode either to be {capital, small}.
  // Represents the type of prefix in text mode either to be {capital, small}.
  typedef enum {cap=1,                // Capital Letter
  typedef enum {cap=1,                // Capital Letter
                smal=2} char_type;    // Small Letter
                smal=2} char_type;    // Small Letter
  // Represents the internal bus state either {accept, refuse}
  // Represents the internal bus state either {accept, refuse}
  typedef enum {accept=1,             // Accept Bus Grant
  typedef enum {accept=1,             // Accept Bus Grant
                declain=2} arbit;     // Refuse Bus Grant
                declain=2} arbit;     // Refuse Bus Grant
  // Define mode of data {ascii or binary}
  // Define mode of data {ascii or binary}
  typedef enum {bin=1,
  typedef enum {bin=1,                // Binary Representation (data remains unchanged)
                ascii=2} data_mode;
                ascii=2} data_mode;   // ASCII Representation  (each niblle is converted into
 
                                      // ASCII byte)
 
 
  // Define mode of the used parity
  // Define mode of the used parity
  typedef enum {parity_off=1,
  typedef enum {parity_off=1,                 // Don't Add Parity Field
                parity_even=2,
                parity_even=2,                // Add Even Parity to fields
                parity_odd=3}  parity_mode ;
                parity_odd=3}  parity_mode ;  // Add Odd Parity to fields
 
 
//-------------------------------------------------------
//-------------------------------------------------------------------------------------------------
//
//
//      GLOBAL FUNCTION
//                                 GLOBAL FUNCTIONS
//
//
//-------------------------------------------------------
//-------------------------------------------------------------------------------------------------
 
 
// Binary To ASCII Conversion to convert nibble into ASCII byte through the following look-up-table
  // Binary To ASCII Conversion to convert nibble into ASCII byte through the following look-up-
 
  // table
function byte bin_asci_conv (bit[3:0] data);
function byte bin_asci_conv (bit[3:0] data);
  byte temp;
    byte temp;
  case (data)
    case (data)
    4'h0:
      4'h0:
      begin
        begin
      temp = 8'h30;
        temp = 8'h30;
      end
        end
    4'h1:
      4'h1:
      begin
        begin
      temp = 8'h31;
        temp = 8'h31;
      end
        end
    4'h2:
      4'h2:
      begin
        begin
      temp = 8'h32;
        temp = 8'h32;
      end
        end
    4'h3:
      4'h3:
      begin
        begin
      temp = 8'h33;
        temp = 8'h33;
      end
        end
    4'h4:
      4'h4:
      begin
        begin
      temp = 8'h34;
        temp = 8'h34;
      end
        end
    4'h5:
      4'h5:
      begin
        begin
      temp = 8'h35;
        temp = 8'h35;
      end
        end
    4'h6:
      4'h6:
      begin
        begin
      temp = 8'h36;
        temp = 8'h36;
      end
        end
    4'h7:
      4'h7:
      begin
        begin
      temp = 8'h37;
        temp = 8'h37;
      end
        end
    4'h8:
      4'h8:
      begin
        begin
      temp = 8'h38;
        temp = 8'h38;
      end
        end
    4'h9:
      4'h9:
      begin
        begin
      temp = 8'h39;
        temp = 8'h39;
      end
        end
    4'hA:
      4'hA:
      begin
        begin
      temp = 8'h41;
        temp = 8'h41;
      end
        end
    4'hB:
      4'hB:
      begin
        begin
      temp = 8'h42;
        temp = 8'h42;
      end
        end
    4'hC:
      4'hC:
      begin
        begin
      temp = 8'h43;
        temp = 8'h43;
      end
        end
    4'hD:
      4'hD:
      begin
        begin
      temp = 8'h44;
        temp = 8'h44;
      end
        end
    4'hE:
      4'hE:
      begin
        begin
      temp = 8'h45;
        temp = 8'h45;
      end
        end
    4'hF:
      4'hF:
      begin
        begin
      temp = 8'h46;
        temp = 8'h46;
      end
        end
  endcase
    endcase
  return temp;
    return temp;
endfunction:bin_asci_conv
  endfunction:bin_asci_conv
 
 
// ASCII To Binary Conversion is to convert ASCII byte into Binary nibble through the following Look-Up-Table
  // ASCII To Binary Conversion is to convert ASCII byte into Binary nibble through the following
 
  // Look-Up-Table
function bit [3:0] asci_bin_conv (byte data);
function bit [3:0] asci_bin_conv (byte data);
  bit [3:0] temp;
    bit [3:0] temp;
  case (data)
    case (data)
    8'h30:
      8'h30:
      begin
        begin
      temp = 4'h0;
        temp = 4'h0;
      end
        end
    8'h31:
      8'h31:
      begin
        begin
      temp = 4'h1;
        temp = 4'h1;
      end
        end
    8'h32:
      8'h32:
      begin
        begin
      temp = 4'h2;
        temp = 4'h2;
      end
        end
    8'h33:
      8'h33:
      begin
        begin
      temp = 4'h3;
        temp = 4'h3;
      end
        end
    8'h34:
      8'h34:
      begin
        begin
      temp = 4'h4;
        temp = 4'h4;
      end
        end
    8'h35:
      8'h35:
      begin
        begin
      temp = 4'h5;
        temp = 4'h5;
      end
        end
    8'h36:
      8'h36:
      begin
        begin
      temp = 4'h6;
        temp = 4'h6;
      end
        end
    8'h37:
      8'h37:
      begin
        begin
      temp = 4'h7;
        temp = 4'h7;
      end
        end
    8'h38:
      8'h38:
      begin
        begin
      temp = 4'h8;
        temp = 4'h8;
      end
        end
    8'h39:
      8'h39:
      begin
        begin
      temp = 4'h9;
        temp = 4'h9;
      end
        end
    8'h41:
      8'h41:
      begin
        begin
      temp = 4'hA;
        temp = 4'hA;
      end
        end
    8'h42:
      8'h42:
      begin
        begin
      temp = 4'hB;
        temp = 4'hB;
      end
        end
    8'h43:
      8'h43:
      begin
        begin
      temp = 4'hC;
        temp = 4'hC;
      end
        end
    8'h44:
      8'h44:
      begin
        begin
      temp = 4'hD;
        temp = 4'hD;
      end
        end
    8'h45:
      8'h45:
      begin
        begin
      temp = 4'hE;
        temp = 4'hE;
      end
        end
    8'h46:
      8'h46:
      begin
        begin
      temp = 4'hF;
        temp = 4'hF;
      end
        end
    default:
      default:
      begin
        begin
      $error("undefined ascii symbol");
        $error("undefined ascii symbol");
      end
        end
  endcase
    endcase
  return temp;
    return temp;
 
  endfunction:asci_bin_conv
 
 

powered by: WebSVN 2.1.0

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