Forum Discussion
Altera_Forum
Honored Contributor
11 years agoHow to pad or extend the most significant bit (bit 23) into bits 24 through 31
Hi, As suggested by forumer kflynn (http://www.alteraforum.com/forum/member.php?u=86819) in this link (http://www.alteraforum.com/forum/showthread.php?t=48398), the below issue can be resolved ...
Altera_Forum
Honored Contributor
11 years agosince you are using Nios, this operation could be easily converted to simple custom instruction, something like:
module ci_pad(
input dataa,
output result
);
assign result = { {8{dataa}}, dataa};
endmodule
alternatively, as PietervanderStar suggested (in C):
value = (value & (0x1 << 24)) ?
value | (0xFF << 24 ) :
value;