Skip to content

Commit

Permalink
added all the examples used in my presentation
Browse files Browse the repository at this point in the history
use the makefile in examples_pk/presentation to run them after installing pk2000
the symmetry examples does not work, because one variable can't have multiple slot accesses at the same time. therefore, there can't be a symmetry check this way.
  • Loading branch information
Lars committed Nov 15, 2012
1 parent ff62d08 commit 868324b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples_pk/presentation/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
all:
ruby ../../pkc.rb -i inc.pk
echo "\n\nputs \"* Increment function\"\nputs \" inc(1): ( \"+Plankalkuel.p1(1)[0].to_i.to_s+\", \"+Plankalkuel.p1(1)[1].to_i.to_s+\")\"\nputs \" inc(65535): ( \"+Plankalkuel.p1(65535)[0].to_i.to_s+\", \"+Plankalkuel.p1(65535)[1].to_i.to_s+\")\"" >> inc.rb
ruby inc.rb
ruby ../../pkc.rb -i maj.pk
echo "\n\nputs \"* Major function\"\nputs \" max(16, 18): \"+Plankalkuel.p2(16, 18).to_i.to_s\nputs \" max(18, 16): \"+Plankalkuel.p2(18, 16).to_i.to_s\nputs \" max(16, 16): \"+Plankalkuel.p2(16, 16).to_i.to_s" >> maj.rb
ruby maj.rb
ruby ../../pkc.rb -i sym.pk
echo "\n\nputs \"* Symmetry (for 16bit numbers)\"\nputs \" sym(0): \"+Plankalkuel.p3(0).to_i.to_s\nputs \" sym(8): \"+Plankalkuel.p3(8).to_i.to_s" >> sym.rb
ruby sym.rb

9 changes: 9 additions & 0 deletions examples_pk/presentation/inc.pk
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
P1 (V0[:16.0]) => (R0[:16.0], R1[:0])
1 => Z0[:0]
0 => R0[:16.0]
W1(16)[
!(V0[i:0] ~ Z0[:0]) => R0[i:0]
V0[i:0] & Z0[:0] => Z0[:0]
]
Z0[:0] => R1[:0]
END
4 changes: 4 additions & 0 deletions examples_pk/presentation/maj.pk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
P2 (V0[:16.0], V1[:16.0]) => R0[:16.0]
V0[:16.0] > V1[:16.0] -> (V0[:16.0] => R0[:16.0])
! V0[:16.0] > V1[:16.0] -> (V1[:16.0] => R0[:16.0])
END
13 changes: 13 additions & 0 deletions examples_pk/presentation/sym.pk
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
P3 (V0[:16.0]) => R0[:0]
0 => Z1[:4.0]
15 => Z2[:4.0]
1 => Z0[:0]
W[
Z1[:4.0] < Z2[:4.0] -> [
(V0[Z1[:4.0]:0] ~ V0[Z2[:4.0]:0]) & Z0[:0] => Z0[:0]
Z1[:4.0] + 1 => Z1[:4.0]
Z2[:4.0] - 1 => Z2[:4.0]
]
]
Z0[:0] => R0[:0]
END

0 comments on commit 868324b

Please sign in to comment.