veryl-std 0.20.3

A modern hardware description language
Documentation
pub package selector_pkg {
    enum selector_kind {
        BINARY,
        VECTOR,
        ONEHOT,
    }

    function calc_binary_select_width (
        entries: input u32,
    ) -> u32 {
        return if entries >= 2 ? $clog2(entries) : 1;
    }

    function calc_select_width (
        entries: input u32          ,
        kind   : input selector_kind,
    ) -> u32 {
        if kind == selector_kind::BINARY {
            return calc_binary_select_width(entries);
        } else {
            return entries;
        }
    }
}