Skip to content

Instantly share code, notes, and snippets.

@smirnovich
Last active April 17, 2023 12:17
Show Gist options
  • Save smirnovich/1d03168da0a0627c08768b8a16f8d873 to your computer and use it in GitHub Desktop.
Save smirnovich/1d03168da0a0627c08768b8a16f8d873 to your computer and use it in GitHub Desktop.
simple priority encoder on SystemVerilog to check if it is synthesizable in different software
`timescale 1ns / 1ps
module prior_encod(
input logic [11:0] sw,
output logic [3:0] leds
);
always_comb begin
if (sw == 12'b0) begin
leds = 4'b0;
end else begin
for(int i=0;i<12;i++) begin
if (sw[i] == 1'b1) begin
leds = i;
end
end
end
end
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment