From c637f538fa37037f2c8845bfdd9ab9e0d182094c Mon Sep 17 00:00:00 2001 From: Wade Fife Date: Wed, 18 Dec 2024 13:06:47 -0600 Subject: [PATCH] fpga: lib: Add TO_SIGNED to usrp_utils.svh Original-commit: c4eaadfaca97490d68f7b4702f009eb50252d0dc --- lib/control/usrp_utils.svh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/control/usrp_utils.svh b/lib/control/usrp_utils.svh index 1cfc6b7..fdfbc30 100644 --- a/lib/control/usrp_utils.svh +++ b/lib/control/usrp_utils.svh @@ -22,6 +22,10 @@ // Floor of X/Y for integer operands. Use $floor(X/Y) for real numbers. `define DIV_FLOOR(X ,Y) ((X) / (Y)) +// Convert an unsigned number to a signed number. Note that this requires +// lengthening the value by one bit to allow for the sign. +`define TO_SIGNED(X) (signed'({1'b0, (X)})) + // Shorthand to get the I'th port of a concatenated bus. For example, if a bus // contains four 16-bit ports, you can get the 3rd port (port 2) using the // macro call `BUS_I(my_bus, 16, 2), which is equivalent to my_bus[32+:16], or