Forum Discussion
Altera_Forum
Honored Contributor
10 years ago --- Quote Start --- If I understand you correctly, you are reading a 24 bit signed value from a 24 bit port into a 32 bit signed variable then you have extend the most significant bit into bits 24 through 31. 1 represented with 24 bits is 0x000001, which when read as a 32 bit number is 0x00000001 which is the same. -1 represented with 24 bits is 0xffffff, which when read as a 32 bit number if 0x00ffffff which is a positive value of 16777215. When the msb is extended into bits 24 thru 31 you get 0xffffffff which is -1. --- Quote End --- Hi kflynn, Thanks so much for your reply. Yes, you understand it correctly. But, there is no way for me to define it as 24 bits since the standard are alt_8, alt_16 and alt_32. Thanks for telling me that I should extend the msb from 24 bits through 31 bits . "When the msb is extended into bits 24 thru 31 you get 0xffffffff which is -1." Could you suggest to me what can be done in order to extend the msb from 24 bits through 31 bits in C code? I program the Nios in C code. Any link or resources would be much appreciated, really thanks for your precious time. Thanks in advance.