summaryrefslogtreecommitdiff
path: root/testbench/concept.cescal
blob: 67873623634123f4679d79f6b966434c31585e57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//
// Copyright (c) 2026, Chloe M.
// Provided under the BSD-3 clause
//

//
// Operations can only be performed on registers but not
// variables. Register names follow this convention:
// -----------------------------------------------------
//             r<bitwidth>:name
//
pub proc log2(v : u64) -> u64 begin
    r64:cnt = 0;
    r64:tmp = v;

    while (r64:tmp != 0) begin
        r64:tmp >>= 1;
        r64:cnt += 1;
    end

    return r64:cnt;
end