setattr(self, fname, sig)
# create signals for all field forms
- self.form_names = forms = self.fields.instrs.keys()
+ forms = self.form_names
self.sigforms = {}
for form in forms:
fields = self.fields.instrs[form]
self.tree_analyse()
+ @property
+ def form_names(self):
+ return self.fields.instrs.keys()
+
def elaborate(self, platform):
m = PowerDecoder.elaborate(self, platform)
comb = m.d.comb
name_on_wiki = "fields.text"
self.fname = find_wiki_file(name_on_wiki)
+ @property
+ def form_names(self):
+ return self.instrs.keys()
+
def create_specs(self):
self.forms, self.instrs = self.decode_fields()
- self.form_names = forms = self.instrs.keys()
+ forms = self.form_names
#print ("specs", self.forms, forms)
for form in forms:
fields = self.instrs[form]
from soc.decoder.power_fields import DecodeFields, BitRange
from nmigen import Module, Elaboratable, Signal, Cat
from nmigen.cli import rtlil
+from copy import deepcopy
class SignalBitRange(BitRange):
BitRange.__init__(self)
self.signal = signal
+ def __deepcopy__(self, memo):
+ signal = deepcopy(self.signal, memo)
+ retval = SignalBitRange(signal=signal)
+ for k, v in self.items():
+ k = deepcopy(k, memo)
+ v = deepcopy(v, memo)
+ retval[k] = v
+ return retval
+
def _rev(self, k):
width = self.signal.width
return width-1-k
from pprint import pprint
from ply import lex, yacc
import astor
+from copy import deepcopy
from soc.decoder.power_decoder import create_pdecode
from soc.decoder.pseudo.lexer import IndentLexer
#from compiler import misc, syntax, pycodegen
+_CACHED_PARSERS = {}
+_CACHE_PARSERS = True
+
+
class GardenSnakeCompiler(object):
def __init__(self, debug=False, form=None, incl_carry=False):
- self.parser = GardenSnakeParser(debug=debug, form=form,
- incl_carry=incl_carry)
+ if _CACHE_PARSERS:
+ try:
+ parser = _CACHED_PARSERS[debug, form, incl_carry]
+ except KeyError:
+ parser = GardenSnakeParser(debug=debug, form=form,
+ incl_carry=incl_carry)
+ _CACHED_PARSERS[debug, form, incl_carry] = parser
+
+ self.parser = deepcopy(parser)
+ else:
+ self.parser = GardenSnakeParser(debug=debug, form=form,
+ incl_carry=incl_carry)
def compile(self, code, mode="exec", filename="<string>"):
tree = self.parser.parse(code)