parameters: (arch)
return_statement: return changed
docstring: For the purposes of constant generator detection every model needs to include
      a set of primtiive internal timing edges.
  
      If we find a combinational model definition which has no internal timing edges,
      we add timing edges between all input and output ports. This is a pessimistic,
      but safe assumption.
  
      Note that if we find any internal timing edges specified we assume the user has
      specified them correctly and do not make any changes to that model
docstring_summary: For the purposes of constant generator detection every model needs to include
      a set of primtiive internal timing edges.
docstring_tokens: For the purposes of constant generator detection every model needs to include a set of primtiive internal timing edges .
function: def add_missing_comb_model_internal_timing_edges(arch):
      """
      For the purposes of constant generator detection every model needs to include
      a set of primtiive internal timing edges.
  
      If we find a combinational model definition which has no internal timing edges,
      we add timing edges between all input and output ports. This is a pessimistic,
      but safe assumption.
  
      Note that if we find any internal timing edges specified we assume the user has
      specified them correctly and do not make any changes to that model
      """
      changed = False
  
      model_tags = arch.findall("./models/model")
  
      for model_tag in model_tags:
  
          input_clock_tags = model_tag.findall("./input_ports/port[@is_clock='1']")
          if len(input_clock_tags) > 0:
              continue  # Sequential primitive -- no change
  
          input_tags_with_timing_edges = model_tag.findall(
              "./input_ports/port[@combinational_sink_ports]"
          )
          if len(input_tags_with_timing_edges) > 0:
              continue  # Already has internal edges specified -- no change
  
          # Collect the model port definitions
          input_port_tags = model_tag.findall("./input_ports/port")
          output_port_tags = model_tag.findall("./output_ports/port")
  
          # Collect output port names
          output_port_names = []
          for output_port_tag in output_port_tags:
              output_port_names.append(output_port_tag.attrib["name"])
  
          for input_port_tag in input_port_tags:
  
              assert "combinational_sink_ports" not in input_port_tag
  
              input_port_tag.attrib["combinational_sink_ports"] = " ".join(output_port_names)
  
              print(
                  "Warning: Conservatively upgrading combinational sink dependencies for input port '{}' of model '{}' to '{}'. The user should manually check whether a reduced set of sink dependencies can be safely specified.".format(
                      input_port_tag.attrib["name"],
                      model_tag.attrib["name"],
                      input_port_tag.attrib["combinational_sink_ports"],
                  ),
                  file=sys.stderr,
              )
  
              changed = True
  
      return changed
function_tokens: def add_missing_comb_model_internal_timing_edges ( arch ) : changed = False model_tags = arch . findall ( "./models/model" ) for model_tag in model_tags : input_clock_tags = model_tag . findall ( "./input_ports/port[@is_clock='1']" ) if len ( input_clock_tags ) > 0 : continue # Sequential primitive -- no change input_tags_with_timing_edges = model_tag . findall ( "./input_ports/port[@combinational_sink_ports]" ) if len ( input_tags_with_timing_edges ) > 0 : continue # Already has internal edges specified -- no change # Collect the model port definitions input_port_tags = model_tag . findall ( "./input_ports/port" ) output_port_tags = model_tag . findall ( "./output_ports/port" ) # Collect output port names output_port_names = [ ] for output_port_tag in output_port_tags : output_port_names . append ( output_port_tag . attrib [ "name" ] ) for input_port_tag in input_port_tags : assert "combinational_sink_ports" not in input_port_tag input_port_tag . attrib [ "combinational_sink_ports" ] = " " . join ( output_port_names ) print ( "Warning: Conservatively upgrading combinational sink dependencies for input port '{}' of model '{}' to '{}'. The user should manually check whether a reduced set of sink dependencies can be safely specified." . format ( input_port_tag . attrib [ "name" ] , model_tag . attrib [ "name" ] , input_port_tag . attrib [ "combinational_sink_ports" ] , ) , file = sys . stderr , ) changed = True return changed