mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Support of SystemVerilog
This commit is contained in:
18
samples/SystemVerilog/priority_encoder.sv
Normal file
18
samples/SystemVerilog/priority_encoder.sv
Normal file
@@ -0,0 +1,18 @@
|
||||
// http://hdlsnippets.com/parameterized_priority_encoder
|
||||
module priority_encoder #(parameter INPUT_WIDTH=8,OUTPUT_WIDTH=3)
|
||||
(
|
||||
input logic [INPUT_WIDTH-1:0] input_data,
|
||||
output logic [OUTPUT_WIDTH-1:0] output_data
|
||||
);
|
||||
|
||||
int ii;
|
||||
|
||||
always_comb
|
||||
begin
|
||||
output_data = 'b0;
|
||||
for(ii=0;ii<INPUT_WIDTH;ii++)
|
||||
if (input_data[ii])
|
||||
output_data = ii[OUTPUT_WIDTH-1:0];
|
||||
end
|
||||
|
||||
endmodule
|
||||
Reference in New Issue
Block a user