fpga: sim: Add coerce function to PkgMath
Original-commit: 1f7ea94d8f9f1b9007fa1cd1d808f385139e264d
This commit is contained in:
committed by
Wade Fife
parent
1a3bdccd51
commit
2535aa4f1b
@@ -125,6 +125,12 @@ package PkgMath;
|
||||
return b;
|
||||
endfunction : fmin
|
||||
|
||||
// Coerce from real to 16-bit signed integer
|
||||
function automatic shortint coerce_to_int16(real num);
|
||||
if (num > SHORT_MAX) return SHORT_MAX;
|
||||
if (num < SHORT_MIN) return SHORT_MIN;
|
||||
return shortint'(num);
|
||||
endfunction : coerce_to_int16
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Template Functions (For any data type)
|
||||
|
||||
Reference in New Issue
Block a user