[Oberon] Volatile variables in Oberon

Jörg Straube joerg.straube at iaeth.ch
Sat Jul 30 07:42:30 CEST 2016


Wojtek

If you really want a memory-mapped variable you could do it e.g. as follows
- - - 
TYPE MemoryMapped = POINTER TO INTEGER;
VAR p: MemoryMapped;
BEGIN
  p := SYSTEM.VAL(MemoryMapped, 0E7F00H) (* assign address of memory to variable *)
  WHILE p^ # 0 DO END;
END
- - - 

But as Chris mentioned the „usual" way in Oberon to do the same is as follows:
- - -
VAR i: INTEGER;
BEGIN
  SYSTEM.GET(0E7F00H, i);
  WHILE i # 0 DO SYSTEM.Get(0E7F00H, i) END;
END
- - - 

But we don’t have to mark „p" as „volatile" as the Oberon compiler does no optimization.
If the compiler generates code for the WHILE loop, and would see „oh, „p" is not changed in the loop so I load „p" to register R3 only once and just check R3", this optimized code would fail in case p is a memory mapped variable. Then you have to mark „p“ as volatile, as hint for the compiler to re-load the value every time.
But the Oberon compiler does not do such kind of optimizations and loads the value of „p" every time. So no „volatile" needed in Oberon.

Jörg

> Am 30.07.2016 um 04:57 schrieb Skulski, Wojciech <skulski at pas.rochester.edu>:
> 
> Chris wrote:
>> I cannot think of a situation where you would need to specify that a
>> variable is volatile when using Oberon-07. Can you think of one?
> 
> Yes I can. If a variable is mapped to a register which can be changed "from the other end" then it is volatile. 
> 
>> This constraint is typically only required on systems that implement unsafe
>> optimisations and variables that are mapped to peripheral registers.
> 
> I am not sure of optimizations. But register mapping is the gist of programming the FPGA. 
> 
> I would rephrase the question: how do we handle memory-mapped registers whose value can change at any time?
> 
> Regards,
> Wojtek
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3583 bytes
Desc: not available
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20160730/1e9eba49/attachment.p7s>


More information about the Oberon mailing list