Alias for a bit variable

Avra
Schreiberling
Avatar
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

Alias for a bit variable

 · 
Posted: 29.05.2014 - 13:02  ·  #1
Right now I have to make an alias to a port bit variable like this:
Code
var
  SEL_A[@PortG, 3]: bit;
  ComMuxA[@PortG, 3]: bit;

which I do not like because I have to repeat "@PortG, 3" two times. I would prefer something like this instead:
Code
var
  SEL_A[@PortG, 3]: bit;
  ComMuxA[@SEL_A]: bit;

but compiler does not allow it.

Is there some workaround that I am not aware of?
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Alias for a bit variable

 · 
Posted: 29.05.2014 - 15:45  ·  #2
Hello Avra,
a bit type is very, very different from any other types.
It consists of a 16bit address and an 8bit bit-address and is more like a constant than a variable.
So it is impossible to pass such a type to a function for example.
Also your construction will not work, sorry.

But this is working:
Code
var
  BitX[@PortA, 5]: bit;
  
Alias
  BitY      = BitX;
.....
  if BitX then
  endif;
  if BitY then
  endif;

rolf
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   47   61 · Page-Gen-Time: 0.040367s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI