mirror of https://github.com/m-labs/artiq.git
examples/coredev_test: print prime numbers
This commit is contained in:
parent
2f334589f0
commit
2aa63ba57d
|
@ -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
|
from artiq.devices import corecom_serial, runtime, core, gpio_core
|
||||||
|
|
||||||
class CompilerTest(Experiment):
|
class CompilerTest(Experiment):
|
||||||
|
@ -7,6 +7,18 @@ class CompilerTest(Experiment):
|
||||||
@kernel
|
@kernel
|
||||||
def run(self):
|
def run(self):
|
||||||
self.led.set(1)
|
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__":
|
if __name__ == "__main__":
|
||||||
with corecom_serial.CoreCom() as com:
|
with corecom_serial.CoreCom() as com:
|
||||||
|
|
Loading…
Reference in New Issue