MyHDL

Shadow Signals are not updating

I found it really difficult to understand what is going on when it comes to the shadow signals behavior.

from the documentation, I assumed that the shadow signal should follow the updates from the original signal. However, I could not get this to work, as shown in the output below.

Am I doing something wrong?

here is my test to understand the shadow signal behavior.

from myhdl import block, Signal, intbv, delay, ConcatSignal, instance, instances, __version__

@block
def Stimulus():

  @instance
  def tb_logic():
      a = Signal(intbv(0)[8:0])
      b = ConcatSignal(a, '000')
      c = a(4,0)
      d = a(0)
      print(a, b, c, d)
      print(f'len(a) = {len(a)}')
      print(f'len(b) = {len(b)}')
      print(f'len(c) = {len(c)}')
      print(f'len(d) = {len(d)}')

      while True:
        a.next = a + 1
        yield (delay(2))
        print(f'a = {a}')
        print(f'b = {b}')        
        print(f'c = {c}')        
        print(f'd = {d}')        
        print('\n===============\n')

  return instances()

if __name__ == '__main__':
    print(f'MyHDL Version = {__version__}')
    inst = Stimulus()
    inst.config_sim(trace=False)
    inst.run_sim(10)
    # print(f'MyHDL Version = {__version__}')

and here is the output:

MyHDL Version = 0.11
00 000 0 False
len(a) = 8
len(b) = 11
len(c) = 4
len(d) = 1
a = 01
b = 000
c = 0
d = False

===============

a = 02
b = 000
c = 0
d = False

===============

a = 03
b = 000
c = 0
d = False

===============

a = 04
b = 000
c = 0
d = False

===============

a = 05
b = 000
c = 0
d = False

===============

<class 'myhdl._SuspendSimulation'>: Simulated 10 timesteps

You declare variables outside the instance (and always_comb et.al.):

@block
def Stimulus():
    a = Signal(intbv(0)[8:0])
    b = ConcatSignal(a, '000')
    c = a(4, 0)
    d = a(0)
    print(a, b, c, d)
    print(f'len(a) = {len(a)}')
    print(f'len(b) = {len(b)}')
    print(f'len(c) = {len(c)}')
    print(f'len(d) = {len(d)}')

    @instance
    def tb_logic():
        while True:
            a.next = a + 1
            yield (delay(2))
            print(f'a = {a}')
            print(f'b = {b}')
            print(f'c = {c}')
            print(f'd = {d}')
            print('\n===============\n')

    return instances()

MyHDL Version = 0.11
00 000 0 False
len(a) = 8
len(b) = 11
len(c) = 4
len(d) = 1
a = 01
b = 008
c = 1
d = True

===============

a = 02
b = 010
c = 2
d = False

===============

a = 03
b = 018
c = 3
d = True

===============

a = 04
b = 020
c = 4
d = False

===============

a = 05
b = 028
c = 5
d = True

===============

<class 'myhdl._SuspendSimulation'>: Simulated 10 timesteps

Thank you, it is working now.