-
Notifications
You must be signed in to change notification settings - Fork 5
pzbcm_selector
Taichi Ishitani edited this page Dec 26, 2022
·
2 revisions
https://github.com/pezy-computing/pzbcm/tree/master/pzbcm_selector
This interface implements MUX/DEMUX functions.
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.
- Specify type of selector which
- DEFAULT
- Specify default data for unselected entries.
This function implements MUX of which input select can be any bit vector.
This function implements MUX of which input select is one-hot encoded.
This function implements MUX of which input select is binary index.
This function implements MUX of which type is specified by SELECTOR_TYPE
parameter.
This function implements DEMUX of which input select is vectorized.
This function implements DEMUX of which input select is binary index.
This function implements DEMUX of which type is selected by SELECTOR_TYPE
parameter.
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