Skip to content

pzbcm_min_max_finder

Taichi Ishitani edited this page Dec 26, 2022 · 3 revisions

pzbcm_min_max_finder

https:/pezy-computing/pzbcm/tree/master/pzbcm_min_max_finder

Overview

This interface implements functions to return the min/max value of the input values and its location.

Parameters

name tyep/width default value
ENTRIES int 1
WIDTH int 1
TYPE type logic[WIDTH-1:0]
RESULT type NA
COMPARE_WIDTH int $bits(TYPE)

Details

  • ENTRIES
    • Specify number of the input values
  • WIDTH/TYPE
    • Width/Type of the input values
  • RESULT
    • Type of the output result
    • You need to specify a struct type which has following fields
      • data
        • Contains the result.
        • Its type is TYPE.
      • location
        • Indicates which input values is selected.
        • Its type is logic[ENTRIES-1:0].
  • COMPARE_WIDTH
    • Specify how many bits of the input values are used for comparison.

Functions

find_min

This function returns the minimum value from the given input values.

find_max

This function returns the maximum value from the given input values.

Example

typedef struct packed {
  logic [1:0] data;
  logic [3:0] location;
} result_t;

pzbcm_min_max_finder #(
  .ENTRIES        (4        ),
  .WIDTH          (2        ),
  .COMPARE_WIDTH  (1        ),
  .RESULT         (result_t )
) u_min_max_finder();

logic [3:0][1:0]  input_data;
result_t          result;

initial begin
  input_data[0] = 2;
  input_data[1] = 0;
  input_data[2] = 1;
  input_data[3] = 3;

  result  = u_min_max_finder.find_min(input_data);  //  data: 2 location: 4'b0001
  result  = u_min_max_finder.find_max(input_data);  //  data: 1 location: 4'b0100
end
Clone this wiki locally