Skip to content

pzbcm_onehot

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

pzbcm_onehot

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

Overview

This interface implements functions to treat one-hot encoded bit vector.

Parameter

name type/width default value
N int 1
  • N
    • Specify number of bits of the bit vector.

Functions

to_onehot

This function converts the given any bit vector to the one-hot encoded bit vector.

to_binary

This function converts the given one-hot encoded bit vector to the binary value.

Example

localparam  int N = 4;

pzbcm_onehot #(N) u_onehot();

logic [N-1:0]         input_vector;
logic [N-1:0]         onehot_vector;
logic [$clog2(N)-1:0] binary_value;

initial begin
  input_vector  = 4'b1010;
  onehot_vector = u_onehot.to_onehot(input_vector);   //  4'b0010
  binary_value  = u_onehot.to_binary(onehot_vector);  //  1
end
Clone this wiki locally