File: usrp_utils.svh

package info (click to toggle)
uhd 4.8.0.0%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 183,172 kB
  • sloc: cpp: 279,415; python: 109,850; ansic: 103,348; vhdl: 57,230; tcl: 20,007; xml: 8,581; makefile: 2,863; sh: 2,797; pascal: 230; javascript: 120; csh: 94; asm: 20; perl: 11
file content (34 lines) | stat: -rw-r--r-- 1,148 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//
// Copyright 2024 Ettus Research, a National Instruments Brand
//
// SPDX-License-Identifier: LGPL-3.0-or-later
//
// Module: usrp_utils
//
// Description:
//
//   A header file containing commonly used Verilog macros.
//

`ifndef USRP_UTILS_SVH
`define USRP_UTILS_SVH

`define ABS(X)    ((X) < (0) ? -(X) : (X))
`define MAX(X, Y) ((X) > (Y) ?  (X) : (Y))
`define MIN(X, Y) ((X) < (Y) ?  (X) : (Y))

// Ceiling of X/Y for integer operands. Use $ceil(X/Y) for real numbers.
`define DIV_CEIL(X, Y) (((X) + (Y) - 1) / (Y))
// Floor of X/Y for integer operands. Use $floor(X/Y) for real numbers.
`define DIV_FLOOR(X ,Y) ((X) / (Y))

// 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
// my_bus[47:32]. The macro is useful when the width or index is an expression.
`define BUS_I(BUS_NAME, W, I) BUS_NAME[((W)*(I)) +: (W)]

// Return a string that contains the file and line number
`define LINE_INFO $sformatf("%s: %0d", `__FILE__, `__LINE__)

`endif // USRP_UTILS_SVH