-
Notifications
You must be signed in to change notification settings - Fork 5
pzbcm_onehot
Taichi Ishitani edited this page Dec 26, 2022
·
2 revisions
https://github.com/pezy-computing/pzbcm/tree/master/pzbcm_onehot
This interface implements functions to treat one-hot encoded bit vector.
name | type/width | default value |
---|---|---|
N | int | 1 |
- N
- Specify number of bits of the bit vector.
This function converts the given any bit vector to the one-hot encoded bit vector.
This function converts the given one-hot encoded bit vector to the binary value.
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