hdl.rec: make Record inherit from UserValue.

Closes #354.
This commit is contained in:
anuejn 2020-04-16 18:46:55 +02:00 committed by GitHub
parent b4af217ed0
commit ff6c0327a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 32 additions and 24 deletions

View file

@ -374,9 +374,6 @@ class _ValueCompiler(ValueVisitor, _Compiler):
def on_ResetSignal(self, value):
raise NotImplementedError # :nocov:
def on_Record(self, value):
return self(Cat(value.fields.values()))
def on_AnyConst(self, value):
raise NotImplementedError # :nocov:

View file

@ -365,9 +365,6 @@ class _ValueCompiler(xfrm.ValueVisitor):
def on_Initial(self, value):
raise NotImplementedError # :nocov:
def on_Record(self, value):
return self(ast.Cat(value.fields.values()))
def on_Cat(self, value):
return "{{ {} }}".format(" ".join(reversed([self(o) for o in value.parts])))
@ -378,7 +375,11 @@ class _ValueCompiler(xfrm.ValueVisitor):
if value.start == 0 and value.stop == len(value.value):
return self(value.value)
sigspec = self._prepare_value_for_Slice(value.value)
if isinstance(value.value, ast.UserValue):
sigspec = self._prepare_value_for_Slice(value.value._lazy_lower())
else:
sigspec = self._prepare_value_for_Slice(value.value)
if value.start == value.stop:
return "{}"
elif value.start + 1 == value.stop:
@ -644,7 +645,7 @@ class _LHSValueCompiler(_ValueCompiler):
return wire_next or wire_curr
def _prepare_value_for_Slice(self, value):
assert isinstance(value, (ast.Signal, ast.Slice, ast.Cat, rec.Record))
assert isinstance(value, (ast.Signal, ast.Slice, ast.Cat))
return self(value)
def on_Part(self, value):