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

Subversion Repositories uart2bus_testbench

[/] [uart2bus_testbench/] [trunk/] [tb/] [interfaces/] [rf_interface.sv] - Diff between revs 2 and 3

Show entire file | Details | Blame | View Log

Rev 2 Rev 3
Line 1... Line 1...
//-----------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
 
//
//
//
//                             UART2BUS VERIFICATION
//                             UART2BUS VERIFICATION
//
//
//-----------------------------------------------------------------------------
//
 
//-------------------------------------------------------------------------------------------------
// CREATOR    : HANY SALAH
// CREATOR    : HANY SALAH
// PROJECT    : UART2BUS UVM TEST BENCH
// PROJECT    : UART2BUS UVM TEST BENCH
// UNIT       : INTERFACE
// UNIT       : INTERFACE
//-----------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
// TITLE      : UART Interface
// TITLE      : REGISTER FILE BFM
// DESCRIPTION: This
// DESCRIPTION: THIS BUS FUNCTIONAL MODEL (BFM) ACTS AS ACTUAL REGISTER FILE CONNECTED TO THE DUT
//-----------------------------------------------------------------------------
//              ACROSS THE NON-STANDARD INTERFACE. IT IS IMPLEMENTED IN THE MANNER THAT APPLY THE
 
//              COMMUNICATION PROTOCOL DESCRIPED IN THE DUT MICROARCHITECTURE SPECIFICATIONS
 
//-------------------------------------------------------------------------------------------------
// 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    20012016    ADD READ BLOCK ROUTINE
// ALL COPYRIGHTS ARE RESERVED FOR THE PRODUCER ONLY .THIS FILE IS PRODUCED FOR
//    3       HANY SALAH    11022016    IMPROVE BLOCK DESCRIPTION & ADD BLOCK COMMENTS
// OPENCORES MEMBERS ONLY AND IT IS PROHIBTED TO USE THIS MATERIAL WITHOUT THE
//-------------------------------------------------------------------------------------------------
// CREATOR'S PERMISSION
// 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 CREATOR'S PERMISSION
 
//-------------------------------------------------------------------------------------------------
`include "defin_lib.svh"
`include "defin_lib.svh"
interface rf_interface (input bit clock,        // Global Clock Signal
interface rf_interface (input bit clock,        // Global Clock Signal
                        input bit reset);       // Global Asynchronous Reset Signal
                        input bit reset);       // Global Asynchronous Reset Signal
 
 
 
 
 
 
//--------------------------------
//-------------------------------------------------------------------------------------------------
//
//
//   Register File Side Signals
//   Register File Side Signals
//
//
//--------------------------------
//-------------------------------------------------------------------------------------------------
 
 
  logic [15:0]   int_address;    // Address Bus To Register File
  logic [15:0]   int_address;    // Address Bus To Register File
 
 
  logic [7:0]         int_wr_data;    // Write Data To Register File
  logic [7:0]         int_wr_data;    // Write Data To Register File
  logic               int_write;      // Write Contorl To Register File
  logic               int_write;      // Write Contorl To Register File
 
 
  logic [7:0]         int_rd_data;    // Read Data From Register File
  logic [7:0]         int_rd_data;    // Read Data From Register File
  logic               int_read;       // Read Control To Register File
  logic               int_read;       // Read Control To Register File
 
 
//--------------------------------
//-------------------------------------------------------------------------------------------------
//
//
//  CONTROL SIGNALS
//  CONTROL SIGNALS
//
//
//--------------------------------
//-------------------------------------------------------------------------------------------------
 
 
 
  // This output is set when the testbench gives the bus access to the UART DUT
  logic               int_gnt;
  logic               int_gnt;
 
 
 
  // This input is activated whenever the UART DUT request to grant the bus access
  logic               int_req;
  logic               int_req;
//--------------------------------
 
 
//-------------------------------------------------------------------------------------------------
//
//
//   Internal Variables
//   Internal Variables
//
//
//--------------------------------
//-------------------------------------------------------------------------------------------------
 
 
  // Memory of 64K bytes as Register File
  // Memory of 64K bytes as Register File
  byte       register_file [`mem_size-1:0];
  byte       register_file [`mem_size-1:0];
 
 
//--------------------------------
//-------------------------------------------------------------------------------------------------
//
//
//   Operation Blocks
//   Operation Blocks
//
//
//--------------------------------
//-------------------------------------------------------------------------------------------------
 
 
 
  // This is the main operation always block that responds to the asynchronous reset. Every clock
 
  // positive edge, it check for both int_read & int_write inputs. if the int_write is activated,
 
  // it store the data forced on the int_wr_data into the memory location defined by the address
 
  // applied on the int_address port. if the int_read is activated, it load the data stored in the
 
  // memory location defined by the address applied on the int_address port.
 
  // It's forbidden to assert both the int_write & int_read signal in the same time.
  always
  always
    begin
    begin
    @(posedge clock or posedge reset);
    @(posedge clock or posedge reset);
      begin
      begin
      if (reset)
      if (reset)
Line 79... Line 94...
        int_rd_data = read_mem_data(int_address);
        int_rd_data = read_mem_data(int_address);
        end
        end
      end
      end
    end
    end
 
 
//--------------------------------
//-------------------------------------------------------------------------------------------------
//
//
//   Non Standard Routines
//   Non Standard Routines
//
//
//--------------------------------
//-------------------------------------------------------------------------------------------------
 
 
  // fill_byte routine is a function that fill only single byte in the register
  // fill_byte routine is a function that fill only a single byte in the register file defined by
  // file
  // the input address with the single byte identified by data.
function void fill_byte (bit [`size-1:0] address,
function void fill_byte (bit [`size-1:0] address,
                         byte            data);
                         byte            data);
 
 
  register_file[address] = data;
  register_file[address] = data;
endfunction:fill_byte
endfunction:fill_byte
 
 
  // fill_block routine is a function that fill continuous block of locations
  // fill_block routine is a function that fill continuous block of locations in the register file.
  // in the register file
  // The starting address identified by the address input and the data is defined by the dynamic
 
  // array data with length equal to block_length input.
 
  // In case that the block of memory locations includes the top memory location which meant that
 
  // the memory pointer(address) will reach its highest possible value and roll to zero. The imp-
 
  // lemented function has put this point in the concern
function automatic void fill_block(bit [`size-1:0] address,
function automatic void fill_block(bit [`size-1:0] address,
                                   ref byte data [],
                                   ref byte data [],
                                   int unsigned block_length);
                                   int unsigned block_length);
 
 
    for (int unsigned index = 0; index < block_length; index++)
    for (int unsigned index = 0; index < block_length; index++)
      begin
      begin
 
        // in case that the memory pointer has rolled over. the new address will be calculated from
 
        // the following relationship
 
        // The new address = the actual address - the whole memory size.
 
        if(address+index > `mem_size-1)
 
          begin
 
          register_file[address+index-`mem_size] = data [index];
 
          end
 
        else
 
          begin
      register_file[address+index] = data [index];
      register_file[address+index] = data [index];
      end
      end
 
        end
endfunction:fill_block
endfunction:fill_block
 
 
  // reset_mem routine is a function that fill reset the register file to contents
  // reset_mem routine is a function that fill reset the register file contents to zero
  // zero
 
 function void reset_mem();
 function void reset_mem();
  for (int unsigned index = 0; index < `mem_size; index++)
  for (int unsigned index = 0; index < `mem_size; index++)
    begin
    begin
    register_file[index] = 8'b0;
    register_file[index] = 8'b0;
    end
    end
Line 119... Line 146...
  // read_mem_data routine is a function that load bus with the data content
  // read_mem_data routine is a function that load bus with the data content
  function byte read_mem_data(bit [`size-1:0] address);
  function byte read_mem_data(bit [`size-1:0] address);
    return register_file[address];
    return register_file[address];
  endfunction: read_mem_data
  endfunction: read_mem_data
 
 
 
  // This routine read adjacent block of memory location into dynamic array of data and the
 
  // starting address defined by the address input.
 
  // The point of memory pointer rolling over has been put in the consideration 
  task automatic read_block(input int unsigned data_length,
  task automatic read_block(input int unsigned data_length,
                            input bit [15:0] address,
                            input bit [15:0] address,
                            ref byte data []);
                            ref byte data []);
    data = new [data_length];
    data = new [data_length];
    for (int unsigned index=0;index
    for (int unsigned index=0;index
      begin
      begin
 
      if (address+index > `mem_size-1)
 
        begin
 
        data[index] = read_mem_data(address+index-`mem_size);
 
        end
 
      else
 
        begin
      data[index] = read_mem_data(address+index);
      data[index] = read_mem_data(address+index);
      end
      end
 
      end
  endtask:read_block
  endtask:read_block
 
 
  //-----------------------------------------
//-------------------------------------------------------------------------------------------------
  //
  //
  //        MONITOR ROUTINES
  //        MONITOR ROUTINES
  //
  //
  //-----------------------------------------
//-------------------------------------------------------------------------------------------------
 
 
 
  // This routine capture both the data and the address of the current transaction across the non-
 
  // standard interface side.
 
  // When it is called, it is blocked till the raising edge of int_gnt input. And during the high
 
  // level of int_gnt input. This routine samples both int_read and int_write inputs every positive
 
  // edge of the clock signal. If int_read is active, it realizes that the current transaction is
 
  // read and sample the int_rd_data bus at the current clock tick.
 
  // If the int_write is active, it realizes that the current transaction is write and sample the
 
  // int_wr_data bus at the current clock tick.
 
  // Note : - The transaction address is the address of the first affected memory location.
 
  //        - It's obvious that one of the signals int_read or int_write at least should be active
 
  //          when the int_gnt is active. which is implemented through the error alarm below.
  task automatic capture_transaction (output bit[`size-1:0] address,
  task automatic capture_transaction (output bit[`size-1:0] address,
                                      ref byte data []);
                                      ref byte data [],
    int index;
                                      output int unsigned data_length);
 
    int unsigned index;
    index = 0;
    index = 0;
    @(posedge int_gnt);
    @(posedge int_gnt);
    while (int_gnt)
    while (int_gnt)
      begin
      begin
      @(posedge clock);
      @(posedge clock);
Line 157... Line 206...
        begin
        begin
        data [index] = int_wr_data;
        data [index] = int_wr_data;
        end
        end
      else
      else
        begin
        begin
        $error("both int_write and int_read is inactive");
        $error("Both int_read and int_write is inactive while int_gnt is active");
        end
        end
      index++;
      index++;
 
      data_length = index;
      end
      end
  endtask:capture_transaction
  endtask:capture_transaction
endinterface:rf_interface
endinterface:rf_interface
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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