Shop OBEX P1 Docs P2 Docs Learn Events
XORO32 parameters don't match alleged values... — Parallax Forums

XORO32 parameters don't match alleged values...

In this forum post, the parameters for the xoroshiro32++ generator are alleged to be A = 14, B = 2, C = 7, D = 5. However, experimental confirmation reveals that it is actually using A = 13, B = 5, C = 10, D = 9. How curious...

CON
_CLKFREQ = 300_000_000

A = 13, B = 5, C = 10, D = 9

PUB main() | seed, val_hw, state_hw, val_soft, state_soft

repeat
  seed := getrnd()
  org
    mov state_hw,seed
    xoro32 state_hw
    mov val_hw,0-0
  end
  state_soft,val_soft := xoro32_soft(seed)
  if state_soft <> state_hw OR val_soft <> val_hw
    debug("FAIL: ",uhex_long(seed,state_hw,state_soft,val_hw,val_soft))


PUB xoro32_soft(seed) : state,val
  state, val.word[0] := xoro32_half(seed)
  state, val.word[1] := xoro32_half(state)

PRI xoro32_half(seed) : state,val | temp
  val.word[0] := rol16(seed.word[0]+seed.word[1],D)+seed.word[0]
  state := seed
  state.word[1] ^= state.word[0]
  state.word[0] := rol16(state.word[0],A) ^ (state.word[1]<<B) ^ state.word[1]
  state.word[1] := rol16(state.word[1],C)

PRI rol16(val,amount) :r
  val.word[1] := val.word[0]
  return (val rol amount) zerox 15

Comments

  • @Wuerfel_21 said:
    In this forum post, the parameters for the xoroshiro32++ generator are alleged to be A = 14, B = 2, C = 7, D = 5. However, experimental confirmation reveals that it is actually using A = 13, B = 5, C = 10, D = 9. How curious...

    How many [A,B,C,D] quadruples did you test? :)
    Post 16 told people about the change. Rev A uses [14,2,7,5].

  • @TonyB_ said:
    How many [A,B,C,D] quadruples did you test? :)

    All 2^16 of them, as it were :)

  • Oh, the irony of not reading the "doc" fully.

Sign In or Register to comment.