int reg_addr,reg_addr_pre;
rand bit [63:0] irq_no;
reg_addr_pre =(irq_no - 28)*4;
reg_addr = reg_addr_pre + 'hC0000028
in above irq_no get random generated in decimal so by using it i have to calculate the register address which is in hexadecimal.
ex: if irq is 44 then reg_addr_pre = (44-28)*4 = 'd64
now i have to add 40 i.e hex of 'd64 to 'c0000028.
How can i achieve it. I am stuck in converting decimal to hexadecimal, as direct conversion is not possible.
Thanks,
Prakher
In reply to myselfprakhar:
Not sure what you mean. All integral variables are represented as a binary packed array of bits. You can choose a radix format for displaying their value, and you can choose a radix for numeric literals. But everything gets converted and calculated in binary.
actually in my example when i am storing (irq_no - 28)*4; in reg_addr_pre and then adding to hexadecimal value c00000028 it is not giving me as expected value.
ex for irq_no value as 32 reg_addr_pre is saving 16. and when i am adding it to c0000028 it is giving unexpected value. While expectation was 16 get converted to hex i.e. 10 and then added to the value. Last value that come will be c0000038 is expected one.
I just updated the code as reg_addr = (irq_no- 28)*4h + 'hC0000028 it is giving me expected result.