Simplify stickybit implementation for single-bit fields to not create redundant expression. #127
This commit is contained in:
@@ -46,15 +46,24 @@ class Stickybit(NextStateConditional):
|
||||
|
||||
def get_predicate(self, field: 'FieldNode') -> str:
|
||||
F = self.exp.hwif.get_input_identifier(field)
|
||||
return f"{F} != '0"
|
||||
if field.width == 1:
|
||||
return str(F)
|
||||
else:
|
||||
return f"{F} != '0"
|
||||
|
||||
def get_assignments(self, field: 'FieldNode') -> List[str]:
|
||||
I = self.exp.hwif.get_input_identifier(field)
|
||||
R = self.exp.field_logic.get_storage_identifier(field)
|
||||
return [
|
||||
f"next_c = {R} | {I};",
|
||||
"load_next_c = '1;",
|
||||
]
|
||||
if field.width == 1:
|
||||
return [
|
||||
"next_c = '1;",
|
||||
"load_next_c = '1;",
|
||||
]
|
||||
else:
|
||||
I = self.exp.hwif.get_input_identifier(field)
|
||||
R = self.exp.field_logic.get_storage_identifier(field)
|
||||
return [
|
||||
f"next_c = {R} | {I};",
|
||||
"load_next_c = '1;",
|
||||
]
|
||||
|
||||
class PosedgeStickybit(NextStateConditional):
|
||||
"""
|
||||
@@ -74,13 +83,19 @@ class PosedgeStickybit(NextStateConditional):
|
||||
return f"(~{Iq} & {I}) != '0"
|
||||
|
||||
def get_assignments(self, field: 'FieldNode') -> List[str]:
|
||||
I = self.exp.hwif.get_input_identifier(field)
|
||||
Iq = self.exp.field_logic.get_next_q_identifier(field)
|
||||
R = self.exp.field_logic.get_storage_identifier(field)
|
||||
return [
|
||||
f"next_c = {R} | (~{Iq} & {I});",
|
||||
"load_next_c = '1;",
|
||||
]
|
||||
if field.width == 1:
|
||||
return [
|
||||
"next_c = '1;",
|
||||
"load_next_c = '1;",
|
||||
]
|
||||
else:
|
||||
I = self.exp.hwif.get_input_identifier(field)
|
||||
Iq = self.exp.field_logic.get_next_q_identifier(field)
|
||||
R = self.exp.field_logic.get_storage_identifier(field)
|
||||
return [
|
||||
f"next_c = {R} | (~{Iq} & {I});",
|
||||
"load_next_c = '1;",
|
||||
]
|
||||
|
||||
class NegedgeStickybit(NextStateConditional):
|
||||
"""
|
||||
@@ -100,13 +115,19 @@ class NegedgeStickybit(NextStateConditional):
|
||||
return f"({Iq} & ~{I}) != '0"
|
||||
|
||||
def get_assignments(self, field: 'FieldNode') -> List[str]:
|
||||
I = self.exp.hwif.get_input_identifier(field)
|
||||
Iq = self.exp.field_logic.get_next_q_identifier(field)
|
||||
R = self.exp.field_logic.get_storage_identifier(field)
|
||||
return [
|
||||
f"next_c = {R} | ({Iq} & ~{I});",
|
||||
"load_next_c = '1;",
|
||||
]
|
||||
if field.width == 1:
|
||||
return [
|
||||
"next_c = '1;",
|
||||
"load_next_c = '1;",
|
||||
]
|
||||
else:
|
||||
I = self.exp.hwif.get_input_identifier(field)
|
||||
Iq = self.exp.field_logic.get_next_q_identifier(field)
|
||||
R = self.exp.field_logic.get_storage_identifier(field)
|
||||
return [
|
||||
f"next_c = {R} | ({Iq} & ~{I});",
|
||||
"load_next_c = '1;",
|
||||
]
|
||||
|
||||
class BothedgeStickybit(NextStateConditional):
|
||||
"""
|
||||
@@ -126,13 +147,19 @@ class BothedgeStickybit(NextStateConditional):
|
||||
return f"{Iq} != {I}"
|
||||
|
||||
def get_assignments(self, field: 'FieldNode') -> List[str]:
|
||||
I = self.exp.hwif.get_input_identifier(field)
|
||||
Iq = self.exp.field_logic.get_next_q_identifier(field)
|
||||
R = self.exp.field_logic.get_storage_identifier(field)
|
||||
return [
|
||||
f"next_c = {R} | ({Iq} ^ {I});",
|
||||
"load_next_c = '1;",
|
||||
]
|
||||
if field.width == 1:
|
||||
return [
|
||||
"next_c = '1;",
|
||||
"load_next_c = '1;",
|
||||
]
|
||||
else:
|
||||
I = self.exp.hwif.get_input_identifier(field)
|
||||
Iq = self.exp.field_logic.get_next_q_identifier(field)
|
||||
R = self.exp.field_logic.get_storage_identifier(field)
|
||||
return [
|
||||
f"next_c = {R} | ({Iq} ^ {I});",
|
||||
"load_next_c = '1;",
|
||||
]
|
||||
|
||||
class PosedgeNonsticky(NextStateUnconditional):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user