Skip to content

pzbcm_selector

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

pzbcm_selector

https://github.com/pezy-computing/pzbcm/tree/master/pzbcm_selector

Overview

This interface implements MUX/DEMUX functions.

Parameters

name type/width default value
WIDTH int 1
TYPE type logic[WIDTH-1:0]
ENTRIES int 2
SELECTOR_TYPE pzbcm_selector_type PZBCM_SELECTOR_BINARY
DEFAULT TYPE TYPE'(0)
  • WIDTH/TYPE
    • Specify width/type of the given/selected data
  • ENTRIES
    • Specify number of input entries of MUX functions/result entries of DEMUX function.
  • SELECTOR_TYPE
    • Specify type of selector which mux/demux functions implement.
  • DEFAULT
    • Specify default data for unselected entries.

Functions

priority_mux

This function implements MUX of which input select can be any bit vector.

onehot_mux

This function implements MUX of which input select is one-hot encoded.

binary_mux

This function implements MUX of which input select is binary index.

mux

This function implements MUX of which type is specified by SELECTOR_TYPE parameter.

vector_demux

This function implements DEMUX of which input select is vectorized.

binary_demux

This function implements DEMUX of which input select is binary index.

demux

This function implements DEMUX of which type is selected by SELECTOR_TYPE parameter.

Example

localparam  int WIDTH   = 4;
localparam  int ENTRIES = 4;

pzbcm_selector #(WIDTH, ENTRIES)  u_selector();

logic [ENTRIES-1:0][WIDTH-1:0]  mux_input;
logic [WIDTH-1:0]               mux_result;

initial begin
  mux_input[0]  = 2'd0;
  mux_input[1]  = 2'd1;
  mux_input[2]  = 2'd2;
  mux_input[3]  = 2'd3;

  mux_result  = u_selector.priority_mux(4'b0101, mux_input);  //  result: 0
  mux_result  = u_selector.onehot_mux(4'b0010, mux_input);    //  result: 1
  mux_result  = u_selector.binary_mux(2'd2, mux_input);       //  result: 2
end

logic [WIDTH-1:0]               demux_input;
logic [ENTRIES-1:0][WIDTH-1:0]  demux_result;

initial begin
  demux_input = 2'd3;

  demux_result  = u_selector.vector_demux(4'b1010, demux_input);  //  0: 0/1: 3/2: 0/3: 0
  demux_result  = u_selector.binary_demux(2'd3, demux_input);     //  0: 0/1: 0/2: 0/3: 3
end