Skip to content

Commit

Permalink
Run rust-clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
ArhanChaudhary committed Dec 22, 2023
1 parent 57f7401 commit c9a183c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/core/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn add16(a: u16, b: u16) -> u16 {
let x13 = xor(b13, carry13);
let carry14 = or(and(b13, carry13), and(a13, x13));
let x14 = xor(b14, carry14);
return word16_16(
word16_16(
xor(a0, b0),
xor(a1, x1),
xor(a2, x2),
Expand All @@ -81,14 +81,15 @@ fn add16(a: u16, b: u16) -> u16 {
xor(a13, x13),
xor(a14, x14),
xor(a15, xor(b15, or(and(b14, carry14), and(a14, x14)))),
);
)
}

pub fn inc16(in_: u16) -> u16 {
add16(in_, 1)
}

// NOTE: combining all the bools into a single opcode doesn't seem to have any performance impact
#[allow(clippy::too_many_arguments)]
pub fn alu(x: u16, y: u16, zx: bool, nx: bool, zy: bool, ny: bool, f: bool, no: bool) -> u16 {
// zx
let x1 = mux16(x, 0, zx);
Expand Down
1 change: 1 addition & 0 deletions src/core/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ fn placebit16_0(b: bool) -> u16 {
u16_from_bool(b)
}

#[allow(clippy::too_many_arguments)]
pub fn word16_16(
a: bool,
b: bool,
Expand Down
16 changes: 8 additions & 8 deletions src/core/gates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn mux(a: bool, b: bool, sel: bool) -> bool {
}

pub fn not16(in_: u16) -> u16 {
return word16_16(
word16_16(
not(nbit16_0(in_)),
not(nbit16(in_, 1)),
not(nbit16(in_, 2)),
Expand All @@ -39,11 +39,11 @@ pub fn not16(in_: u16) -> u16 {
not(nbit16(in_, 13)),
not(nbit16(in_, 14)),
not(nbit16(in_, 15)),
);
)
}

pub fn and16(a: u16, b: u16) -> u16 {
return word16_16(
word16_16(
and(nbit16_0(a), nbit16_0(b)),
and(nbit16(a, 1), nbit16(b, 1)),
and(nbit16(a, 2), nbit16(b, 2)),
Expand All @@ -60,11 +60,11 @@ pub fn and16(a: u16, b: u16) -> u16 {
and(nbit16(a, 13), nbit16(b, 13)),
and(nbit16(a, 14), nbit16(b, 14)),
and(nbit16(a, 15), nbit16(b, 15)),
);
)
}

pub fn mux16(a: u16, b: u16, sel: bool) -> u16 {
return word16_16(
word16_16(
mux(nbit16_0(a), nbit16_0(b), sel),
mux(nbit16(a, 1), nbit16(b, 1), sel),
mux(nbit16(a, 2), nbit16(b, 2), sel),
Expand All @@ -81,11 +81,11 @@ pub fn mux16(a: u16, b: u16, sel: bool) -> u16 {
mux(nbit16(a, 13), nbit16(b, 13), sel),
mux(nbit16(a, 14), nbit16(b, 14), sel),
mux(nbit16(a, 15), nbit16(b, 15), sel),
);
)
}

pub fn is_zero(in_: u16) -> bool {
return not(or(
not(or(
nbit16(in_, 15),
or(
nbit16(in_, 14),
Expand Down Expand Up @@ -127,5 +127,5 @@ pub fn is_zero(in_: u16) -> bool {
),
),
),
));
))
}

0 comments on commit c9a183c

Please sign in to comment.