DPGEN_NUL(3)
β¨ DPGEN_NUL β¨ β the Zero Detector Macro-Generator, bestie edition
okay so this page is straight out of the Alliance - genlib User's Manual, and today we're learning about DPGEN_NUL, aka the girl who checks if literally everything is zero. she's a macro-generator, she's iconic, she does one job and she does it flawlessly. let's get into it π
πΈ NAME πΈ
DPGEN_NUL β Zero Detector Macro-Generator. that's it, that's the whole vibe. she looks at a pile of bits and tells you if they're all zeros. no cap.
π SYNOPSIS π
#include <genlib.h>
void GENLIB_MACRO (DPGEN_NUL, char *modelname, long flags, long N);
that's the whole incantation, bestie. include the header, call the macro, boom β you got yourself a zero detector.
π¦ DESCRIPTION π¦
Generate a N bits zero detector named modelname. N bits go in, one lil flag comes out, and that flag is screaming "yes queen, it's ALL zeros" or "nope, something's not zero in here." π«Ά
π TERMINAL NAMES π
the ports, in order, so you know exactly who's who at this sleepover:
i0: value to check (input, N bits). the thing under investigation.q: null flag (output, 1 bit). the verdict. the moment of truth.vdd: power. she needs her electrolytes. β‘vss: ground. the calm, grounded friend in every group chat.
π BEHAVIOR π
here's the actual logic, and we're keeping it character for character because it's sacred:
q <= <= '1' WHEN (i0 = X"00000000") ELSE '0';
so like β if i0 equals all those zeros, q goes '1'. otherwise '0'. simple. clean. chef's kiss. π
π₯ EXAMPLE π₯
first you generate the macro, then you instantiate it. two steps, both slay:
GENLIB_MACRO(DPGEN_NUL, "model_nul_32"
, F_BEHAV|F_PLACE
, 32
);
GENLIB_LOINS( "model_nul_32"
, "instance1_nul_32"
, "i0[31:0]"
, "q" /* Flag null. */
, "vdd", "vss", NULL
);
see how the second one wires i0[31:0] in, catches q on the way out (she's the null flag, obviously π), and gets hooked up to vdd and vss? that's the whole ritual. 32 bits of checking, one bit of truth. periodt.
heads up bestie:F_BEHAV|F_PLACEis doing heavy lifting in that first call, andNis32here β changeNand you change how many bits get checked, but thei0/q/vdd/vsslineup stays the same.
π SEE ALSO π
go read those too, iykyk. π
written under the ASIM/LIP6 banner, dated 30 July 2004 β yeah she's an elder but she still ate, and the manual page still hits. mwah πβ¨π¦
π¦ where this page comes from
- nixos 26.05: alliance 5.1.1-unstable-2025-02-24
- nixpkgs unstable: alliance 5.1.1-unstable-2025-02-24
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms