Added module for sign extension. Needs test cases

This commit is contained in:
riley committed 2026-10-13 22:24:43 +11:00
1 parent 75ef513efa
commit ac6c4cc094
1 file changed
+13
+13
View File
@@ -0,0 +1,13 @@
`ifndef SIGN_EXTENDER_H
`define SIGN_EXTENDER_H
module sign_extender #(in_width=4, out_width=5)(
input logic [0:0] op,
input logic [2**in_width-1:0] val,
output logic [2**out_width-1:0] ext_val
);
always_comb begin
assign ext_val = (op) ? {{(2**(out_width-in_width)){val[2**in_width-1]}}, val} : ({{(2**(out_width-in_width)){1'b0}}, val});
end
endmodule
`endif