-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fae5bc1
commit 1e834a2
Showing
3 changed files
with
110 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
use std::machines::binary_bb::ByteBinary; | ||
use std::machines::binary_bb::Binary16; | ||
|
||
machine Main with degree: 196608 { | ||
reg pc[@pc]; | ||
reg X0_1[<=]; | ||
reg X0_2[<=]; | ||
reg X1_1[<=]; | ||
reg X1_2[<=]; | ||
reg X2_1[<=]; | ||
reg X2_2[<=]; | ||
reg A1; | ||
reg A2; | ||
|
||
ByteBinary byte_binary; | ||
Binary16 binary(byte_binary); | ||
|
||
instr and X0_1, X0_2, X1_1, X1_2 -> X2_1, X2_2 link ~> (X2_1, X2_2) = binary.and(X0_1, X0_2, X1_1, X1_2); | ||
instr or X0_1, X0_2, X1_1, X1_2 -> X2_1, X2_2 link ~> (X2_1, X2_2) = binary.or(X0_1, X0_2, X1_1, X1_2); | ||
instr xor X0_1, X0_2, X1_1, X1_2 -> X2_1, X2_2 link ~> (X2_1, X2_2) = binary.xor(X0_1, X0_2, X1_1, X1_2); | ||
|
||
instr assert_eq X0_1, X0_2, X1_1, X1_2 { | ||
X0_1 = X1_1, | ||
X0_2 = X1_2 | ||
} | ||
|
||
function main { | ||
|
||
// AND | ||
A1, A2 <== and(0, 0, 0, 0); | ||
assert_eq A1, A2, 0, 0; | ||
A1, A2 <== and(0xffff, 0xffff, 0xffff, 0xffff); | ||
assert_eq A1, A2, 0xffff, 0xffff; | ||
A1, A2 <== and(0xffff, 0xffff, 0xabcd, 0xef01); | ||
assert_eq A1, A2, 0xabcd, 0xef01; | ||
A1, A2 <== and(0xabcd, 0xef01, 0xffff, 0xffff); | ||
assert_eq A1, A2, 0xabcd, 0xef01; | ||
A1, A2 <== and(0, 0, 0xabcd, 0xef01); | ||
assert_eq A1, A2, 0, 0; | ||
A1, A2 <== and(0xabcd, 0xef01, 0, 0); | ||
assert_eq A1, A2, 0, 0; | ||
|
||
// OR | ||
A1, A2 <== or(0, 0, 0, 0); | ||
assert_eq A1, A2, 0, 0; | ||
A1, A2 <== or(0xffff, 0xffff, 0xffff, 0xffff); | ||
assert_eq A1, A2, 0xffff, 0xffff; | ||
A1, A2 <== or(0xffff, 0xffff, 0xabcd, 0xef01); | ||
assert_eq A1, A2, 0xffff, 0xffff; | ||
A1, A2 <== or(0xabcd, 0xef01, 0xffff, 0xffff); | ||
assert_eq A1, A2, 0xffff, 0xffff; | ||
A1, A2 <== or(0, 0, 0xabcd, 0xef01); | ||
assert_eq A1, A2, 0xabcd, 0xef01; | ||
A1, A2 <== or(0xabcd, 0xef01, 0, 0); | ||
assert_eq A1, A2, 0xabcd, 0xef01; | ||
|
||
// XOR | ||
A1, A2 <== xor(0, 0, 0, 0); | ||
assert_eq A1, A2, 0, 0; | ||
A1, A2 <== xor(0xffff, 0xffff, 0xffff, 0xffff); | ||
assert_eq A1, A2, 0, 0; | ||
A1, A2 <== xor(0xffff, 0xffff, 0xabcd, 0xef01); | ||
assert_eq A1, A2, 0x5432, 0x10fe; | ||
A1, A2 <== xor(0xabcd, 0xef01, 0xffff, 0xffff); | ||
assert_eq A1, A2, 0x5432, 0x10fe; | ||
A1, A2 <== xor(0, 0, 0xabcd, 0xef01); | ||
assert_eq A1, A2, 0xabcd, 0xef01; | ||
A1, A2 <== xor(0xabcd, 0xef01, 0, 0); | ||
assert_eq A1, A2, 0xabcd, 0xef01; | ||
|
||
return; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters