connection checks (asserts)

This commit is contained in:
Vojta Mrazek 2023-03-28 11:16:55 +02:00
parent 44e0a920d1
commit a4741db191
2 changed files with 14 additions and 13 deletions

View File

@ -311,16 +311,19 @@ class TwoOneMultiplexer(ThreeInputOneBitCircuit):
if not self.use_verilog_instance:
return super().get_init_v_flat()
# TODO - replace by one verilog_instance_format!
neg_out_w_name = f"neg_{self.out.get_wire(0).name}"
return f" wire {neg_out_w_name};\n " + self.use_verilog_instance.format(
**{
"unit": self.prefix,
"wirea": f"1'b{self.a.value}" if self.a.is_const() else self.a.name,
"wireb": f"1'b{self.b.value}" if self.b.is_const() else self.b.name,
"wires": f"1'b{self.c.value}" if self.c.is_const() else self.c.name,
"wirey": neg_out_w_name,
}) + ";\n" + f" assign {self.out.get_wire(0).name} = ~{neg_out_w_name};\n"
if self.out[0].is_const():
return ""
else:
# TODO - replace by one verilog_instance_format!
neg_out_w_name = f"neg_{self.out.get_wire(0).name}"
return f" wire {neg_out_w_name};\n " + self.use_verilog_instance.format(
**{
"unit": self.prefix,
"wirea": self.a.get_wire_value_v_hier(), # former version: f"1'b{self.a.value}" if self.a.is_const() else self.a.name,
"wireb": self.b.get_wire_value_v_hier(), #f"1'b{self.b.value}" if self.b.is_const() else self.b.name,
"wires": self.c.get_wire_value_v_hier(), #f"1'b{self.c.value}" if self.c.is_const() else self.c.name,
"wirey": neg_out_w_name,
}) + ";\n" + f" assign {self.out.get_wire(0).name} = ~{neg_out_w_name};\n"
def get_self_init_v_hier(self):
""" support of custom PDK """

View File

@ -75,11 +75,9 @@ class Bus():
Returns:
Wire: Returning wire from the bus.
"""
assert wire_index < self.N, f"Wire index {wire_index} is out of bounds of the bus {self.prefix} with size {self.N}"
return self.bus[wire_index]
def __getitem__(self, i):
return self.bus[i]
def __getitem__(self, i):
return self.get_wire(i)