Package dv_utils_pkg

Classes

Typedefs

Name

Actual Type

Description

alert_t

logic[NUM_MAX_ALERTS-1:0]

interrupt_t

logic[NUM_MAX_INTERRUPTS-1:0]

intr_vif

virtual interface pins_if#(NUM_MAX_INTERRUPTS)

typedef parameterized pins_if for ease of implementation for interrupts and alerts

uint

bit[31:0]

types & variables

uint16

bit[15:0]

uint16_t

bit[15:0]

uint32

bit[31:0]

uint32_t

bit[31:0]

uint64

bit[63:0]

uint64_t

bit[63:0]

uint8

bit[7:0]

uint8_t

bit[7:0]

TODO

The above typedefs violate the name rule, which is fixed below. Cleanup the codebase to

use the typedefs below and remove the ones above.

Enums

bus_op_e

Enum representing a bus operation type

read or write.

Enum Items:
  • BusOpWrite = 1'b0

  • BusOpRead = 1'b1

clk_freq_diff_e

Enum representing clock frequency difference on 2 clocks

Enum Items:
  • ClkFreqDiffNone

  • ClkFreqDiffSmall

  • ClkFreqDiffBig

  • ClkFreqDiffAny

compare_op_e

compare operator types

Enum Items:
  • CompareOpEq

  • CompareOpCaseEq

  • CompareOpNe

  • CompareOpCaseNe

  • CompareOpGt

  • CompareOpGe

  • CompareOpLt

  • CompareOpLe

host_req_type_e

Enum representing a type of host requests

read only, write only or random read & write

Enum Items:
  • HostReqNone = 0

  • HostReqReadOnly = 1

  • HostReqWriteOnly = 2

  • HostReqReadWrite = 3

if_mode_e

interface direction / mode

Host or Device

Enum Items:
  • Host

  • Device

signal_probe_e

Enum representing a probe operation on an internal signal.

Enum Items:
  • SignalProbeSample

    Sample the signal.

  • SignalProbeForce

    Force the signal with some value.

  • SignalProbeRelease

    Release the previous force.

Structs

typedef struct addr_range_t

mem address struct

Functions

absolute(int val)

get absolute value of the input. Usage

absolute(val) or absolute(a

b)

Parameters:

val (int)

Return type:

uint

create_seq_by_name(string seq_name)

create a sequence by name and return the handle of uvm_sequence

Parameters:

seq_name (string)

Return type:

uvm_sequence

endian_swap(logic[31:0] data)

endian swaps a 32-bit data word

Parameters:

data (logic[31:0])

endian_swap_byte_arr(bit[7:0] arr)

endian swaps bytes at a word granularity, while preserving overall word ordering.

e.g. if arr[] = '{'h0, 'h1, 'h2, 'h3, 'h4, 'h5, 'h6, 'h7}, this function will produce: '{'h3, 'h2, 'h1, 'h0, 'h7, 'h6, 'h5, 'h4}

Parameters:

arr (bit[7:0])

get_masked_data(bit[bus_params_pkg::BUS_DW-1:0] data, bit[bus_params_pkg::BUS_DBW-1:0] mask, uvm_reg csr = null)

get masked data based on provided byte mask; if csr reg handle is provided (optional) then masked bytes from csr's mirrored value are returned, else masked bytes are 0's

Parameters:
  • data (bit[bus_params_pkg::BUS_DW-1:0])

  • mask (bit[bus_params_pkg::BUS_DBW-1:0])

  • csr (uvm_reg)

get_parent_hier(string hier, int n_levels_up = 1)

Returns the hierarchical path to the interface / module N levels up.

Meant to be invoked inside a module or interface. hier: String input of the interface / module, typically $sformatf("%m"). n_levels_up: Integer number of levels up the hierarchy to omit. Example: if (hier = tb.DUT.foo.bar, n_levels_up = 2), then return tb.DUT

Parameters:
  • hier (string)

  • n_levels_up (int)

has_uvm_fatal_occurred()

return if uvm_fatal occurred

max(int int_q)

return the biggest value within the given queue of integers.

Parameters:

int_q (int)

max2(int a, int b)

return the bigger value of 2 inputs

Parameters:
  • a (int)

  • b (int)

min2(int a, int b)

return the smaller value of 2 inputs

Parameters:
  • a (int)

  • b (int)

read_vmem(string vmem_file, logic[bus_params_pkg::BUS_DW-1:0] vmem_data)

Reads VMEM file contents into a queue of data.

TODO

Add support for non-contiguous memory.

TODO: Add support for ECC bits. TODO: Add support for non-BUS_DW sized VMEM data. vmem_file: Path to VMEM image, compatible with $readmemh mathod. vmem_data: A queue of BUS_DW sized data returned to the caller.

Parameters:
  • vmem_file (string)

  • vmem_data (logic[bus_params_pkg::BUS_DW-1:0])

set_max_quit_count(int n)

Simple function to set max errors before quitting sim

Parameters:

n (int)

sw_symbol_get_addr_size(string elf_file, string symbol, bit does_not_exist_ok, longint unsigned addr, longint unsigned size)

Extracts the address and size of a const symbol in a SW test (supplied as an ELF file).

Used by a testbench to modify the given symbol in an executable (elf) generated for an embedded CPU within the DUT. This function only returns the extracted address and size of the symbol using the readelf utility. Readelf comes with binutils, a package typically available on linux machines. If not available, the assumption is, it can be relatively easily installed. The actual job of writing the new value into the symbol is handled externally (often via a backdoor mechanism to write the memory). Return 1 on success and 0 on failure.

Parameters:
  • elf_file (string)

  • symbol (string)

  • does_not_exist_ok (bit)

  • addr (longint unsigned)

  • size (longint unsigned)

Tasks

poll_for_stop(uint interval_ns = 10_000, string filename = "dv.stop")

Periodically check for the existence of a magic file (dv.stop). Exit if it exists. This provides a mechanism to gracefully kill a simulation without direct access to the process.

Parameters:
  • interval_ns (uint)

  • filename (string)