[Oberon] FPGA - Bit reversal

Tomas Kral thomas.kral at email.cz
Fri Sep 22 14:33:37 CEST 2017


On Fri, 22 Sep 2017 14:35:20 +0300
Alexander Ilin <ajsoft at yandex.ru> wrote:

> Partially unrolling the loop like that seems the way to go.

Hi Alex,

I primarily make provisions for bitmap operations, just in case it may
be needed. It proved useful for screen capture module `Screen.Mod'

I have tried to unroll the loop, unsure if getting any performance
benefit.

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

I need to give more thinking to lookup tables, I like 8 bit version by
Joerg, 32 bit version seems a bit bulky and not simple.   

As I do also `little' to `big' endian conversions I may only need 8 bit
version, unless I discover hot reverse and swap bits in one go.

Many thanks.

-- 
Tomas Kral <thomas.kral at email.cz>


More information about the Oberon mailing list