old_contents: #!/bin/env python
  # Copyright 2020 Google LLC
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     https://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  from nmigen import *
  from nmigen_cfu import InstructionBase, InstructionTestBase, Cfu, CfuTestBase
  import unittest
  
  # See proj_example for further example instructions
  
  class TemplateInstruction(InstructionBase):
      """Template instruction
      """
      def elab(self, m):
          with m.If(self.start):
              m.d.sync += self.output.eq(self.in0 + self.in1)
              m.d.sync += self.done.eq(1)
          with m.Else():
              m.d.sync += self.done.eq(0)
  
  
  class TemplateInstructionTest(InstructionTestBase):
      def create_dut(self):
          return TemplateInstruction()
  
      def test(self):
          self.verify([
              (0, 0, 0),
              (4, 5, 9),
              (0xffffffff, 0xffffffff, 0xfffffffe),
          ])
  
  
  def make_cfu():
      return Cfu({
          # Add instructions here...
          0: TemplateInstruction(),
      })
  
  
  class CfuTest(CfuTestBase):
      def create_dut(self):
          return make_cfu()
  
      def test(self):
          DATA = [
              # Test CFU calls here...
              ((0, 22, 22), 44),
          ]
          return self.run_ops(DATA)
  
  
  if __name__ == '__main__':
      unittest.main()
  
new_contents: #!/bin/env python
  # Copyright 2020 Google LLC
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     https://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  from nmigen import *
  from nmigen_cfu import InstructionBase, InstructionTestBase, Cfu, CfuTestBase
  import unittest
  
  # See proj_example for further example instructions
  
  class AddSyncInstruction(InstructionBase):
      """Template instruction
      """
      def elab(self, m):
          with m.If(self.start):
              m.d.sync += self.output.eq(self.in0 + self.in1)
              m.d.sync += self.done.eq(1)
          with m.Else():
              m.d.sync += self.done.eq(0)
  
  
  class AddCombInstruction(InstructionBase):
      """Template instruction
      """
      def elab(self, m):
          m.d.comb += self.output.eq(self.in0 + self.in1)
          m.d.comb += self.done.eq(1)
  
  
  # class TemplateInstructionTest(InstructionTestBase):
  #     def create_dut(self):
  #         return TemplateInstruction()
  
  #     def test(self):
  #         self.verify([
  #             (0, 0, 0),
  #             (4, 5, 9),
  #             (0xffffffff, 0xffffffff, 0xfffffffe),
  #         ])
  
  
  def make_cfu():
      return Cfu({
          # Add instructions here...
          0: AddSyncInstruction(),
          1: AddCombInstruction(),
      })
  
  
  class CfuTest(CfuTestBase):
      def create_dut(self):
          return make_cfu()
  
      def test(self):
          DATA = [
              # Test CFU calls here...
              ((0, 22, 22), 44),
          ]
          return self.run_ops(DATA)
  
  
  if __name__ == '__main__':
      unittest.main()
  
subject: Add Sync and Comb instructions