From 2aa63ba57d7d250eefb16f0b9850b7d42eb531f2 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sun, 6 Jul 2014 18:29:02 +0200 Subject: [PATCH] examples/coredev_test: print prime numbers --- examples/coredev_test.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/examples/coredev_test.py b/examples/coredev_test.py index f6ac50321..8985515f4 100644 --- a/examples/coredev_test.py +++ b/examples/coredev_test.py @@ -1,4 +1,4 @@ -from artiq.language.experiment import Experiment, kernel +from artiq.language.experiment import Experiment, kernel, syscall from artiq.devices import corecom_serial, runtime, core, gpio_core class CompilerTest(Experiment): @@ -7,6 +7,18 @@ class CompilerTest(Experiment): @kernel def run(self): self.led.set(1) + x = 1 + while x < 100: + d = 2 + prime = 1 + while d*d <= x: + if x % d == 0: + prime = 0 + d = d + 1 + if prime == 1: + syscall("print_int", x) + x = x + 1 + self.led.set(0) if __name__ == "__main__": with corecom_serial.CoreCom() as com: