def test_multi_level_trace():
    class Top(Component):
        def construct(s):
            s.simple_trace = 'simple'
            s.verbose_trace = 'verbose'

        def line_trace(s, level='simple'):
            if level == 'simple':
                return "{}".format(s.simple_trace)
            elif level == 'verbose':
                return "{}".format(s.verbose_trace)
            else:
                return "default"

    A = Top()
    A.set_param('top.line_trace', level='verbose')
    A.elaborate()
    A.apply(GenDAGPass())
    A.apply(WrapGreenletPass())
    A.apply(SimpleSchedulePass())
    A.apply(CLLineTracePass())
    A.apply(SimpleTickPass())
    A.apply(LineTraceParamPass())
    A.lock_in_simulation()
    A.tick()
    print(A.line_trace())
    assert A.line_trace() == "verbose"
def _test_model(cls):
    A = cls()
    A.elaborate()
    A.apply(GenDAGPass())
    A.apply(DynamicSchedulePass())
    A.apply(SimpleTickPass())
    A.lock_in_simulation()

    T = 0
    while T < 5:
        A.tick()
        print(A.line_trace())
        T += 1
示例#3
0
def test_top_level_method():

  class Top(Component):

    def construct( s ):
      s.element = None

      s.count = Wire(Bits32)
      s.amp   = Wire(Bits32)

      s.value = Wire(Bits32)

      @s.update_ff
      def up_incr():
        s.count <<= s.count + 1

      @s.update
      def up_amp():
        s.amp = s.count * 100

      @s.update
      def up_compose_in():
        if s.element:
          s.value = s.amp + s.element
          s.element = None
        else:
          s.value = -1

      s.add_constraints(
        M( s.push ) < U( up_compose_in ),
        U( up_compose_in ) < M( s.pull ), # bypass behavior
      )

    @method_port
    def push( s, ele ):
      if s.element is None:
        s.element = ele

    @method_port
    def pull( s ):
      return s.value

    def line_trace( s ):
      return "line trace: {}".format(s.value)

    def done( s ):
      return True

  A = Top()
  A.elaborate()
  A.apply( GenDAGPass() )
  A.apply( OpenLoopCLPass() )
  A.lock_in_simulation()

  print("- push!")
  A.push(7)
  print("- pull!")
  print(A.pull())

  print("- pull!")
  print(A.pull())

  print("- push!")
  A.push(33)
  print("- push!")
  A.push(55)
  print("- pull!")
  print(A.pull())

  print("num_cycles_executed: ", A.num_cycles_executed)
示例#4
0
def _test_TestModuleNonBlockingIfc( cls ):

  A = cls()
  A.elaborate()
  A.apply( GenDAGPass() )
  A.apply( OpenLoopCLPass() )
  A.lock_in_simulation()

  rdy = A.push.rdy()
  print("- push_rdy?", rdy )
  assert not rdy

  rdy = A.push.rdy()
  print("- push_rdy?", rdy)
  assert not rdy

  rdy = A.push.rdy()
  print("- push_rdy?", rdy)
  assert not rdy

  rdy = A.push.rdy()
  print("- push_rdy?", rdy)
  assert not rdy

  rdy = A.push.rdy()
  print("- push_rdy?", rdy)
  assert rdy
  print("- push 13!")
  A.push(13)

  assert A.pull.rdy()
  ret = A.pull()
  print("- pull!", ret)
  assert ret == 413

  assert not A.pull.rdy()

  rdy = A.push.rdy()
  print("- push_rdy?", rdy )
  assert not rdy

  rdy = A.push.rdy()
  print("- push_rdy?", rdy)
  assert not rdy

  rdy = A.push.rdy()
  print("- push_rdy?", rdy)
  assert not rdy

  rdy = A.push.rdy()
  print("- push_rdy?", rdy)
  assert rdy
  print("- push 33!")
  A.push(33)

  assert A.pull.rdy()
  ret = A.pull()
  print("- pull!", ret)
  assert ret == 933

  assert not A.pull.rdy()

  return A.num_cycles_executed