all_ones = !0; u8 = unsigned(8); s4 = signed(4); fn inv(input: u8) -> (output1: u8, output2: u8) { .output1 = !input; .output2 = input ^ x; x = all_ones; } fn arith(a: u8, b: u8, c: s4) -> (x: u8, y: u8, z: bit) { c = .c + 2; .x = a + b - c as integer; .y = (x * b) as u8; .z = x <= y as integer; } fn mux(a: u8, opt: unsigned(3)) -> (y: u8) { .y = y; match opt { 0 => { .y = a; } 1, 2 => { .y = !a; } 3 => { .y = 3; } } else { .y = a ^ 0b10100101; } } fn counter( clk: bit, aclear: bit, enable: bit, ) -> ( val: unsigned(4), ) { .val = val; !aclear => val = 0 as unsigned(4); @clk => val = next; if enable { .next = val + 1; } else { .next = val; } }