--- /dev/null
- [submodule "logic"]
- path = logic
- url = <address of this repo>
- branch = logic
+[submodule "logicui"]
+ path = logicui
+ url = <address of this repo>
+ branch = logicui
+[submodule "SampleERCP"]
+ path = SampleERCP
+ url = <address of this repo>
+ branch = SampleERCP
--- /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<classpath>\r
- <classpathentry kind="src" path="src" />\r
- <classpathentry kind="con"\r
- path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5" />\r
- <classpathentry kind="con"\r
- path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">\r
- <attributes>\r
- <attribute name="module" value="true" />\r
- </attributes>\r
- </classpathentry>\r
- <classpathentry kind="output" path="bin" />\r
-</classpath>\r
++<?xml version="1.0" encoding="UTF-8"?>
++<classpath>
++ <classpathentry kind="src" path="src" />
++ <classpathentry kind="con"
++ path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5" />
++ <classpathentry kind="con"
++ path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
++ <attributes>
++ <attribute name="module" value="true" />
++ </attributes>
++ </classpathentry>
++ <classpathentry kind="output" path="bin" />
++</classpath>
--- /dev/null
-eclipse.preferences.version=1\r
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=10\r
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve\r
-org.eclipse.jdt.core.compiler.compliance=10\r
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate\r
-org.eclipse.jdt.core.compiler.debug.localVariable=generate\r
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate\r
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
-org.eclipse.jdt.core.compiler.release=enabled\r
-org.eclipse.jdt.core.compiler.source=10\r
-org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false\r
-org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647\r
-org.eclipse.jdt.core.formatter.align_type_members_on_columns=false\r
-org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false\r
-org.eclipse.jdt.core.formatter.align_with_spaces=false\r
-org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16\r
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16\r
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0\r
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16\r
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16\r
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16\r
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16\r
-org.eclipse.jdt.core.formatter.alignment_for_assignment=0\r
-org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16\r
-org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16\r
-org.eclipse.jdt.core.formatter.alignment_for_compact_if=16\r
-org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16\r
-org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80\r
-org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0\r
-org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16\r
-org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16\r
-org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0\r
-org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16\r
-org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0\r
-org.eclipse.jdt.core.formatter.alignment_for_module_statements=16\r
-org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16\r
-org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16\r
-org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0\r
-org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16\r
-org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16\r
-org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0\r
-org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80\r
-org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16\r
-org.eclipse.jdt.core.formatter.alignment_for_shift_operator=0\r
-org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16\r
-org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16\r
-org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16\r
-org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16\r
-org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16\r
-org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16\r
-org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0\r
-org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0\r
-org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16\r
-org.eclipse.jdt.core.formatter.blank_lines_after_imports=1\r
-org.eclipse.jdt.core.formatter.blank_lines_after_package=1\r
-org.eclipse.jdt.core.formatter.blank_lines_before_field=0\r
-org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0\r
-org.eclipse.jdt.core.formatter.blank_lines_before_imports=1\r
-org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1\r
-org.eclipse.jdt.core.formatter.blank_lines_before_method=1\r
-org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1\r
-org.eclipse.jdt.core.formatter.blank_lines_before_package=0\r
-org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1\r
-org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1\r
-org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=next_line\r
-org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=next_line\r
-org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line\r
-org.eclipse.jdt.core.formatter.brace_position_for_block=next_line\r
-org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line\r
-org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line\r
-org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=next_line\r
-org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line\r
-org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=next_line\r
-org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line\r
-org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line\r
-org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line\r
-org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=true\r
-org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false\r
-org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false\r
-org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false\r
-org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true\r
-org.eclipse.jdt.core.formatter.comment.format_block_comments=true\r
-org.eclipse.jdt.core.formatter.comment.format_header=false\r
-org.eclipse.jdt.core.formatter.comment.format_html=true\r
-org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true\r
-org.eclipse.jdt.core.formatter.comment.format_line_comments=true\r
-org.eclipse.jdt.core.formatter.comment.format_source_code=true\r
-org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false\r
-org.eclipse.jdt.core.formatter.comment.indent_root_tags=false\r
-org.eclipse.jdt.core.formatter.comment.indent_tag_description=false\r
-org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert\r
-org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert\r
-org.eclipse.jdt.core.formatter.comment.line_length=140\r
-org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true\r
-org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true\r
-org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false\r
-org.eclipse.jdt.core.formatter.compact_else_if=true\r
-org.eclipse.jdt.core.formatter.continuation_indentation=2\r
-org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2\r
-org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off\r
-org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on\r
-org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false\r
-org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=false\r
-org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true\r
-org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true\r
-org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true\r
-org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true\r
-org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true\r
-org.eclipse.jdt.core.formatter.indent_empty_lines=false\r
-org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true\r
-org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true\r
-org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true\r
-org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false\r
-org.eclipse.jdt.core.formatter.indentation.size=4\r
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert\r
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert\r
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert\r
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert\r
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert\r
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert\r
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert\r
-org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert\r
-org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert\r
-org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert\r
-org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert\r
-org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert\r
-org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert\r
-org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert\r
-org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert\r
-org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert\r
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert\r
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert\r
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert\r
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert\r
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert\r
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert\r
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert\r
-org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert\r
-org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert\r
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert\r
-org.eclipse.jdt.core.formatter.join_lines_in_comments=true\r
-org.eclipse.jdt.core.formatter.join_wrapped_lines=true\r
-org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_never\r
-org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_never\r
-org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_never\r
-org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false\r
-org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false\r
-org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_never\r
-org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never\r
-org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_never\r
-org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false\r
-org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_never\r
-org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_never\r
-org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_never\r
-org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false\r
-org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false\r
-org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false\r
-org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false\r
-org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false\r
-org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never\r
-org.eclipse.jdt.core.formatter.lineSplit=140\r
-org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false\r
-org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false\r
-org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0\r
-org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1\r
-org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines\r
-org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines\r
-org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines\r
-org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines\r
-org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines\r
-org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines\r
-org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines\r
-org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines\r
-org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines\r
-org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines\r
-org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true\r
-org.eclipse.jdt.core.formatter.tabulation.char=tab\r
-org.eclipse.jdt.core.formatter.tabulation.size=4\r
-org.eclipse.jdt.core.formatter.use_on_off_tags=true\r
-org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false\r
-org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true\r
-org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false\r
-org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true\r
-org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true\r
-org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true\r
-org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true\r
-org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true\r
-org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true\r
-org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true\r
-org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true\r
-org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true\r
-org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true\r
-org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter\r
++eclipse.preferences.version=1
++org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
++org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
++org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
++org.eclipse.jdt.core.compiler.compliance=10
++org.eclipse.jdt.core.compiler.debug.lineNumber=generate
++org.eclipse.jdt.core.compiler.debug.localVariable=generate
++org.eclipse.jdt.core.compiler.debug.sourceFile=generate
++org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
++org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
++org.eclipse.jdt.core.compiler.release=enabled
++org.eclipse.jdt.core.compiler.source=10
++org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false
++org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
++org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
++org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false
++org.eclipse.jdt.core.formatter.align_with_spaces=false
++org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16
++org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
++org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
++org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
++org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
++org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
++org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
++org.eclipse.jdt.core.formatter.alignment_for_assignment=0
++org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
++org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16
++org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
++org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16
++org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
++org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0
++org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16
++org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
++org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0
++org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16
++org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
++org.eclipse.jdt.core.formatter.alignment_for_module_statements=16
++org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
++org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16
++org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0
++org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
++org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
++org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0
++org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
++org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
++org.eclipse.jdt.core.formatter.alignment_for_shift_operator=0
++org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16
++org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
++org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
++org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
++org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
++org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
++org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0
++org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0
++org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
++org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
++org.eclipse.jdt.core.formatter.blank_lines_after_package=1
++org.eclipse.jdt.core.formatter.blank_lines_before_field=0
++org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
++org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
++org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
++org.eclipse.jdt.core.formatter.blank_lines_before_method=1
++org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
++org.eclipse.jdt.core.formatter.blank_lines_before_package=0
++org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
++org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
++org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=next_line
++org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=next_line
++org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
++org.eclipse.jdt.core.formatter.brace_position_for_block=next_line
++org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line
++org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line
++org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=next_line
++org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line
++org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=next_line
++org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line
++org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line
++org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line
++org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=true
++org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false
++org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
++org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
++org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true
++org.eclipse.jdt.core.formatter.comment.format_block_comments=true
++org.eclipse.jdt.core.formatter.comment.format_header=false
++org.eclipse.jdt.core.formatter.comment.format_html=true
++org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
++org.eclipse.jdt.core.formatter.comment.format_line_comments=true
++org.eclipse.jdt.core.formatter.comment.format_source_code=true
++org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false
++org.eclipse.jdt.core.formatter.comment.indent_root_tags=false
++org.eclipse.jdt.core.formatter.comment.indent_tag_description=false
++org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
++org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert
++org.eclipse.jdt.core.formatter.comment.line_length=140
++org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
++org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
++org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
++org.eclipse.jdt.core.formatter.compact_else_if=true
++org.eclipse.jdt.core.formatter.continuation_indentation=2
++org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
++org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
++org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
++org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
++org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=false
++org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
++org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
++org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
++org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
++org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
++org.eclipse.jdt.core.formatter.indent_empty_lines=false
++org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
++org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
++org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
++org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
++org.eclipse.jdt.core.formatter.indentation.size=4
++org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert
++org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
++org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
++org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
++org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
++org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
++org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
++org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
++org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
++org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert
++org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
++org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert
++org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
++org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
++org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert
++org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
++org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
++org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
++org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
++org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
++org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
++org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
++org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
++org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert
++org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
++org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
++org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
++org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert
++org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
++org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
++org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
++org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
++org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
++org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
++org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
++org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
++org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
++org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
++org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
++org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
++org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
++org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
++org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
++org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
++org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
++org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
++org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
++org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
++org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
++org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
++org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
++org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
++org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
++org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
++org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
++org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
++org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
++org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert
++org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert
++org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
++org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
++org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
++org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert
++org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
++org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
++org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert
++org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert
++org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert
++org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
++org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
++org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
++org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
++org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert
++org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
++org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
++org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
++org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
++org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
++org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert
++org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
++org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
++org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
++org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
++org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
++org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert
++org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
++org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert
++org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert
++org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
++org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
++org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
++org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
++org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
++org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
++org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
++org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
++org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
++org.eclipse.jdt.core.formatter.join_lines_in_comments=true
++org.eclipse.jdt.core.formatter.join_wrapped_lines=true
++org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_never
++org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_never
++org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_never
++org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
++org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
++org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_never
++org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never
++org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_never
++org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
++org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_never
++org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_never
++org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_never
++org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false
++org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false
++org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false
++org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false
++org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
++org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never
++org.eclipse.jdt.core.formatter.lineSplit=140
++org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
++org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
++org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
++org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
++org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines
++org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines
++org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines
++org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines
++org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines
++org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines
++org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines
++org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines
++org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines
++org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines
++org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
++org.eclipse.jdt.core.formatter.tabulation.char=tab
++org.eclipse.jdt.core.formatter.tabulation.size=4
++org.eclipse.jdt.core.formatter.use_on_off_tags=true
++org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
++org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true
++org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false
++org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
++org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true
++org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true
++org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true
++org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true
++org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
++org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true
++org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true
++org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true
++org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
++org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter
--- /dev/null
-package era.mi.logic;\r
-\r
-import era.mi.logic.timeline.Timeline;\r
-\r
-public class Simulation\r
-{\r
- public final static Timeline TIMELINE = new Timeline(11);\r
-\r
++package era.mi.logic;
++
++import era.mi.logic.timeline.Timeline;
++
++public class Simulation
++{
++ public final static Timeline TIMELINE = new Timeline(11);
++
+ }
--- /dev/null
-package era.mi.logic;\r
-\r
-import java.util.Arrays;\r
-\r
-import era.mi.logic.types.Bit;\r
-\r
-public final class Util\r
-{\r
-\r
- @SuppressWarnings("unchecked")\r
- public static <T> T[] concat(T[]... arrays)\r
- {\r
- if (arrays.length == 0)\r
- throw new IllegalArgumentException("Cannot concatenate 0 arrays.");\r
-\r
- int length = 0;\r
- for (T[] array : arrays)\r
- length += array.length;\r
-\r
- T[] newArray = Arrays.copyOf(arrays[0], length);\r
- int appendIndex = arrays[0].length;\r
- for (int i = 1; i < arrays.length; i++)\r
- {\r
- System.arraycopy(arrays[i], 0, newArray, appendIndex, arrays[i].length);\r
- appendIndex += arrays[i].length;\r
- }\r
-\r
- return newArray;\r
- }\r
-\r
-// @SuppressWarnings("unchecked")\r
-// public static <T> T[][] split(T[] array, int... lengths)\r
-// {\r
-// //TODO: implement array split again; This version contains an illegal cast\r
-// int totalLength = 0;\r
-// for(int length : lengths)\r
-// totalLength += length;\r
-// \r
-// if(totalLength != array.length)\r
-// throw new IllegalArgumentException(); //TODO: add proper error message\r
-// \r
-// Object[][] newArray = new Object[lengths.length][];\r
-// int splitIndex = 0;\r
-// for(int i = 0; i < lengths.length; i++)\r
-// {\r
-// System.arraycopy(array, splitIndex, newArray, 0, lengths[i]);\r
-// splitIndex += lengths[i];\r
-// }\r
-// \r
-// return (T[][]) newArray;\r
-// }\r
-\r
- public static Bit[] and(Bit[] a, Bit[] b)\r
- {\r
- return binBitOp(a, b, Bit::and);\r
- }\r
-\r
- public static Bit[] or(Bit[] a, Bit[] b)\r
- {\r
- return binBitOp(a, b, Bit::or);\r
- }\r
-\r
- public static Bit[] xor(Bit[] a, Bit[] b)\r
- {\r
- return binBitOp(a, b, Bit::xor);\r
- }\r
-\r
- private static Bit[] binBitOp(Bit[] a, Bit[] b, BitOp op)\r
- {\r
- if (a.length != b.length)\r
- throw new IllegalArgumentException("Bit Arrays were not of equal length.");\r
- Bit[] out = new Bit[a.length];\r
- for (int i = 0; i < a.length; i++)\r
- {\r
- out[i] = op.execute(a[i], b[i]);\r
- }\r
- return out;\r
- }\r
-\r
- public static Bit[] not(Bit[] a)\r
- {\r
- Bit[] out = new Bit[a.length];\r
- for (int i = 0; i < a.length; i++)\r
- {\r
- out[i] = a[i].not();\r
- }\r
- return out;\r
- }\r
-\r
- /**\r
- * uses the {@link Bit#combineWith(Bit)} method, does not create a new array, the result is stored in the first array.\r
- * \r
- * @author Christian Femers\r
- */\r
- public static Bit[] combineInto(Bit[] dest, Bit[] addition)\r
- {\r
- if (dest.length != addition.length)\r
- throw new IllegalArgumentException("Bit Arrays were not of equal length.");\r
- for (int i = 0; i < addition.length; i++)\r
- {\r
- dest[i] = dest[i].join(addition[i]);\r
- }\r
- return dest;\r
- }\r
-\r
- interface BitOp\r
- {\r
- Bit execute(Bit a, Bit b);\r
- }\r
-}\r
++package era.mi.logic;
++
++import java.util.Arrays;
++
++import era.mi.logic.types.Bit;
++
++public final class Util
++{
++
++ @SuppressWarnings("unchecked")
++ public static <T> T[] concat(T[]... arrays)
++ {
++ if (arrays.length == 0)
++ throw new IllegalArgumentException("Cannot concatenate 0 arrays.");
++
++ int length = 0;
++ for (T[] array : arrays)
++ length += array.length;
++
++ T[] newArray = Arrays.copyOf(arrays[0], length);
++ int appendIndex = arrays[0].length;
++ for (int i = 1; i < arrays.length; i++)
++ {
++ System.arraycopy(arrays[i], 0, newArray, appendIndex, arrays[i].length);
++ appendIndex += arrays[i].length;
++ }
++
++ return newArray;
++ }
++
++// @SuppressWarnings("unchecked")
++// public static <T> T[][] split(T[] array, int... lengths)
++// {
++// //TODO: implement array split again; This version contains an illegal cast
++// int totalLength = 0;
++// for(int length : lengths)
++// totalLength += length;
++//
++// if(totalLength != array.length)
++// throw new IllegalArgumentException(); //TODO: add proper error message
++//
++// Object[][] newArray = new Object[lengths.length][];
++// int splitIndex = 0;
++// for(int i = 0; i < lengths.length; i++)
++// {
++// System.arraycopy(array, splitIndex, newArray, 0, lengths[i]);
++// splitIndex += lengths[i];
++// }
++//
++// return (T[][]) newArray;
++// }
++
++ public static Bit[] and(Bit[] a, Bit[] b)
++ {
++ return binBitOp(a, b, Bit::and);
++ }
++
++ public static Bit[] or(Bit[] a, Bit[] b)
++ {
++ return binBitOp(a, b, Bit::or);
++ }
++
++ public static Bit[] xor(Bit[] a, Bit[] b)
++ {
++ return binBitOp(a, b, Bit::xor);
++ }
++
++ private static Bit[] binBitOp(Bit[] a, Bit[] b, BitOp op)
++ {
++ if (a.length != b.length)
++ throw new IllegalArgumentException("Bit Arrays were not of equal length.");
++ Bit[] out = new Bit[a.length];
++ for (int i = 0; i < a.length; i++)
++ {
++ out[i] = op.execute(a[i], b[i]);
++ }
++ return out;
++ }
++
++ public static Bit[] not(Bit[] a)
++ {
++ Bit[] out = new Bit[a.length];
++ for (int i = 0; i < a.length; i++)
++ {
++ out[i] = a[i].not();
++ }
++ return out;
++ }
++
++ /**
++ * uses the {@link Bit#combineWith(Bit)} method, does not create a new array, the result is stored in the first array.
++ *
++ * @author Christian Femers
++ */
++ public static Bit[] combineInto(Bit[] dest, Bit[] addition)
++ {
++ if (dest.length != addition.length)
++ throw new IllegalArgumentException("Bit Arrays were not of equal length.");
++ for (int i = 0; i < addition.length; i++)
++ {
++ dest[i] = dest[i].join(addition[i]);
++ }
++ return dest;
++ }
++
++ interface BitOp
++ {
++ Bit execute(Bit a, Bit b);
++ }
++}
--- /dev/null
-package era.mi.logic.components;\r
-\r
-import era.mi.logic.Simulation;\r
-import era.mi.logic.types.BitVector;\r
-import era.mi.logic.wires.Wire;\r
-import era.mi.logic.wires.WireObserver;\r
-\r
-/**\r
- * A basic component that recomputes all outputs (with a delay), when it is updated.\r
- * \r
- * @author Fabian Stemmler\r
- */\r
-public abstract class BasicComponent implements WireObserver, Component\r
-{\r
- private int processTime;\r
-\r
- /**\r
- * \r
- * @param processTime Amount of time this component takes to update its outputs. Must be more than 0, otherwise 1 is assumed.\r
- * \r
- * @author Fabian Stemmler\r
- */\r
- public BasicComponent(int processTime)\r
- {\r
- this.processTime = processTime > 0 ? processTime : 1;\r
- }\r
-\r
- @Override\r
- public void update(Wire initiator, BitVector oldValues)\r
- {\r
- Simulation.TIMELINE.addEvent(e -> compute(), processTime);\r
- }\r
-\r
- protected abstract void compute();\r
-}\r
++package era.mi.logic.components;
++
++import era.mi.logic.Simulation;
++import era.mi.logic.types.BitVector;
++import era.mi.logic.wires.Wire;
++import era.mi.logic.wires.WireObserver;
++
++/**
++ * A basic component that recomputes all outputs (with a delay), when it is updated.
++ *
++ * @author Fabian Stemmler
++ */
++public abstract class BasicComponent implements WireObserver, Component
++{
++ private int processTime;
++
++ /**
++ *
++ * @param processTime Amount of time this component takes to update its outputs. Must be more than 0, otherwise 1 is assumed.
++ *
++ * @author Fabian Stemmler
++ */
++ public BasicComponent(int processTime)
++ {
++ this.processTime = processTime > 0 ? processTime : 1;
++ }
++
++ @Override
++ public void update(Wire initiator, BitVector oldValues)
++ {
++ Simulation.TIMELINE.addEvent(e -> compute(), processTime);
++ }
++
++ protected abstract void compute();
++}
--- /dev/null
-package era.mi.logic.components;\r
-\r
-import java.util.List;\r
-\r
-import era.mi.logic.types.Bit;\r
-import era.mi.logic.types.BitVector;\r
-import era.mi.logic.wires.Wire.WireEnd;\r
-\r
-public class BitDisplay extends BasicComponent\r
-{\r
- private final WireEnd in;\r
- private BitVector displayedValue;\r
-\r
- public BitDisplay(WireEnd in)\r
- {\r
- super(1);\r
- this.in = in;\r
- in.addObserver(this);\r
- compute();\r
- }\r
-\r
- @Override\r
- protected void compute()\r
- {\r
- displayedValue = in.getValues();\r
- }\r
-\r
- public BitVector getDisplayedValue()\r
- {\r
- return displayedValue;\r
- }\r
-\r
- public boolean isDisplaying(Bit... values)\r
- {\r
- return displayedValue.equals(BitVector.of(values));\r
- }\r
-\r
- @Override\r
- public List<WireEnd> getAllInputs()\r
- {\r
- return List.of(in);\r
- }\r
-\r
- @Override\r
- public List<WireEnd> getAllOutputs()\r
- {\r
- return List.of();\r
- }\r
-}\r
++package era.mi.logic.components;
++
++import java.util.List;
++
++import era.mi.logic.types.Bit;
++import era.mi.logic.types.BitVector;
++import era.mi.logic.wires.Wire.WireEnd;
++
++public class BitDisplay extends BasicComponent
++{
++ private final WireEnd in;
++ private BitVector displayedValue;
++
++ public BitDisplay(WireEnd in)
++ {
++ super(1);
++ this.in = in;
++ in.addObserver(this);
++ compute();
++ }
++
++ @Override
++ protected void compute()
++ {
++ displayedValue = in.getValues();
++ }
++
++ public BitVector getDisplayedValue()
++ {
++ return displayedValue;
++ }
++
++ public boolean isDisplaying(Bit... values)
++ {
++ return displayedValue.equals(BitVector.of(values));
++ }
++
++ @Override
++ public List<WireEnd> getAllInputs()
++ {
++ return List.of(in);
++ }
++
++ @Override
++ public List<WireEnd> getAllOutputs()
++ {
++ return List.of();
++ }
++}
--- /dev/null
-package era.mi.logic.components;\r
-\r
-import java.util.List;\r
-\r
-import era.mi.logic.Simulation;\r
-import era.mi.logic.timeline.TimelineEvent;\r
-import era.mi.logic.timeline.TimelineEventHandler;\r
-import era.mi.logic.types.Bit;\r
-import era.mi.logic.wires.Wire;\r
-import era.mi.logic.wires.Wire.WireEnd;\r
-\r
-public class Clock implements TimelineEventHandler, Component\r
-{\r
- private boolean toggle = false;\r
- private WireEnd out;\r
- private int delta;\r
-\r
- /**\r
- * \r
- * @param out {@link Wire} the clock's impulses are fed into\r
- * @param delta ticks between rising and falling edge\r
- */\r
- public Clock(WireEnd out, int delta)\r
- {\r
- this.delta = delta;\r
- this.out = out;\r
- addToTimeline();\r
- }\r
-\r
- @Override\r
- public void handle(TimelineEvent e)\r
- {\r
- addToTimeline();\r
- out.feedSignals(toggle ? Bit.ONE : Bit.ZERO);\r
- toggle = !toggle;\r
- }\r
-\r
- public WireEnd getOut()\r
- {\r
- return out;\r
- }\r
-\r
- private void addToTimeline()\r
- {\r
- Simulation.TIMELINE.addEvent(this, delta);\r
- }\r
-\r
- @Override\r
- public List<WireEnd> getAllInputs()\r
- {\r
- return List.of();\r
- }\r
-\r
- @Override\r
- public List<WireEnd> getAllOutputs()\r
- {\r
- return List.of(out);\r
- }\r
-}\r
++package era.mi.logic.components;
++
++import java.util.List;
++
++import era.mi.logic.Simulation;
++import era.mi.logic.timeline.TimelineEvent;
++import era.mi.logic.timeline.TimelineEventHandler;
++import era.mi.logic.types.Bit;
++import era.mi.logic.wires.Wire;
++import era.mi.logic.wires.Wire.WireEnd;
++
++public class Clock implements TimelineEventHandler, Component
++{
++ private boolean toggle = false;
++ private WireEnd out;
++ private int delta;
++
++ /**
++ *
++ * @param out {@link Wire} the clock's impulses are fed into
++ * @param delta ticks between rising and falling edge
++ */
++ public Clock(WireEnd out, int delta)
++ {
++ this.delta = delta;
++ this.out = out;
++ addToTimeline();
++ }
++
++ @Override
++ public void handle(TimelineEvent e)
++ {
++ addToTimeline();
++ out.feedSignals(toggle ? Bit.ONE : Bit.ZERO);
++ toggle = !toggle;
++ }
++
++ public WireEnd getOut()
++ {
++ return out;
++ }
++
++ private void addToTimeline()
++ {
++ Simulation.TIMELINE.addEvent(this, delta);
++ }
++
++ @Override
++ public List<WireEnd> getAllInputs()
++ {
++ return List.of();
++ }
++
++ @Override
++ public List<WireEnd> getAllOutputs()
++ {
++ return List.of(out);
++ }
++}
--- /dev/null
-package era.mi.logic.components;\r
-\r
-import java.util.List;\r
-\r
-import era.mi.logic.types.BitVector;\r
-import era.mi.logic.wires.Wire;\r
-import era.mi.logic.wires.Wire.WireEnd;\r
-import era.mi.logic.wires.WireObserver;\r
-\r
-public class Merger implements WireObserver, Component\r
-{\r
- private WireEnd out;\r
- private WireEnd[] inputs;\r
- private int[] beginningIndex;\r
-\r
- /**\r
- * \r
- * @param union The output of merging n {@link Wire}s into one. Must have length = a1.length() + a2.length() + ... + an.length().\r
- * @param inputs The inputs to be merged into the union\r
- */\r
- public Merger(WireEnd union, WireEnd... inputs)\r
- {\r
- this.inputs = inputs;\r
- this.out = union;\r
- this.beginningIndex = new int[inputs.length];\r
-\r
- int length = 0;\r
- for (int i = 0; i < inputs.length; i++)\r
- {\r
- beginningIndex[i] = length;\r
- length += inputs[i].length();\r
- inputs[i].addObserver(this);\r
- }\r
-\r
- if (length != union.length())\r
- throw new IllegalArgumentException(\r
- "The output of merging n WireArrays into one must have length = a1.length() + a2.length() + ... + an.length().");\r
- }\r
-\r
- public WireEnd getInput(int index)\r
- {\r
- return inputs[index];\r
- }\r
-\r
- public WireEnd getUnion()\r
- {\r
- return out;\r
- }\r
-\r
- @Override\r
- public void update(Wire initiator, BitVector oldValues)\r
- {\r
- int index = find(initiator);\r
- int beginning = beginningIndex[index];\r
- out.feedSignals(beginning, inputs[index].getValues());\r
- }\r
-\r
- private int find(Wire w)\r
- {\r
- for (int i = 0; i < inputs.length; i++)\r
- if (inputs[i].getWire() == w)\r
- return i;\r
- return -1;\r
- }\r
-\r
- public WireEnd[] getInputs()\r
- {\r
- return inputs.clone();\r
- }\r
-\r
- @Override\r
- public List<WireEnd> getAllInputs()\r
- {\r
- return List.of(inputs);\r
- }\r
-\r
- @Override\r
- public List<WireEnd> getAllOutputs()\r
- {\r
- return List.of(out);\r
- }\r
-}\r
++package era.mi.logic.components;
++
++import java.util.List;
++
++import era.mi.logic.types.BitVector;
++import era.mi.logic.wires.Wire;
++import era.mi.logic.wires.Wire.WireEnd;
++import era.mi.logic.wires.WireObserver;
++
++public class Merger implements WireObserver, Component
++{
++ private WireEnd out;
++ private WireEnd[] inputs;
++ private int[] beginningIndex;
++
++ /**
++ *
++ * @param union The output of merging n {@link Wire}s into one. Must have length = a1.length() + a2.length() + ... + an.length().
++ * @param inputs The inputs to be merged into the union
++ */
++ public Merger(WireEnd union, WireEnd... inputs)
++ {
++ this.inputs = inputs;
++ this.out = union;
++ this.beginningIndex = new int[inputs.length];
++
++ int length = 0;
++ for (int i = 0; i < inputs.length; i++)
++ {
++ beginningIndex[i] = length;
++ length += inputs[i].length();
++ inputs[i].addObserver(this);
++ }
++
++ if (length != union.length())
++ throw new IllegalArgumentException(
++ "The output of merging n WireArrays into one must have length = a1.length() + a2.length() + ... + an.length().");
++ }
++
++ public WireEnd getInput(int index)
++ {
++ return inputs[index];
++ }
++
++ public WireEnd getUnion()
++ {
++ return out;
++ }
++
++ @Override
++ public void update(Wire initiator, BitVector oldValues)
++ {
++ int index = find(initiator);
++ int beginning = beginningIndex[index];
++ out.feedSignals(beginning, inputs[index].getValues());
++ }
++
++ private int find(Wire w)
++ {
++ for (int i = 0; i < inputs.length; i++)
++ if (inputs[i].getWire() == w)
++ return i;
++ return -1;
++ }
++
++ public WireEnd[] getInputs()
++ {
++ return inputs.clone();
++ }
++
++ @Override
++ public List<WireEnd> getAllInputs()
++ {
++ return List.of(inputs);
++ }
++
++ @Override
++ public List<WireEnd> getAllOutputs()
++ {
++ return List.of(out);
++ }
++}
--- /dev/null
-package era.mi.logic.components;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Arrays;\r
-import java.util.Collections;\r
-import java.util.List;\r
-\r
-import era.mi.logic.wires.Wire;\r
-import era.mi.logic.wires.Wire.WireEnd;\r
-\r
-/**\r
- * Models a multiplexer. Takes an arbitrary amount of input {@link Wire}s, one of which, as determined by select, is put through to the\r
- * output.\r
- * \r
- * @author Fabian Stemmler\r
- *\r
- */\r
-public class Mux extends BasicComponent\r
-{\r
- private WireEnd select;\r
- private WireEnd out;\r
- private WireEnd[] inputs;\r
- private final int outputSize;\r
-\r
- /**\r
- * Input {@link Wire}s and out must be of uniform length\r
- * \r
- * @param out Must be of uniform length with all inputs.\r
- * @param select Indexes the input array which is to be mapped to the output. Must have enough bits to index all inputs.\r
- * @param inputs One of these inputs is mapped to the output, depending on the select bits\r
- */\r
- public Mux(int processTime, WireEnd out, WireEnd select, WireEnd... inputs)\r
- {\r
- super(processTime);\r
- outputSize = out.length();\r
-\r
- this.inputs = inputs.clone();\r
- for (int i = 0; i < this.inputs.length; i++)\r
- {\r
- if (inputs[i].length() != outputSize)\r
- throw new IllegalArgumentException("All MUX wire arrays must be of uniform length!");\r
- inputs[i].addObserver(this);\r
- }\r
-\r
- this.select = select;\r
- select.addObserver(this);\r
-\r
- int maxInputs = 1 << select.length();\r
- if (this.inputs.length > maxInputs)\r
- throw new IllegalArgumentException("There are more inputs (" + this.inputs.length + ") to the MUX than supported by "\r
- + select.length() + " select bits (" + maxInputs + ").");\r
-\r
- this.out = out;\r
- }\r
-\r
- public WireEnd getOut()\r
- {\r
- return out;\r
- }\r
-\r
- public WireEnd getSelect()\r
- {\r
- return select;\r
- }\r
-\r
- @Override\r
- public void compute()\r
- {\r
- int selectValue;\r
- if (!select.hasNumericValue() || (selectValue = (int) select.getUnsignedValue()) >= inputs.length)\r
- {\r
- out.clearSignals();\r
- return;\r
- }\r
-\r
- WireEnd active = inputs[selectValue];\r
- out.feedSignals(active.getValues());\r
- }\r
-\r
- @Override\r
- public List<WireEnd> getAllInputs()\r
- {\r
- ArrayList<WireEnd> wires = new ArrayList<WireEnd>(Arrays.asList(inputs));\r
- wires.add(select);\r
- return Collections.unmodifiableList(wires);\r
- }\r
-\r
- @Override\r
- public List<WireEnd> getAllOutputs()\r
- {\r
- return List.of(out);\r
- }\r
-}\r
++package era.mi.logic.components;
++
++import java.util.ArrayList;
++import java.util.Arrays;
++import java.util.Collections;
++import java.util.List;
++
++import era.mi.logic.wires.Wire;
++import era.mi.logic.wires.Wire.WireEnd;
++
++/**
++ * Models a multiplexer. Takes an arbitrary amount of input {@link Wire}s, one of which, as determined by select, is put through to the
++ * output.
++ *
++ * @author Fabian Stemmler
++ *
++ */
++public class Mux extends BasicComponent
++{
++ private WireEnd select;
++ private WireEnd out;
++ private WireEnd[] inputs;
++ private final int outputSize;
++
++ /**
++ * Input {@link Wire}s and out must be of uniform length
++ *
++ * @param out Must be of uniform length with all inputs.
++ * @param select Indexes the input array which is to be mapped to the output. Must have enough bits to index all inputs.
++ * @param inputs One of these inputs is mapped to the output, depending on the select bits
++ */
++ public Mux(int processTime, WireEnd out, WireEnd select, WireEnd... inputs)
++ {
++ super(processTime);
++ outputSize = out.length();
++
++ this.inputs = inputs.clone();
++ for (int i = 0; i < this.inputs.length; i++)
++ {
++ if (inputs[i].length() != outputSize)
++ throw new IllegalArgumentException("All MUX wire arrays must be of uniform length!");
++ inputs[i].addObserver(this);
++ }
++
++ this.select = select;
++ select.addObserver(this);
++
++ int maxInputs = 1 << select.length();
++ if (this.inputs.length > maxInputs)
++ throw new IllegalArgumentException("There are more inputs (" + this.inputs.length + ") to the MUX than supported by "
++ + select.length() + " select bits (" + maxInputs + ").");
++
++ this.out = out;
++ }
++
++ public WireEnd getOut()
++ {
++ return out;
++ }
++
++ public WireEnd getSelect()
++ {
++ return select;
++ }
++
++ @Override
++ public void compute()
++ {
++ int selectValue;
++ if (!select.hasNumericValue() || (selectValue = (int) select.getUnsignedValue()) >= inputs.length)
++ {
++ out.clearSignals();
++ return;
++ }
++
++ WireEnd active = inputs[selectValue];
++ out.feedSignals(active.getValues());
++ }
++
++ @Override
++ public List<WireEnd> getAllInputs()
++ {
++ ArrayList<WireEnd> wires = new ArrayList<WireEnd>(Arrays.asList(inputs));
++ wires.add(select);
++ return Collections.unmodifiableList(wires);
++ }
++
++ @Override
++ public List<WireEnd> getAllOutputs()
++ {
++ return List.of(out);
++ }
++}
--- /dev/null
-package era.mi.logic.components;\r
-\r
-import era.mi.logic.types.BitVector;\r
-import era.mi.logic.wires.Wire;\r
-import era.mi.logic.wires.Wire.WireEnd;\r
-import era.mi.logic.wires.WireObserver;\r
-\r
-public class Splitter implements WireObserver\r
-{\r
- private WireEnd input;\r
- private WireEnd[] outputs;\r
-\r
- public Splitter(WireEnd input, WireEnd... outputs)\r
- {\r
- this.input = input;\r
- this.outputs = outputs;\r
- input.addObserver(this);\r
- int length = 0;\r
- for (WireEnd out : outputs)\r
- length += out.length();\r
-\r
- if (input.length() != length)\r
- throw new IllegalArgumentException(\r
- "The input of splitting one into n WireArrays must have length = a1.length() + a2.length() + ... + an.length().");\r
- }\r
-\r
- protected void compute()\r
- {\r
- BitVector inputBits = input.getValues();\r
- int startIndex = 0;\r
- for (int i = 0; i < outputs.length; i++)\r
- {\r
- outputs[i].feedSignals(inputBits.subVector(startIndex, startIndex + outputs[i].length()));\r
- startIndex += outputs[i].length();\r
- }\r
- }\r
-\r
- @Override\r
- public void update(Wire initiator, BitVector oldValues)\r
- {\r
- compute();\r
- }\r
-}\r
++package era.mi.logic.components;
++
++import era.mi.logic.types.BitVector;
++import era.mi.logic.wires.Wire;
++import era.mi.logic.wires.Wire.WireEnd;
++import era.mi.logic.wires.WireObserver;
++
++public class Splitter implements WireObserver
++{
++ private WireEnd input;
++ private WireEnd[] outputs;
++
++ public Splitter(WireEnd input, WireEnd... outputs)
++ {
++ this.input = input;
++ this.outputs = outputs;
++ input.addObserver(this);
++ int length = 0;
++ for (WireEnd out : outputs)
++ length += out.length();
++
++ if (input.length() != length)
++ throw new IllegalArgumentException(
++ "The input of splitting one into n WireArrays must have length = a1.length() + a2.length() + ... + an.length().");
++ }
++
++ protected void compute()
++ {
++ BitVector inputBits = input.getValues();
++ int startIndex = 0;
++ for (int i = 0; i < outputs.length; i++)
++ {
++ outputs[i].feedSignals(inputBits.subVector(startIndex, startIndex + outputs[i].length()));
++ startIndex += outputs[i].length();
++ }
++ }
++
++ @Override
++ public void update(Wire initiator, BitVector oldValues)
++ {
++ compute();
++ }
++}
--- /dev/null
-package era.mi.logic.components.gates;\r
-\r
-import era.mi.logic.types.BitVector.BitVectorMutator;\r
-import era.mi.logic.wires.Wire.WireEnd;\r
-\r
-public class AndGate extends MultiInputGate\r
-{\r
- public AndGate(int processTime, WireEnd out, WireEnd... in)\r
- {\r
- super(processTime, BitVectorMutator::and, out, in);\r
- }\r
-}\r
++package era.mi.logic.components.gates;
++
++import era.mi.logic.types.BitVector.BitVectorMutator;
++import era.mi.logic.wires.Wire.WireEnd;
++
++public class AndGate extends MultiInputGate
++{
++ public AndGate(int processTime, WireEnd out, WireEnd... in)
++ {
++ super(processTime, BitVectorMutator::and, out, in);
++ }
++}
--- /dev/null
-package era.mi.logic.components.gates;\r
-\r
-import java.util.List;\r
-\r
-import era.mi.logic.components.BasicComponent;\r
-import era.mi.logic.wires.Wire.WireEnd;\r
-\r
-public class NotGate extends BasicComponent\r
-{\r
- private WireEnd in;\r
- private WireEnd out;\r
-\r
- public NotGate(int processTime, WireEnd in, WireEnd out)\r
- {\r
- super(processTime);\r
- this.in = in;\r
- in.addObserver(this);\r
- this.out = out;\r
- }\r
-\r
- @Override\r
- protected void compute()\r
- {\r
- out.feedSignals(in.getValues().not());\r
- }\r
-\r
- public WireEnd getIn()\r
- {\r
- return in;\r
- }\r
-\r
- public WireEnd getOut()\r
- {\r
- return out;\r
- }\r
-\r
- @Override\r
- public List<WireEnd> getAllInputs()\r
- {\r
- return List.of(in);\r
- }\r
-\r
- @Override\r
- public List<WireEnd> getAllOutputs()\r
- {\r
- return List.of(out);\r
- }\r
-}\r
++package era.mi.logic.components.gates;
++
++import java.util.List;
++
++import era.mi.logic.components.BasicComponent;
++import era.mi.logic.wires.Wire.WireEnd;
++
++public class NotGate extends BasicComponent
++{
++ private WireEnd in;
++ private WireEnd out;
++
++ public NotGate(int processTime, WireEnd in, WireEnd out)
++ {
++ super(processTime);
++ this.in = in;
++ in.addObserver(this);
++ this.out = out;
++ }
++
++ @Override
++ protected void compute()
++ {
++ out.feedSignals(in.getValues().not());
++ }
++
++ public WireEnd getIn()
++ {
++ return in;
++ }
++
++ public WireEnd getOut()
++ {
++ return out;
++ }
++
++ @Override
++ public List<WireEnd> getAllInputs()
++ {
++ return List.of(in);
++ }
++
++ @Override
++ public List<WireEnd> getAllOutputs()
++ {
++ return List.of(out);
++ }
++}
--- /dev/null
-package era.mi.logic.components.gates;\r
-\r
-import era.mi.logic.types.BitVector.BitVectorMutator;\r
-import era.mi.logic.wires.Wire.WireEnd;\r
-\r
-public class OrGate extends MultiInputGate\r
-{\r
- public OrGate(int processTime, WireEnd out, WireEnd... in)\r
- {\r
- super(processTime, BitVectorMutator::or, out, in);\r
- }\r
-}\r
++package era.mi.logic.components.gates;
++
++import era.mi.logic.types.BitVector.BitVectorMutator;
++import era.mi.logic.wires.Wire.WireEnd;
++
++public class OrGate extends MultiInputGate
++{
++ public OrGate(int processTime, WireEnd out, WireEnd... in)
++ {
++ super(processTime, BitVectorMutator::or, out, in);
++ }
++}
--- /dev/null
-package era.mi.logic.components.gates;\r
-\r
-import era.mi.logic.types.BitVector.BitVectorMutator;\r
-import era.mi.logic.wires.Wire.WireEnd;\r
-\r
-/**\r
- * Outputs 1 when the number of 1 inputs is odd.\r
- * \r
- * @author Fabian Stemmler\r
- */\r
-public class XorGate extends MultiInputGate\r
-{\r
- public XorGate(int processTime, WireEnd out, WireEnd... in)\r
- {\r
- super(processTime, BitVectorMutator::xor, out, in);\r
- }\r
-\r
-}\r
++package era.mi.logic.components.gates;
++
++import era.mi.logic.types.BitVector.BitVectorMutator;
++import era.mi.logic.wires.Wire.WireEnd;
++
++/**
++ * Outputs 1 when the number of 1 inputs is odd.
++ *
++ * @author Fabian Stemmler
++ */
++public class XorGate extends MultiInputGate
++{
++ public XorGate(int processTime, WireEnd out, WireEnd... in)
++ {
++ super(processTime, BitVectorMutator::xor, out, in);
++ }
++
++}
--- /dev/null
-package era.mi.logic.tests;\r
-\r
-import static org.junit.jupiter.api.Assertions.*;\r
-\r
-import java.util.function.LongConsumer;\r
-\r
-import org.junit.jupiter.api.Test;\r
-\r
-import era.mi.logic.Simulation;\r
-import era.mi.logic.components.Connector;\r
-import era.mi.logic.components.Demux;\r
-import era.mi.logic.components.Merger;\r
-import era.mi.logic.components.Mux;\r
-import era.mi.logic.components.Splitter;\r
-import era.mi.logic.components.TriStateBuffer;\r
-import era.mi.logic.components.gates.AndGate;\r
-import era.mi.logic.components.gates.NotGate;\r
-import era.mi.logic.components.gates.OrGate;\r
-import era.mi.logic.components.gates.XorGate;\r
-import era.mi.logic.types.Bit;\r
-import era.mi.logic.types.BitVector;\r
-import era.mi.logic.wires.Wire;\r
-import era.mi.logic.wires.Wire.WireEnd;\r
-\r
-@SuppressWarnings("unused")\r
-class ComponentTest\r
-{\r
-\r
- @Test\r
- void circuitExampleTest()\r
- {\r
- Simulation.TIMELINE.reset();\r
- Wire a = new Wire(1, 1), b = new Wire(1, 1), c = new Wire(1, 10), d = new Wire(2, 1), e = new Wire(1, 1), f = new Wire(1, 1),\r
- g = new Wire(1, 1), h = new Wire(2, 1), i = new Wire(2, 1), j = new Wire(1, 1), k = new Wire(1, 1);\r
- new AndGate(1, f.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd());\r
- new NotGate(1, f.createReadOnlyEnd(), g.createEnd());\r
- new Merger(h.createEnd(), c.createReadOnlyEnd(), g.createReadOnlyEnd());\r
- new Mux(1, i.createEnd(), e.createReadOnlyEnd(), h.createReadOnlyEnd(), d.createReadOnlyEnd());\r
- new Splitter(i.createReadOnlyEnd(), k.createEnd(), j.createEnd());\r
-\r
- a.createEnd().feedSignals(Bit.ZERO);\r
- b.createEnd().feedSignals(Bit.ONE);\r
- c.createEnd().feedSignals(Bit.ZERO);\r
- d.createEnd().feedSignals(Bit.ONE, Bit.ONE);\r
- e.createEnd().feedSignals(Bit.ZERO);\r
-\r
- Simulation.TIMELINE.executeAll();\r
-\r
- assertEquals(Bit.ONE, j.getValue());\r
- assertEquals(Bit.ZERO, k.getValue());\r
- }\r
-\r
- @Test\r
- void splitterTest()\r
- {\r
- Simulation.TIMELINE.reset();\r
- Wire a = new Wire(3, 1), b = new Wire(2, 1), c = new Wire(3, 1), in = new Wire(8, 1);\r
- in.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE);\r
- new Splitter(in.createReadOnlyEnd(), a.createEnd(), b.createEnd(), c.createEnd());\r
-\r
- Simulation.TIMELINE.executeAll();\r
-\r
- assertBitArrayEquals(a.getValues(), Bit.ZERO, Bit.ONE, Bit.ZERO);\r
- assertBitArrayEquals(b.getValues(), Bit.ONE, Bit.ZERO);\r
- assertBitArrayEquals(c.getValues(), Bit.ONE, Bit.ZERO, Bit.ONE);\r
- }\r
-\r
- @Test\r
- void mergerTest()\r
- {\r
- Simulation.TIMELINE.reset();\r
- Wire a = new Wire(3, 1), b = new Wire(2, 1), c = new Wire(3, 1), out = new Wire(8, 1);\r
- a.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO);\r
- b.createEnd().feedSignals(Bit.ONE, Bit.ZERO);\r
- c.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE);\r
-\r
- new Merger(out.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd(), c.createReadOnlyEnd());\r
-\r
- Simulation.TIMELINE.executeAll();\r
-\r
- assertBitArrayEquals(out.getValues(), Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE);\r
- }\r
-\r
- @Test\r
- void triStateBufferTest()\r
- {\r
- Wire a = new Wire(1, 1), b = new Wire(1, 1), en = new Wire(1, 1), notEn = new Wire(1, 1);\r
- new NotGate(1, en.createReadOnlyEnd(), notEn.createEnd());\r
- new TriStateBuffer(1, a.createReadOnlyEnd(), b.createEnd(), en.createReadOnlyEnd());\r
- new TriStateBuffer(1, b.createReadOnlyEnd(), a.createEnd(), notEn.createReadOnlyEnd());\r
-\r
- WireEnd enI = en.createEnd(), aI = a.createEnd(), bI = b.createEnd();\r
- enI.feedSignals(Bit.ONE);\r
- aI.feedSignals(Bit.ONE);\r
- bI.feedSignals(Bit.Z);\r
-\r
- Simulation.TIMELINE.executeAll();\r
-\r
- assertEquals(Bit.ONE, b.getValue());\r
-\r
- bI.feedSignals(Bit.ZERO);\r
-\r
- Simulation.TIMELINE.executeAll();\r
-\r
- assertEquals(Bit.X, b.getValue());\r
- assertEquals(Bit.ONE, a.getValue());\r
-\r
- aI.clearSignals();\r
- enI.feedSignals(Bit.ZERO);\r
-\r
- Simulation.TIMELINE.executeAll();\r
-\r
- assertEquals(Bit.ZERO, a.getValue());\r
-\r
- }\r
-\r
- @Test\r
- void muxTest()\r
- {\r
- Simulation.TIMELINE.reset();\r
- Wire a = new Wire(4, 3), b = new Wire(4, 6), c = new Wire(4, 4), select = new Wire(2, 5), out = new Wire(4, 1);\r
- WireEnd selectIn = select.createEnd();\r
-\r
- selectIn.feedSignals(Bit.ZERO, Bit.ZERO);\r
- a.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO);\r
- c.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE);\r
-\r
- new Mux(1, out.createEnd(), select.createReadOnlyEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd(), c.createReadOnlyEnd());\r
- Simulation.TIMELINE.executeAll();\r
-\r
- assertBitArrayEquals(out.getValues(), Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO);\r
- selectIn.feedSignals(Bit.ZERO, Bit.ONE);\r
- Simulation.TIMELINE.executeAll();\r
-\r
- assertBitArrayEquals(out.getValues(), Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE);\r
-\r
- selectIn.feedSignals(Bit.ONE, Bit.ONE);\r
- Simulation.TIMELINE.executeAll();\r
-\r
- assertBitArrayEquals(out.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z);\r
-\r
- }\r
-\r
- @Test\r
- void demuxTest()\r
- {\r
- Simulation.TIMELINE.reset();\r
- Wire a = new Wire(4, 3), b = new Wire(4, 6), c = new Wire(4, 4), select = new Wire(2, 5), in = new Wire(4, 1);\r
- WireEnd selectIn = select.createEnd();\r
-\r
- selectIn.feedSignals(Bit.ZERO, Bit.ZERO);\r
- in.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO);\r
-\r
- new Demux(1, in.createReadOnlyEnd(), select.createReadOnlyEnd(), a.createEnd(), b.createEnd(), c.createEnd());\r
- Simulation.TIMELINE.executeAll();\r
-\r
- assertBitArrayEquals(a.getValues(), Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO);\r
- assertBitArrayEquals(b.getValues(), Bit.U, Bit.U, Bit.U, Bit.U);\r
- assertBitArrayEquals(c.getValues(), Bit.U, Bit.U, Bit.U, Bit.U);\r
- selectIn.feedSignals(Bit.ZERO, Bit.ONE);\r
- Simulation.TIMELINE.executeAll();\r
-\r
- assertBitArrayEquals(a.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z);\r
- assertBitArrayEquals(b.getValues(), Bit.U, Bit.U, Bit.U, Bit.U);\r
- assertBitArrayEquals(c.getValues(), Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO);\r
-\r
- selectIn.feedSignals(Bit.ONE, Bit.ONE);\r
- Simulation.TIMELINE.executeAll();\r
-\r
- assertBitArrayEquals(a.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z);\r
- assertBitArrayEquals(b.getValues(), Bit.U, Bit.U, Bit.U, Bit.U);\r
- assertBitArrayEquals(c.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z);\r
-\r
- }\r
-\r
- @Test\r
- void andTest()\r
- {\r
- Simulation.TIMELINE.reset();\r
- Wire a = new Wire(4, 1), b = new Wire(4, 3), c = new Wire(4, 1);\r
- new AndGate(1, c.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd());\r
- a.createEnd().feedSignals(Bit.ONE, Bit.ONE, Bit.ZERO, Bit.ZERO);\r
- b.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE);\r
-\r
- Simulation.TIMELINE.executeAll();\r
-\r
- assertBitArrayEquals(c.getValues(), Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ZERO);\r
- }\r
-\r
- @Test\r
- void orTest()\r
- {\r
- Simulation.TIMELINE.reset();\r
- Wire a = new Wire(4, 1), b = new Wire(4, 3), c = new Wire(4, 1);\r
- new OrGate(1, c.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd());\r
- a.createEnd().feedSignals(Bit.ONE, Bit.ONE, Bit.ZERO, Bit.ZERO);\r
- b.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE);\r
-\r
- Simulation.TIMELINE.executeAll();\r
-\r
- assertBitArrayEquals(c.getValues(), Bit.ONE, Bit.ONE, Bit.ZERO, Bit.ONE);\r
- }\r
-\r
- @Test\r
- void xorTest()\r
- {\r
- Simulation.TIMELINE.reset();\r
- Wire a = new Wire(3, 1), b = new Wire(3, 2), c = new Wire(3, 1), d = new Wire(3, 1);\r
- new XorGate(1, d.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd(), c.createReadOnlyEnd());\r
- a.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ONE);\r
- b.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE);\r
- c.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE);\r
-\r
- Simulation.TIMELINE.executeAll();\r
-\r
- assertBitArrayEquals(d.getValues(), Bit.ZERO, Bit.ONE, Bit.ONE);\r
- }\r
-\r
- @Test\r
- void notTest()\r
- {\r
- Simulation.TIMELINE.reset();\r
- Wire a = new Wire(3, 1), b = new Wire(3, 2);\r
- new NotGate(1, a.createReadOnlyEnd(), b.createEnd());\r
- a.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ONE);\r
-\r
- Simulation.TIMELINE.executeAll();\r
-\r
- assertBitArrayEquals(b.getValues(), Bit.ONE, Bit.ZERO, Bit.ZERO);\r
- }\r
-\r
- @Test\r
- void rsLatchCircuitTest()\r
- {\r
- Simulation.TIMELINE.reset();\r
- Wire r = new Wire(1, 1), s = new Wire(1, 1), t1 = new Wire(1, 15), t2 = new Wire(1, 1), q = new Wire(1, 1), nq = new Wire(1, 1);\r
-\r
- new OrGate(1, t2.createEnd(), r.createReadOnlyEnd(), nq.createReadOnlyEnd());\r
- new OrGate(1, t1.createEnd(), s.createReadOnlyEnd(), q.createReadOnlyEnd());\r
- new NotGate(1, t2.createReadOnlyEnd(), q.createEnd());\r
- new NotGate(1, t1.createReadOnlyEnd(), nq.createEnd());\r
-\r
- WireEnd sIn = s.createEnd(), rIn = r.createEnd();\r
-\r
- sIn.feedSignals(Bit.ONE);\r
- rIn.feedSignals(Bit.ZERO);\r
-\r
- Simulation.TIMELINE.executeAll();\r
-\r
- assertEquals(Bit.ONE, q.getValue());\r
- assertEquals(Bit.ZERO, nq.getValue());\r
-\r
- sIn.feedSignals(Bit.ZERO);\r
-\r
- Simulation.TIMELINE.executeAll();\r
- assertEquals(Bit.ONE, q.getValue());\r
- assertEquals(Bit.ZERO, nq.getValue());\r
-\r
- rIn.feedSignals(Bit.ONE);\r
-\r
- Simulation.TIMELINE.executeAll();\r
-\r
- assertEquals(Bit.ZERO, q.getValue());\r
- assertEquals(Bit.ONE, nq.getValue());\r
- }\r
-\r
- @Test\r
- void numericValueTest()\r
- {\r
- Simulation.TIMELINE.reset();\r
-\r
- Wire a = new Wire(4, 1);\r
- a.createEnd().feedSignals(Bit.ONE, Bit.ONE, Bit.ONE, Bit.ONE);\r
-\r
- Simulation.TIMELINE.executeAll();\r
-\r
- assertEquals(15, a.getUnsignedValue());\r
- assertEquals(-1, a.getSignedValue());\r
- }\r
-\r
- @Test\r
- void multipleInputs()\r
- {\r
- Simulation.TIMELINE.reset();\r
- Wire w = new Wire(2, 1);\r
- WireEnd wI1 = w.createEnd(), wI2 = w.createEnd();\r
- wI1.feedSignals(Bit.ONE, Bit.Z);\r
- wI2.feedSignals(Bit.Z, Bit.X);\r
- Simulation.TIMELINE.executeAll();\r
- assertBitArrayEquals(w.getValues(), Bit.ONE, Bit.X);\r
-\r
- wI2.feedSignals(Bit.ZERO, Bit.Z);\r
- Simulation.TIMELINE.executeAll();\r
- assertBitArrayEquals(w.getValues(), Bit.X, Bit.Z);\r
-\r
- wI2.feedSignals(Bit.Z, Bit.Z);\r
- Simulation.TIMELINE.executeAll();\r
- assertBitArrayEquals(w.getValues(), Bit.ONE, Bit.Z);\r
-\r
- wI2.feedSignals(Bit.ONE, Bit.Z);\r
- w.addObserver((i, oldValues) -> fail("WireArray notified observer, although value did not change."));\r
- Simulation.TIMELINE.executeAll();\r
- assertBitArrayEquals(w.getValues(), Bit.ONE, Bit.Z);\r
- }\r
-\r
- @Test\r
- void wireConnections()\r
- {\r
- // Nur ein Experiment, was über mehrere 'passive' Bausteine hinweg passieren würde\r
-\r
- Simulation.TIMELINE.reset();\r
-\r
- Wire a = new Wire(1, 2);\r
- Wire b = new Wire(1, 2);\r
- Wire c = new Wire(1, 2);\r
- WireEnd aI = a.createEnd();\r
- WireEnd bI = b.createEnd();\r
- WireEnd cI = c.createEnd();\r
-\r
- TestBitDisplay test = new TestBitDisplay(c.createReadOnlyEnd());\r
- TestBitDisplay test2 = new TestBitDisplay(a.createReadOnlyEnd());\r
- LongConsumer print = time -> System.out.format("Time %2d\n a: %s\n b: %s\n c: %s\n", time, a, b, c);\r
-\r
- cI.feedSignals(Bit.ONE);\r
- test.assertAfterSimulationIs(print, Bit.ONE);\r
-\r
- cI.feedSignals(Bit.X);\r
- test.assertAfterSimulationIs(print, Bit.X);\r
-\r
- cI.feedSignals(Bit.X);\r
- cI.feedSignals(Bit.Z);\r
- test.assertAfterSimulationIs(print, Bit.Z);\r
-\r
- new Connector(b.createEnd(), c.createEnd()).connect();\r
- test.assertAfterSimulationIs(print, Bit.Z);\r
- System.err.println("ONE");\r
- bI.feedSignals(Bit.ONE);\r
- test.assertAfterSimulationIs(print, Bit.ONE);\r
- System.err.println("ZERO");\r
- bI.feedSignals(Bit.ZERO);\r
- test.assertAfterSimulationIs(print, Bit.ZERO);\r
- System.err.println("Z");\r
- bI.feedSignals(Bit.Z);\r
- test.assertAfterSimulationIs(print, Bit.Z);\r
-\r
- new Connector(a.createEnd(), b.createEnd()).connect();\r
- System.err.println("Z 2");\r
- aI.feedSignals(Bit.Z);\r
- test.assertAfterSimulationIs(print, Bit.Z);\r
- test2.assertAfterSimulationIs(Bit.Z);\r
- System.err.println("ONE 2");\r
- aI.feedSignals(Bit.ONE);\r
- test.assertAfterSimulationIs(print, Bit.ONE);\r
- test2.assertAfterSimulationIs(Bit.ONE);\r
- System.err.println("ZERO 2");\r
- aI.feedSignals(Bit.ZERO);\r
- test.assertAfterSimulationIs(print, Bit.ZERO);\r
- test2.assertAfterSimulationIs(Bit.ZERO);\r
- System.err.println("Z 2 II");\r
- aI.feedSignals(Bit.Z);\r
- test.assertAfterSimulationIs(print, Bit.Z);\r
- test2.assertAfterSimulationIs(Bit.Z);\r
-\r
- System.err.println("No Conflict yet");\r
- bI.feedSignals(Bit.ONE);\r
- test.assertAfterSimulationIs(print, Bit.ONE);\r
- test2.assertAfterSimulationIs(Bit.ONE);\r
- aI.feedSignals(Bit.ONE);\r
- test.assertAfterSimulationIs(print, Bit.ONE);\r
- test2.assertAfterSimulationIs(Bit.ONE);\r
- System.err.println("Conflict");\r
- aI.feedSignals(Bit.ZERO);\r
- test.assertAfterSimulationIs(print, Bit.X);\r
- test2.assertAfterSimulationIs(Bit.X);\r
- aI.feedSignals(Bit.ONE);\r
- test.assertAfterSimulationIs(print, Bit.ONE);\r
- test2.assertAfterSimulationIs(Bit.ONE);\r
- }\r
-\r
- private static void assertBitArrayEquals(BitVector actual, Bit... expected)\r
- {\r
- assertArrayEquals(expected, actual.getBits());\r
- }\r
-}\r
++package era.mi.logic.tests;
++
++import static org.junit.jupiter.api.Assertions.*;
++
++import java.util.function.LongConsumer;
++
++import org.junit.jupiter.api.Test;
++
++import era.mi.logic.Simulation;
++import era.mi.logic.components.Connector;
++import era.mi.logic.components.Demux;
++import era.mi.logic.components.Merger;
++import era.mi.logic.components.Mux;
++import era.mi.logic.components.Splitter;
++import era.mi.logic.components.TriStateBuffer;
++import era.mi.logic.components.gates.AndGate;
++import era.mi.logic.components.gates.NotGate;
++import era.mi.logic.components.gates.OrGate;
++import era.mi.logic.components.gates.XorGate;
++import era.mi.logic.types.Bit;
++import era.mi.logic.types.BitVector;
++import era.mi.logic.wires.Wire;
++import era.mi.logic.wires.Wire.WireEnd;
++
++@SuppressWarnings("unused")
++class ComponentTest
++{
++
++ @Test
++ void circuitExampleTest()
++ {
++ Simulation.TIMELINE.reset();
++ Wire a = new Wire(1, 1), b = new Wire(1, 1), c = new Wire(1, 10), d = new Wire(2, 1), e = new Wire(1, 1), f = new Wire(1, 1),
++ g = new Wire(1, 1), h = new Wire(2, 1), i = new Wire(2, 1), j = new Wire(1, 1), k = new Wire(1, 1);
++ new AndGate(1, f.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd());
++ new NotGate(1, f.createReadOnlyEnd(), g.createEnd());
++ new Merger(h.createEnd(), c.createReadOnlyEnd(), g.createReadOnlyEnd());
++ new Mux(1, i.createEnd(), e.createReadOnlyEnd(), h.createReadOnlyEnd(), d.createReadOnlyEnd());
++ new Splitter(i.createReadOnlyEnd(), k.createEnd(), j.createEnd());
++
++ a.createEnd().feedSignals(Bit.ZERO);
++ b.createEnd().feedSignals(Bit.ONE);
++ c.createEnd().feedSignals(Bit.ZERO);
++ d.createEnd().feedSignals(Bit.ONE, Bit.ONE);
++ e.createEnd().feedSignals(Bit.ZERO);
++
++ Simulation.TIMELINE.executeAll();
++
++ assertEquals(Bit.ONE, j.getValue());
++ assertEquals(Bit.ZERO, k.getValue());
++ }
++
++ @Test
++ void splitterTest()
++ {
++ Simulation.TIMELINE.reset();
++ Wire a = new Wire(3, 1), b = new Wire(2, 1), c = new Wire(3, 1), in = new Wire(8, 1);
++ in.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE);
++ new Splitter(in.createReadOnlyEnd(), a.createEnd(), b.createEnd(), c.createEnd());
++
++ Simulation.TIMELINE.executeAll();
++
++ assertBitArrayEquals(a.getValues(), Bit.ZERO, Bit.ONE, Bit.ZERO);
++ assertBitArrayEquals(b.getValues(), Bit.ONE, Bit.ZERO);
++ assertBitArrayEquals(c.getValues(), Bit.ONE, Bit.ZERO, Bit.ONE);
++ }
++
++ @Test
++ void mergerTest()
++ {
++ Simulation.TIMELINE.reset();
++ Wire a = new Wire(3, 1), b = new Wire(2, 1), c = new Wire(3, 1), out = new Wire(8, 1);
++ a.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO);
++ b.createEnd().feedSignals(Bit.ONE, Bit.ZERO);
++ c.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE);
++
++ new Merger(out.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd(), c.createReadOnlyEnd());
++
++ Simulation.TIMELINE.executeAll();
++
++ assertBitArrayEquals(out.getValues(), Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE);
++ }
++
++ @Test
++ void triStateBufferTest()
++ {
++ Wire a = new Wire(1, 1), b = new Wire(1, 1), en = new Wire(1, 1), notEn = new Wire(1, 1);
++ new NotGate(1, en.createReadOnlyEnd(), notEn.createEnd());
++ new TriStateBuffer(1, a.createReadOnlyEnd(), b.createEnd(), en.createReadOnlyEnd());
++ new TriStateBuffer(1, b.createReadOnlyEnd(), a.createEnd(), notEn.createReadOnlyEnd());
++
++ WireEnd enI = en.createEnd(), aI = a.createEnd(), bI = b.createEnd();
++ enI.feedSignals(Bit.ONE);
++ aI.feedSignals(Bit.ONE);
++ bI.feedSignals(Bit.Z);
++
++ Simulation.TIMELINE.executeAll();
++
++ assertEquals(Bit.ONE, b.getValue());
++
++ bI.feedSignals(Bit.ZERO);
++
++ Simulation.TIMELINE.executeAll();
++
++ assertEquals(Bit.X, b.getValue());
++ assertEquals(Bit.ONE, a.getValue());
++
++ aI.clearSignals();
++ enI.feedSignals(Bit.ZERO);
++
++ Simulation.TIMELINE.executeAll();
++
++ assertEquals(Bit.ZERO, a.getValue());
++
++ }
++
++ @Test
++ void muxTest()
++ {
++ Simulation.TIMELINE.reset();
++ Wire a = new Wire(4, 3), b = new Wire(4, 6), c = new Wire(4, 4), select = new Wire(2, 5), out = new Wire(4, 1);
++ WireEnd selectIn = select.createEnd();
++
++ selectIn.feedSignals(Bit.ZERO, Bit.ZERO);
++ a.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO);
++ c.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE);
++
++ new Mux(1, out.createEnd(), select.createReadOnlyEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd(), c.createReadOnlyEnd());
++ Simulation.TIMELINE.executeAll();
++
++ assertBitArrayEquals(out.getValues(), Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO);
++ selectIn.feedSignals(Bit.ZERO, Bit.ONE);
++ Simulation.TIMELINE.executeAll();
++
++ assertBitArrayEquals(out.getValues(), Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE);
++
++ selectIn.feedSignals(Bit.ONE, Bit.ONE);
++ Simulation.TIMELINE.executeAll();
++
++ assertBitArrayEquals(out.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z);
++
++ }
++
++ @Test
++ void demuxTest()
++ {
++ Simulation.TIMELINE.reset();
++ Wire a = new Wire(4, 3), b = new Wire(4, 6), c = new Wire(4, 4), select = new Wire(2, 5), in = new Wire(4, 1);
++ WireEnd selectIn = select.createEnd();
++
++ selectIn.feedSignals(Bit.ZERO, Bit.ZERO);
++ in.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO);
++
++ new Demux(1, in.createReadOnlyEnd(), select.createReadOnlyEnd(), a.createEnd(), b.createEnd(), c.createEnd());
++ Simulation.TIMELINE.executeAll();
++
++ assertBitArrayEquals(a.getValues(), Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO);
++ assertBitArrayEquals(b.getValues(), Bit.U, Bit.U, Bit.U, Bit.U);
++ assertBitArrayEquals(c.getValues(), Bit.U, Bit.U, Bit.U, Bit.U);
++ selectIn.feedSignals(Bit.ZERO, Bit.ONE);
++ Simulation.TIMELINE.executeAll();
++
++ assertBitArrayEquals(a.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z);
++ assertBitArrayEquals(b.getValues(), Bit.U, Bit.U, Bit.U, Bit.U);
++ assertBitArrayEquals(c.getValues(), Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO);
++
++ selectIn.feedSignals(Bit.ONE, Bit.ONE);
++ Simulation.TIMELINE.executeAll();
++
++ assertBitArrayEquals(a.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z);
++ assertBitArrayEquals(b.getValues(), Bit.U, Bit.U, Bit.U, Bit.U);
++ assertBitArrayEquals(c.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z);
++
++ }
++
++ @Test
++ void andTest()
++ {
++ Simulation.TIMELINE.reset();
++ Wire a = new Wire(4, 1), b = new Wire(4, 3), c = new Wire(4, 1);
++ new AndGate(1, c.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd());
++ a.createEnd().feedSignals(Bit.ONE, Bit.ONE, Bit.ZERO, Bit.ZERO);
++ b.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE);
++
++ Simulation.TIMELINE.executeAll();
++
++ assertBitArrayEquals(c.getValues(), Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ZERO);
++ }
++
++ @Test
++ void orTest()
++ {
++ Simulation.TIMELINE.reset();
++ Wire a = new Wire(4, 1), b = new Wire(4, 3), c = new Wire(4, 1);
++ new OrGate(1, c.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd());
++ a.createEnd().feedSignals(Bit.ONE, Bit.ONE, Bit.ZERO, Bit.ZERO);
++ b.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE);
++
++ Simulation.TIMELINE.executeAll();
++
++ assertBitArrayEquals(c.getValues(), Bit.ONE, Bit.ONE, Bit.ZERO, Bit.ONE);
++ }
++
++ @Test
++ void xorTest()
++ {
++ Simulation.TIMELINE.reset();
++ Wire a = new Wire(3, 1), b = new Wire(3, 2), c = new Wire(3, 1), d = new Wire(3, 1);
++ new XorGate(1, d.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd(), c.createReadOnlyEnd());
++ a.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ONE);
++ b.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE);
++ c.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE);
++
++ Simulation.TIMELINE.executeAll();
++
++ assertBitArrayEquals(d.getValues(), Bit.ZERO, Bit.ONE, Bit.ONE);
++ }
++
++ @Test
++ void notTest()
++ {
++ Simulation.TIMELINE.reset();
++ Wire a = new Wire(3, 1), b = new Wire(3, 2);
++ new NotGate(1, a.createReadOnlyEnd(), b.createEnd());
++ a.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ONE);
++
++ Simulation.TIMELINE.executeAll();
++
++ assertBitArrayEquals(b.getValues(), Bit.ONE, Bit.ZERO, Bit.ZERO);
++ }
++
++ @Test
++ void rsLatchCircuitTest()
++ {
++ Simulation.TIMELINE.reset();
++ Wire r = new Wire(1, 1), s = new Wire(1, 1), t1 = new Wire(1, 15), t2 = new Wire(1, 1), q = new Wire(1, 1), nq = new Wire(1, 1);
++
++ new OrGate(1, t2.createEnd(), r.createReadOnlyEnd(), nq.createReadOnlyEnd());
++ new OrGate(1, t1.createEnd(), s.createReadOnlyEnd(), q.createReadOnlyEnd());
++ new NotGate(1, t2.createReadOnlyEnd(), q.createEnd());
++ new NotGate(1, t1.createReadOnlyEnd(), nq.createEnd());
++
++ WireEnd sIn = s.createEnd(), rIn = r.createEnd();
++
++ sIn.feedSignals(Bit.ONE);
++ rIn.feedSignals(Bit.ZERO);
++
++ Simulation.TIMELINE.executeAll();
++
++ assertEquals(Bit.ONE, q.getValue());
++ assertEquals(Bit.ZERO, nq.getValue());
++
++ sIn.feedSignals(Bit.ZERO);
++
++ Simulation.TIMELINE.executeAll();
++ assertEquals(Bit.ONE, q.getValue());
++ assertEquals(Bit.ZERO, nq.getValue());
++
++ rIn.feedSignals(Bit.ONE);
++
++ Simulation.TIMELINE.executeAll();
++
++ assertEquals(Bit.ZERO, q.getValue());
++ assertEquals(Bit.ONE, nq.getValue());
++ }
++
++ @Test
++ void numericValueTest()
++ {
++ Simulation.TIMELINE.reset();
++
++ Wire a = new Wire(4, 1);
++ a.createEnd().feedSignals(Bit.ONE, Bit.ONE, Bit.ONE, Bit.ONE);
++
++ Simulation.TIMELINE.executeAll();
++
++ assertEquals(15, a.getUnsignedValue());
++ assertEquals(-1, a.getSignedValue());
++ }
++
++ @Test
++ void multipleInputs()
++ {
++ Simulation.TIMELINE.reset();
++ Wire w = new Wire(2, 1);
++ WireEnd wI1 = w.createEnd(), wI2 = w.createEnd();
++ wI1.feedSignals(Bit.ONE, Bit.Z);
++ wI2.feedSignals(Bit.Z, Bit.X);
++ Simulation.TIMELINE.executeAll();
++ assertBitArrayEquals(w.getValues(), Bit.ONE, Bit.X);
++
++ wI2.feedSignals(Bit.ZERO, Bit.Z);
++ Simulation.TIMELINE.executeAll();
++ assertBitArrayEquals(w.getValues(), Bit.X, Bit.Z);
++
++ wI2.feedSignals(Bit.Z, Bit.Z);
++ Simulation.TIMELINE.executeAll();
++ assertBitArrayEquals(w.getValues(), Bit.ONE, Bit.Z);
++
++ wI2.feedSignals(Bit.ONE, Bit.Z);
++ w.addObserver((i, oldValues) -> fail("WireArray notified observer, although value did not change."));
++ Simulation.TIMELINE.executeAll();
++ assertBitArrayEquals(w.getValues(), Bit.ONE, Bit.Z);
++ }
++
++ @Test
++ void wireConnections()
++ {
++ // Nur ein Experiment, was über mehrere 'passive' Bausteine hinweg passieren würde
++
++ Simulation.TIMELINE.reset();
++
++ Wire a = new Wire(1, 2);
++ Wire b = new Wire(1, 2);
++ Wire c = new Wire(1, 2);
++ WireEnd aI = a.createEnd();
++ WireEnd bI = b.createEnd();
++ WireEnd cI = c.createEnd();
++
++ TestBitDisplay test = new TestBitDisplay(c.createReadOnlyEnd());
++ TestBitDisplay test2 = new TestBitDisplay(a.createReadOnlyEnd());
++ LongConsumer print = time -> System.out.format("Time %2d\n a: %s\n b: %s\n c: %s\n", time, a, b, c);
++
++ cI.feedSignals(Bit.ONE);
++ test.assertAfterSimulationIs(print, Bit.ONE);
++
++ cI.feedSignals(Bit.X);
++ test.assertAfterSimulationIs(print, Bit.X);
++
++ cI.feedSignals(Bit.X);
++ cI.feedSignals(Bit.Z);
++ test.assertAfterSimulationIs(print, Bit.Z);
++
++ new Connector(b.createEnd(), c.createEnd()).connect();
++ test.assertAfterSimulationIs(print, Bit.Z);
++ System.err.println("ONE");
++ bI.feedSignals(Bit.ONE);
++ test.assertAfterSimulationIs(print, Bit.ONE);
++ System.err.println("ZERO");
++ bI.feedSignals(Bit.ZERO);
++ test.assertAfterSimulationIs(print, Bit.ZERO);
++ System.err.println("Z");
++ bI.feedSignals(Bit.Z);
++ test.assertAfterSimulationIs(print, Bit.Z);
++
++ new Connector(a.createEnd(), b.createEnd()).connect();
++ System.err.println("Z 2");
++ aI.feedSignals(Bit.Z);
++ test.assertAfterSimulationIs(print, Bit.Z);
++ test2.assertAfterSimulationIs(Bit.Z);
++ System.err.println("ONE 2");
++ aI.feedSignals(Bit.ONE);
++ test.assertAfterSimulationIs(print, Bit.ONE);
++ test2.assertAfterSimulationIs(Bit.ONE);
++ System.err.println("ZERO 2");
++ aI.feedSignals(Bit.ZERO);
++ test.assertAfterSimulationIs(print, Bit.ZERO);
++ test2.assertAfterSimulationIs(Bit.ZERO);
++ System.err.println("Z 2 II");
++ aI.feedSignals(Bit.Z);
++ test.assertAfterSimulationIs(print, Bit.Z);
++ test2.assertAfterSimulationIs(Bit.Z);
++
++ System.err.println("No Conflict yet");
++ bI.feedSignals(Bit.ONE);
++ test.assertAfterSimulationIs(print, Bit.ONE);
++ test2.assertAfterSimulationIs(Bit.ONE);
++ aI.feedSignals(Bit.ONE);
++ test.assertAfterSimulationIs(print, Bit.ONE);
++ test2.assertAfterSimulationIs(Bit.ONE);
++ System.err.println("Conflict");
++ aI.feedSignals(Bit.ZERO);
++ test.assertAfterSimulationIs(print, Bit.X);
++ test2.assertAfterSimulationIs(Bit.X);
++ aI.feedSignals(Bit.ONE);
++ test.assertAfterSimulationIs(print, Bit.ONE);
++ test2.assertAfterSimulationIs(Bit.ONE);
++ }
++
++ private static void assertBitArrayEquals(BitVector actual, Bit... expected)
++ {
++ assertArrayEquals(expected, actual.getBits());
++ }
++}
--- /dev/null
-package era.mi.logic.tests;\r
-\r
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;\r
-\r
-import java.util.function.LongConsumer;\r
-\r
-import era.mi.logic.Simulation;\r
-import era.mi.logic.components.BitDisplay;\r
-import era.mi.logic.types.Bit;\r
-import era.mi.logic.wires.Wire.WireEnd;\r
-\r
-public final class TestBitDisplay extends BitDisplay\r
-{\r
-\r
- public TestBitDisplay(WireEnd in)\r
- {\r
- super(in);\r
- }\r
-\r
- public void assertDisplays(Bit... expected)\r
- {\r
- assertArrayEquals(expected, getDisplayedValue().getBits());\r
- }\r
-\r
- public void assertAfterSimulationIs(Bit... expected)\r
- {\r
- Simulation.TIMELINE.executeAll();\r
- assertDisplays(expected);\r
- }\r
-\r
- public void assertAfterSimulationIs(LongConsumer r, Bit... expected)\r
- {\r
- while (Simulation.TIMELINE.hasNext())\r
- {\r
- Simulation.TIMELINE.executeNext();\r
- r.accept(Simulation.TIMELINE.getSimulationTime());\r
- }\r
- assertDisplays(expected);\r
- }\r
-\r
- @Override\r
- protected void compute()\r
- {\r
- super.compute();\r
- System.out.println("update: value is " + getDisplayedValue());\r
- }\r
-}\r
++package era.mi.logic.tests;
++
++import static org.junit.jupiter.api.Assertions.assertArrayEquals;
++
++import java.util.function.LongConsumer;
++
++import era.mi.logic.Simulation;
++import era.mi.logic.components.BitDisplay;
++import era.mi.logic.types.Bit;
++import era.mi.logic.wires.Wire.WireEnd;
++
++public final class TestBitDisplay extends BitDisplay
++{
++
++ public TestBitDisplay(WireEnd in)
++ {
++ super(in);
++ }
++
++ public void assertDisplays(Bit... expected)
++ {
++ assertArrayEquals(expected, getDisplayedValue().getBits());
++ }
++
++ public void assertAfterSimulationIs(Bit... expected)
++ {
++ Simulation.TIMELINE.executeAll();
++ assertDisplays(expected);
++ }
++
++ public void assertAfterSimulationIs(LongConsumer r, Bit... expected)
++ {
++ while (Simulation.TIMELINE.hasNext())
++ {
++ Simulation.TIMELINE.executeNext();
++ r.accept(Simulation.TIMELINE.getSimulationTime());
++ }
++ assertDisplays(expected);
++ }
++
++ @Override
++ protected void compute()
++ {
++ super.compute();
++ System.out.println("update: value is " + getDisplayedValue());
++ }
++}
--- /dev/null
-package era.mi.logic.timeline;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.PriorityQueue;\r
-import java.util.function.Consumer;\r
-\r
-/**\r
- * Orders Events by the time they are due to be executed. Can execute Events individually.\r
- * \r
- * @author Fabian Stemmler\r
- *\r
- */\r
-public class Timeline\r
-{\r
- private PriorityQueue<InnerEvent> events;\r
- private long currentTime = 0;\r
-\r
- private final List<Consumer<TimelineEvent>> eventAddedListener;\r
-\r
- public Timeline(int initCapacity)\r
- {\r
- events = new PriorityQueue<InnerEvent>(initCapacity, (a, b) ->\r
- {\r
- long difference = a.getTiming() - b.getTiming();\r
- if (difference == 0)\r
- return 0;\r
- return difference < 0 ? -1 : 1;\r
- });\r
-\r
- eventAddedListener = new ArrayList<>();\r
- }\r
-\r
- public boolean hasNext()\r
- {\r
- return !events.isEmpty();\r
- }\r
-\r
- public void executeNext()\r
- {\r
- InnerEvent first = events.poll();\r
- currentTime = first.getTiming();\r
- first.run();\r
- }\r
-\r
- public void executeAll()\r
- {\r
- while (hasNext())\r
- executeNext();\r
- }\r
-\r
- /**\r
- * Executes all events up to a given simulation timestamp. The simulation process can be constrained by a real world timestamp.\r
- * \r
- * @param timestamp the simulation timestamp up to which the events will be processed\r
- * @param stopMillis the System.currentTimeMillis() when simulation definitely needs to stop.\r
- * @return if it was possible to fulfil the goal in the given real world time.\r
- * @author Christian Femers\r
- */\r
- public ExecutionResult executeUpTo(long timestamp, long stopMillis)\r
- {\r
- if (events.isEmpty())\r
- {\r
- currentTime = timestamp;\r
- return ExecutionResult.NOTHING_DONE;\r
- }\r
- int checkStop = 0;\r
- InnerEvent first = events.peek();\r
- while (first != null && first.getTiming() <= timestamp)\r
- {\r
- events.remove();\r
- currentTime = first.getTiming();\r
- first.run();\r
- // Don't check after every run\r
- checkStop = (checkStop + 1) % 10;\r
- if (checkStop == 0 && System.currentTimeMillis() >= stopMillis)\r
- return ExecutionResult.RAN_OUT_OF_TIME;\r
- first = events.peek();\r
- }\r
- currentTime = timestamp;\r
- return ExecutionResult.DONE_IN_TIME;\r
- }\r
-\r
- public long getSimulationTime()\r
- {\r
- return currentTime;\r
- }\r
-\r
- public long nextEventTime()\r
- {\r
- if (!hasNext())\r
- return -1;\r
- return events.peek().timing;\r
- }\r
-\r
- public void reset()\r
- {\r
- events.clear();\r
- currentTime = 0;\r
- }\r
-\r
- public void addEventAddedListener(Consumer<TimelineEvent> listener)\r
- {\r
- eventAddedListener.add(listener);\r
- }\r
-\r
- public void removeEventAddedListener(Consumer<TimelineEvent> listener)\r
- {\r
- eventAddedListener.remove(listener);\r
- }\r
-\r
- /**\r
- * Adds an Event to the {@link Timeline}\r
- * \r
- * @param function The {@link TimelineEventHandler} that will be executed, when the {@link InnerEvent} occurs on the timeline.\r
- * @param relativeTiming The amount of MI ticks in which the {@link InnerEvent} is called, starting from the current time.\r
- */\r
- public void addEvent(TimelineEventHandler function, int relativeTiming)\r
- {\r
- long timing = currentTime + relativeTiming;\r
- TimelineEvent event = new TimelineEvent(timing);\r
- events.add(new InnerEvent(function, event, timing));\r
- eventAddedListener.forEach(l -> l.accept(event));\r
- }\r
-\r
- private class InnerEvent\r
- {\r
-\r
- final long timing;\r
- private final TimelineEventHandler function;\r
- private final TimelineEvent event;\r
-\r
- /**\r
- * Creates an {@link InnerEvent}\r
- * \r
- * @param function {@link TimelineEventHandler} to be executed when the {@link InnerEvent} occurs\r
- * @param timing Point in the MI simulation {@link Timeline}, at which the {@link InnerEvent} is executed;\r
- */\r
- InnerEvent(TimelineEventHandler function, TimelineEvent event, long timing)\r
- {\r
- this.function = function;\r
- this.event = event;\r
- this.timing = timing;\r
- }\r
-\r
- public long getTiming()\r
- {\r
- return timing;\r
- }\r
-\r
- public void run()\r
- {\r
- function.handle(event);\r
- }\r
-\r
- @Override\r
- public String toString()\r
- {\r
- return event.toString();\r
- }\r
- }\r
-\r
- @Override\r
- public String toString()\r
- {\r
- return "simulation time: " + currentTime + ", " + events.toString();\r
- }\r
-\r
- public static long toNanoseconds(long ticks)\r
- {\r
- return ticks; // TODO: Alter this when it has been determined how ticks should relate to real time.\r
- }\r
-\r
- public enum ExecutionResult\r
- {\r
- NOTHING_DONE, DONE_IN_TIME, RAN_OUT_OF_TIME\r
- }\r
++package era.mi.logic.timeline;
++
++import java.util.ArrayList;
++import java.util.List;
++import java.util.PriorityQueue;
++import java.util.function.Consumer;
++
++/**
++ * Orders Events by the time they are due to be executed. Can execute Events individually.
++ *
++ * @author Fabian Stemmler
++ *
++ */
++public class Timeline
++{
++ private PriorityQueue<InnerEvent> events;
++ private long currentTime = 0;
++
++ private final List<Consumer<TimelineEvent>> eventAddedListener;
++
++ public Timeline(int initCapacity)
++ {
++ events = new PriorityQueue<InnerEvent>(initCapacity, (a, b) ->
++ {
++ long difference = a.getTiming() - b.getTiming();
++ if (difference == 0)
++ return 0;
++ return difference < 0 ? -1 : 1;
++ });
++
++ eventAddedListener = new ArrayList<>();
++ }
++
++ public boolean hasNext()
++ {
++ return !events.isEmpty();
++ }
++
++ public void executeNext()
++ {
++ InnerEvent first = events.poll();
++ currentTime = first.getTiming();
++ first.run();
++ }
++
++ public void executeAll()
++ {
++ while (hasNext())
++ executeNext();
++ }
++
++ /**
++ * Executes all events up to a given simulation timestamp. The simulation process can be constrained by a real world timestamp.
++ *
++ * @param timestamp the simulation timestamp up to which the events will be processed
++ * @param stopMillis the System.currentTimeMillis() when simulation definitely needs to stop.
++ * @return if it was possible to fulfil the goal in the given real world time.
++ * @author Christian Femers
++ */
++ public ExecutionResult executeUpTo(long timestamp, long stopMillis)
++ {
++ if (events.isEmpty())
++ {
++ currentTime = timestamp;
++ return ExecutionResult.NOTHING_DONE;
++ }
++ int checkStop = 0;
++ InnerEvent first = events.peek();
++ while (first != null && first.getTiming() <= timestamp)
++ {
++ events.remove();
++ currentTime = first.getTiming();
++ first.run();
++ // Don't check after every run
++ checkStop = (checkStop + 1) % 10;
++ if (checkStop == 0 && System.currentTimeMillis() >= stopMillis)
++ return ExecutionResult.RAN_OUT_OF_TIME;
++ first = events.peek();
++ }
++ currentTime = timestamp;
++ return ExecutionResult.DONE_IN_TIME;
++ }
++
++ public long getSimulationTime()
++ {
++ return currentTime;
++ }
++
++ public long nextEventTime()
++ {
++ if (!hasNext())
++ return -1;
++ return events.peek().timing;
++ }
++
++ public void reset()
++ {
++ events.clear();
++ currentTime = 0;
++ }
++
++ public void addEventAddedListener(Consumer<TimelineEvent> listener)
++ {
++ eventAddedListener.add(listener);
++ }
++
++ public void removeEventAddedListener(Consumer<TimelineEvent> listener)
++ {
++ eventAddedListener.remove(listener);
++ }
++
++ /**
++ * Adds an Event to the {@link Timeline}
++ *
++ * @param function The {@link TimelineEventHandler} that will be executed, when the {@link InnerEvent} occurs on the timeline.
++ * @param relativeTiming The amount of MI ticks in which the {@link InnerEvent} is called, starting from the current time.
++ */
++ public void addEvent(TimelineEventHandler function, int relativeTiming)
++ {
++ long timing = currentTime + relativeTiming;
++ TimelineEvent event = new TimelineEvent(timing);
++ events.add(new InnerEvent(function, event, timing));
++ eventAddedListener.forEach(l -> l.accept(event));
++ }
++
++ private class InnerEvent
++ {
++
++ final long timing;
++ private final TimelineEventHandler function;
++ private final TimelineEvent event;
++
++ /**
++ * Creates an {@link InnerEvent}
++ *
++ * @param function {@link TimelineEventHandler} to be executed when the {@link InnerEvent} occurs
++ * @param timing Point in the MI simulation {@link Timeline}, at which the {@link InnerEvent} is executed;
++ */
++ InnerEvent(TimelineEventHandler function, TimelineEvent event, long timing)
++ {
++ this.function = function;
++ this.event = event;
++ this.timing = timing;
++ }
++
++ public long getTiming()
++ {
++ return timing;
++ }
++
++ public void run()
++ {
++ function.handle(event);
++ }
++
++ @Override
++ public String toString()
++ {
++ return event.toString();
++ }
++ }
++
++ @Override
++ public String toString()
++ {
++ return "simulation time: " + currentTime + ", " + events.toString();
++ }
++
++ public static long toNanoseconds(long ticks)
++ {
++ return ticks; // TODO: Alter this when it has been determined how ticks should relate to real time.
++ }
++
++ public enum ExecutionResult
++ {
++ NOTHING_DONE, DONE_IN_TIME, RAN_OUT_OF_TIME
++ }
+ }
--- /dev/null
-package era.mi.logic.timeline;\r
-\r
-/**\r
- * A class that stores all relevant information about an event in the {@link Timeline}. Currently, there is not much relevant information to\r
- * store.\r
- * \r
- * @author Fabian Stemmler\r
- *\r
- */\r
-public class TimelineEvent\r
-{\r
- private final long timing;\r
-\r
- TimelineEvent(long timing)\r
- {\r
- super();\r
- this.timing = timing;\r
- }\r
-\r
- public long getTiming()\r
- {\r
- return timing;\r
- }\r
-\r
- @Override\r
- public String toString()\r
- {\r
- return "timestamp: " + timing;\r
- }\r
++package era.mi.logic.timeline;
++
++/**
++ * A class that stores all relevant information about an event in the {@link Timeline}. Currently, there is not much relevant information to
++ * store.
++ *
++ * @author Fabian Stemmler
++ *
++ */
++public class TimelineEvent
++{
++ private final long timing;
++
++ TimelineEvent(long timing)
++ {
++ super();
++ this.timing = timing;
++ }
++
++ public long getTiming()
++ {
++ return timing;
++ }
++
++ @Override
++ public String toString()
++ {
++ return "timestamp: " + timing;
++ }
+ }
--- /dev/null
-package era.mi.logic.timeline;\r
-\r
-public interface TimelineEventHandler\r
-{\r
- public void handle(TimelineEvent e);\r
++package era.mi.logic.timeline;
++
++public interface TimelineEventHandler
++{
++ public void handle(TimelineEvent e);
+ }