Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/cf_math_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,17 @@ package cf_math_pkg;
return (value != 0) && (value & (value - 1)) == 0;
endfunction

// Return either the argument minus 1 or 0 if 0; useful for IO vector width declaration
function automatic integer unsigned iomsb (input integer unsigned width);
return (width != 32'd0) ? unsigned'(width-1) : 32'd0;
endfunction

/// Returns the minimum between two integers
function automatic int min(int a, int b);
if (a >= b) begin
return a;
end
return b;
endfunction

endpackage