fpga: sim: Add coerce function to PkgMath

Original-commit: 1f7ea94d8f9f1b9007fa1cd1d808f385139e264d
This commit is contained in:
Niels Garibaldi
2025-02-26 22:09:04 -06:00
committed by Wade Fife
parent 1a3bdccd51
commit 2535aa4f1b
+6
View File
@@ -125,6 +125,12 @@ package PkgMath;
return b; return b;
endfunction : fmin 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) // Template Functions (For any data type)