0
from collections import deque
import itertools
lfsr = deque([])
taps = []
i=0
x=0
y=0
test=''

for i in itertools.product([0,1],repeat=15):
    lfsr = deque(i)
    #print(lfsr)
    while x < len(lfsr):
        while y < len(lfsr):
            taps = [x, y]
            #print (lfsr)
            y+=1
        x+=1

Sorry for repost.

I have a simplified version of my code above with the same problem. I am trying to set the lfsr list equal to a binary number, once this is being set i want to use this value within the nested loops. The lfsr is being set correctly i believe as when i uncomment out the first #print, it prints as it should, however when i try to print it during the nested loop, all it outputs is 0's.

What is causing the array/list to be set to 0 and changing from when its initially set? Thanks

1 Answer 1

1

It isn't getting reset. The problem is your loop control. Since you never reset x and y to 0, the only time you enter your while loops is when the dequeue is all 0s.

from collections import deque
import itertools
lfsr = deque([])
taps = []
i=0 
test=''

for i in itertools.product([0,1],repeat=4):
    # reduced length to 4, to see the effects more easily

    lfsr = deque(i)
    print("TOP", lfsr)
    limit = len(lfsr)
    x=0
    while x < limit:
        y=0
        while y < limit:
            taps = [x, y]
            print ("MID", lfsr)
            y+=1
        x+=1

Convert to for loops (which are the proper structure) to make this easier.

for i in itertools.product([0,1],repeat=4):
    lfsr = deque(i)
    print("TOP", lfsr)
    limit = len(lfsr)

    for x in range(limit):
        for y in range(limit):
            taps = [x, y]
            print ("MID", lfsr)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.