()blivion
Active Member
(-_-) ummm. . .
So, trying to make a building block for a PRNG in PICASM for PIC18 instruction set, and I'm having the worst time making it work. If you don't already know, more information on exactly what I'm doing can be found *HERE*. The second or third code box has what I'm doing, only in C. My PIC18ASM source that has worked the best so far is below. I get sequence repetition after only 21081 iterations though, which isn't right.
I'm not getting maximum sequence length out of the register no matter what bit mask I use for the polynomial/taps. I have tried all sorts of different combinations I could think of with all different lengths for the shift register. Maybe I'm not following the algo correctly? The bit mask above is for a 17 bit Galois LFSR as laid out on the wiki article. I use two RRCFs to pass bits through CARRY, which should make it effectively a 17 bit LFSR. I'm doing nByte + 1bit LFSRs because (in theory) it conveniently allows one to do most things with byte oriented instructions while almost entirely avoiding single bit manipulations. Which is the point of implementing a Galois LFSR.
I know the fix is going to be something really stupid too, I just think I've been looking at it to long or something. If I can get it to work with about the same number of instructions as above it will be a really good building block for PIC PRNGs.
Thanks for any assistance.
-()b
So, trying to make a building block for a PRNG in PICASM for PIC18 instruction set, and I'm having the worst time making it work. If you don't already know, more information on exactly what I'm doing can be found *HERE*. The second or third code box has what I'm doing, only in C. My PIC18ASM source that has worked the best so far is below. I get sequence repetition after only 21081 iterations though, which isn't right.
Code:
PRNG RRCF LFSR_B_H, F ; Shift the 16+1 bit register
RRCF LFSR_B_L, F ; (Shifts through the CARRY bit)
BTFSS STATUS, 0 ; Test the output bit.
RETURN
MOVLW b'10010000' ; XOR bits 17 and 14 if bit 0 is set
XORWF LFSR_B_H, F ; store in LFSR high byte.
RETURN
I'm not getting maximum sequence length out of the register no matter what bit mask I use for the polynomial/taps. I have tried all sorts of different combinations I could think of with all different lengths for the shift register. Maybe I'm not following the algo correctly? The bit mask above is for a 17 bit Galois LFSR as laid out on the wiki article. I use two RRCFs to pass bits through CARRY, which should make it effectively a 17 bit LFSR. I'm doing nByte + 1bit LFSRs because (in theory) it conveniently allows one to do most things with byte oriented instructions while almost entirely avoiding single bit manipulations. Which is the point of implementing a Galois LFSR.
I know the fix is going to be something really stupid too, I just think I've been looking at it to long or something. If I can get it to work with about the same number of instructions as above it will be a really good building block for PIC PRNGs.
Thanks for any assistance.
-()b
Last edited: