-
Notifications
You must be signed in to change notification settings - Fork 16
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
2f58ef7
commit 020e55f
Showing
3 changed files
with
62 additions
and
0 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,18 @@ | ||
(module teuc) | ||
|
||
(defcolumns | ||
(IOMF :binary) | ||
(CT :byte) | ||
(CT_MAX :byte) | ||
(DIVIDEND :i8) | ||
(DIVISOR :i8) | ||
(QUOTIENT :i8) | ||
(REST :i8) | ||
(CEIL :i8) | ||
(DONE :binary) | ||
(DIVIDEND_BYTE :byte) | ||
(DIVISOR_BYTE :byte) | ||
(QUOTIENT_BYTE :byte) | ||
(REST_BYTE :byte)) | ||
|
||
|
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,40 @@ | ||
(module teuc) | ||
|
||
(defconst | ||
MAX_INPUT_LENGTH 8) | ||
|
||
(defconstraint first-row (:domain {0}) | ||
(vanishes! IOMF)) | ||
|
||
(defconstraint heartbeat () | ||
(if-zero IOMF | ||
(begin (vanishes! DONE) | ||
(vanishes! (next CT))) | ||
(begin (eq! (next IOMF) 1) | ||
(if-zero (- CT CT_MAX) | ||
(begin (vanishes! DONE) | ||
(will-inc! CT 1)) | ||
(begin (eq! DONE 1) | ||
(vanishes! (next CT))))))) | ||
|
||
(defconstraint ctmax () | ||
(eq! (~ (- CT MAX_INPUT_LENGTH)) | ||
1)) | ||
|
||
(defconstraint last-row (:domain {-1}) | ||
(eq! DONE 1)) | ||
|
||
(defconstraint byte-decomposition () | ||
(begin (byte-decomposition CT DIVIDEND DIVIDEND_BYTE) | ||
(byte-decomposition CT DIVISOR DIVISOR_BYTE) | ||
(byte-decomposition CT QUOTIENT QUOTIENT_BYTE) | ||
(byte-decomposition CT REST REST_BYTE))) | ||
|
||
(defconstraint result (:guard DONE) | ||
(begin (eq! DIVIDEND | ||
(+ (* DIVISOR QUOTIENT) REST)) | ||
(if-zero REST | ||
(eq! CEIL QUOTIENT) | ||
(eq! CEIL (+ QUOTIENT 1))))) | ||
|
||
|