forked from M-Labs/artiq
1
0
Fork 0

devices/runtime: pretty-print

This commit is contained in:
Sebastien Bourdeauducq 2014-10-14 19:49:39 +08:00
parent 88ad4fbf23
commit cbf915c2cc
1 changed files with 7 additions and 1 deletions

View File

@ -5,6 +5,7 @@ from llvm import core as lc
from llvm import target as lt from llvm import target as lt
from artiq.py2llvm import base_types from artiq.py2llvm import base_types
from artiq.language import units
lt.initialize_all() lt.initialize_all()
@ -138,12 +139,17 @@ def _debug_dump_obj(obj):
class Environment(LinkInterface): class Environment(LinkInterface):
def __init__(self, ref_period): def __init__(self, ref_period):
self.cpu_type = "or1k"
self.ref_period = ref_period self.ref_period = ref_period
# allow 1ms for all initial DDS programming # allow 1ms for all initial DDS programming
self.initial_time = int(Fraction(1, 1000)/self.ref_period) self.initial_time = int(Fraction(1, 1000)/self.ref_period)
def emit_object(self): def emit_object(self):
tm = lt.TargetMachine.new(triple="or1k", cpu="generic") tm = lt.TargetMachine.new(triple=self.cpu_type, cpu="generic")
obj = tm.emit_object(self.llvm_module) obj = tm.emit_object(self.llvm_module)
_debug_dump_obj(obj) _debug_dump_obj(obj)
return obj return obj
def __repr__(self):
return "<Environment {} {}>".format(self.cpu_type,
str(units.Hz/self.ref_period))