Skip to content

Commit 5852023

Browse files
committed
feat: support assembly implementation of euc
This puts in place an assembly implementation of the euc module, thereby replacing the original.
1 parent 3666fb4 commit 5852023

File tree

16 files changed

+31
-102
lines changed

16 files changed

+31
-102
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ EC_DATA_LONDON := ecdata/london
3434

3535
EC_DATA_OSAKA := ecdata/osaka
3636

37-
EUC := euc
37+
EUC := euc/euc.zkasm
3838

3939
EXP := exp/exp.zkasm
4040

blockdata/cancun/lookups/blockdata_into_euc.lisp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
(blockdata-into-euc :unchecked)
55
;; target columns
66
(
7-
euc.IOMF
87
euc.DIVIDEND
98
euc.DIVISOR
109
euc.QUOTIENT
@@ -13,7 +12,6 @@
1312
(blockdata-into-euc-selector)
1413
;; source columns
1514
(
16-
1
1715
blockdata.ARG_1_LO
1816
blockdata.ARG_2_LO
1917
blockdata.RES

blockdata/london/lookups/blockdata_into_euc.lisp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
(blockdata-into-euc :unchecked)
55
;; target columns
66
(
7-
euc.IOMF
87
euc.DIVIDEND
98
euc.DIVISOR
109
euc.QUOTIENT
@@ -13,7 +12,6 @@
1312
(blockdata-into-euc-selector)
1413
;; source columns
1514
(
16-
1
1715
blockdata.ARG_1_LO
1816
blockdata.ARG_2_LO
1917
blockdata.RES

blockdata/paris/lookups/blockdata_into_euc.lisp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
(blockdata-into-euc :unchecked)
55
;; target columns
66
(
7-
euc.IOMF
87
euc.DIVIDEND
98
euc.DIVISOR
109
euc.QUOTIENT
@@ -13,7 +12,6 @@
1312
(blockdata-into-euc-selector)
1413
;; source columns
1514
(
16-
1
1715
blockdata.ARG_1_LO
1816
blockdata.ARG_2_LO
1917
blockdata.RES

euc/columns.lisp

Lines changed: 0 additions & 17 deletions
This file was deleted.

euc/constraints.lisp

Lines changed: 0 additions & 38 deletions
This file was deleted.

euc/euc.zkasm

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
;; The Tiny Euclidean Division Module (EUC) is used for checking small
2+
;; (64-bit) divisions are correct. In addition, the function computes
3+
;; a ceiling for the quotient. NOTE: the function does not permit a
4+
;; zero divisor
5+
fn euc(DIVIDEND u64, DIVISOR=1 u64, QUOTIENT u64, REMAINDER u64) -> (CEIL u64)
6+
;; PRE: DIVISOR!=0
7+
{
8+
var val_hi, val_lo u64
9+
var tmp u64
10+
var b, c u1
11+
;; assert divisor is non-zero
12+
if DIVISOR == 0 goto exit_f
13+
;; reconstruct value from quotient / remainder
14+
val_hi,val_lo = (QUOTIENT * DIVISOR) + REMAINDER
15+
;; assert value is consistent
16+
if val_hi != 0 goto exit_f
17+
if val_lo != DIVIDEND goto exit_f
18+
;; assert remainder < divisor
19+
b, tmp = DIVISOR - REMAINDER - 1
20+
if b == 1 goto exit_f
21+
;; Compute ceiling
22+
if REMAINDER == 0 goto exit_0
23+
c, CEIL = QUOTIENT + 1
24+
return
25+
exit_0:
26+
CEIL = QUOTIENT
27+
return
28+
exit_f:
29+
fail
30+
}

euc/lookups/euc_into_wcp.lisp

Lines changed: 0 additions & 24 deletions
This file was deleted.

mmu/london/lookups/mmu_into_euc.lisp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
euc.QUOTIENT
1111
euc.REMAINDER
1212
euc.CEIL
13-
euc.DONE
1413
)
1514
;; source selector
1615
(mmu-to-euc-selector)
@@ -21,7 +20,6 @@
2120
mmu.prprc/EUC_QUOT
2221
mmu.prprc/EUC_REM
2322
mmu.prprc/EUC_CEIL
24-
1
2523
))
2624

2725

mmu/osaka/lookups/mmu_into_euc.lisp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
euc.QUOTIENT
1111
euc.REMAINDER
1212
euc.CEIL
13-
euc.DONE
1413
)
1514
;; source selector
1615
(mmu-to-euc-selector)
@@ -21,7 +20,6 @@
2120
mmu.prprc/EUC_QUOT
2221
mmu.prprc/EUC_REM
2322
mmu.prprc/EUC_CEIL
24-
1
2523
))
2624

2725

0 commit comments

Comments
 (0)