[Oberon] FPGA - Bit reversal

Alexander Ilin ajsoft at yandex.ru
Fri Sep 22 13:36:40 CEST 2017


EDIT: the EXCL should be in the IF, of course.

PROCEDURE ReverseWord(wd: INTEGER): INTEGER;
  VAR i: INTEGER; rwd, u: SET;
BEGIN
  u := SYSTEM.VAL(SET, wd);
  rwd := {}; i := 0;
  WHLE u # {} DO
    IF i IN u THEN INCL(rwd, 31-i); EXCL(u, i) END;
    INC(i)
  END
RETURN SYSTEM.VAL(INTEGER, rwd) END ReverseWord;


---=====--- 
 Александр


More information about the Oberon mailing list