[Oberon] FPGA - SET initialisation

Jörg joerg.straube at iaeth.ch
Sun Apr 30 13:52:34 CEST 2017


In my point of view, the most general answer would be this

VAR
  s: SET; (* 32 bit *)
  i: INTEGER; (* 32 bit *)
BEGIN
 s := SYSTEM.VAL(SET, i)
(* low level type conversion, aka compiler cheating. Not really recommended unless absoluetly needed. *)
END

There are tons of other ways to do it. It depends a little bit, where you get the INTEGER or BYTE value from (constant, memory, over a serial link...)

Jörg

> Am 30.04.2017 um 12:35 schrieb Tomas Kral <thomas.kral at email.cz>:
> 
> Ah yes, sily me.
> 
> But how to best initialise a SET variable with an arbitrary byte /
> integer?
> 
> TYPE ii = POINTER TO iidsc;
> iidsc = STRUCT i: INTEGER END; 
> 
> i := b; SYSTEM.PUT(ii,i); SYSTEM.GET(ii,s); (* initialise a set with
> a byte *)
> SYSTEM.PUT(ii,i); SYSTEM.GET(ii,s); (* initialise a set with an integer
> *)
> 
> Tomas
> 
> On Sun, 30 Apr 2017 12:59:22 +0300
> Alexander Ilin <ajsoft at yandex.ru> wrote:
> 
>> s := { 10 }; makes a SET with 10th bit => s = 0x0400
>> 
>> So, I don't think s := { i } does what you think it would.
>> 
>> 30.04.2017, 12:44, "Tomas Kral" <thomas.kral at email.cz>:
>>> Hi,
>>> 
>>> Reading `SET - neglected data type',
>>> I was wondering, how I could best initialise a SET variable.
>>> 
>>> VAR b: BYTE, i: INTEGER, s: SET;
>>> ...
>>> SYTEM.GET(adr, s); (* reading 4 bytes from adr, easiest but adr MOD
>>> 4! *)
>>> ...
>>> SYTEM.GET(adr, i); s := {i}; (* same result as above? *)
>>> ...
>>> (* provided adr MOD = 0 *)
>>> SYTEM.GET(adr+0, b); s := {b}; (* same result as above? *)
>>> SYTEM.GET(adr+1, b); ASL(s,8); s := s + {b};
>>> SYTEM.GET(adr+2, b); ASL(s,8); s := s + {b};
>>> SYTEM.GET(adr+3, b); ASL(s,8); s := s + {b};
>>> 
>>> Tomas
>>> --
>>> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related
>>> systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
>> 
>> ---=====--- 
>> Александр
>> --
>> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related
>> systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
> 
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon



More information about the Oberon mailing list