Skip to content

pzbcm_gray

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

pzbcm_gray

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

Overview

This interface implements encoder/decoder functions for Gray code.

Parameter

name type/width default value
WIDTH int 4
  • WIDTH
    • Specify width of binary/Gray code value

Functions

encode

This function encodes the given binary value to the Gray code value.

decode

This function decode the given Gray code value to the binary value.

Example

localparam  int WIDTH = 8;

logic [WIDTH-1:0] input_value;
logic [WIDTH-1:0] gray_code_value;
logic [WIDTH-1:0] bianry_value;

pzbcm_gray #(WIDTH) u_gray();

always_comb begin
  gray_code_value = u_gray.encode(input_value);
  bianry_value    = u_gray.decode(gray_code_value);
end
Clone this wiki locally