J
Jonathan Ross
Guest
I have only been programming full-time in VHDL for a little over a
year so I tend to be skeptical at my ability to come up with
suggestions that would enhance the language. So before I go through
any process to make any official request I'd like to get some feedback
here on a few ideas that I've felt would improve the VHDL experience.
1. 'SCOPE' or 'CONTEXT' - a keyword to define a scope. An example
usage follows:
CountDown : CONTEXT
VARIABLE Counter : UNSIGNED( 15 DOWNTO 0 ) :=
x"FFFF";
BEGIN
Counter := Counter - 1;
END CONTEXT CountDown;
Counter := Counter - 1; -- Error: Counter is not
defined here.
This is a trivial example, but the idea is as follows. Many variables
are used only a few times and in a small section. By having the
variable declaration close to where it's used it makes the code more
readable as the programmer does not need to search through the file
for the definition. Originally the idea was to simply allow the BEGIN
keyword to be used in IF statements, but the syntax would be very odd
with respect to how it would look if you used ELSE statements. This is
broader. I would suggest CONTEXT be allowed both within a process body
and outside of it for the benefit of concurrent statements. This
models one of the uses of the curly brackets in C++.
2. Often times signals are used only within a single process because
the semantics are ideal if you don't want changes to take effect until
the next clock cycle. For example, all of my state machines, even if
they're only defined within a process, are signals. Similar to the
above reasoning of keeping variable declarations close to where
they're used, I'd like to see the SIGNAL keyword be legal to use
wherever you can use VARIABLE. I realize simulators require more CPU
resources to simulate signals than variables and so some people try to
discourage their use, but for those of us who use them often I feel
this would help readability.
3. This is less well thought out than the two above and comes more in
the shape of a problem than a solution. VHDL's ability for static
elaboration is amazing in comparison to many other languages (i.e. C+
+). However, consider the following type. Imagine that I wanted to
implement a LFSR that cycles every N increments. Can this be coded in
VHDL 2008? I.E., can I have something like the following:
TYPE lfsr5 IS lfsr( period => 5 );
....
VARIABLE state : lfsr5 := lfsr5'POS(0);
....
CASE state IS
WHEN lfsr5'POS(0) => ...
WHEN lfsr5'POS(1) => ...
...
WHEN lfsr5'POS(4) => ...
END CASE;
state := state + 1;
I don't see how to do anything quite like that at the moment. The
values of POS(0) through POS(1) for an LFSR depend on the period so
they would need to be generated during elaboration. I wouldn't mind a
custom attribute other than POS to be used, I just don't see how to do
this as a generic variable. If I'm mistaken please let me know.
year so I tend to be skeptical at my ability to come up with
suggestions that would enhance the language. So before I go through
any process to make any official request I'd like to get some feedback
here on a few ideas that I've felt would improve the VHDL experience.
1. 'SCOPE' or 'CONTEXT' - a keyword to define a scope. An example
usage follows:
CountDown : CONTEXT
VARIABLE Counter : UNSIGNED( 15 DOWNTO 0 ) :=
x"FFFF";
BEGIN
Counter := Counter - 1;
END CONTEXT CountDown;
Counter := Counter - 1; -- Error: Counter is not
defined here.
This is a trivial example, but the idea is as follows. Many variables
are used only a few times and in a small section. By having the
variable declaration close to where it's used it makes the code more
readable as the programmer does not need to search through the file
for the definition. Originally the idea was to simply allow the BEGIN
keyword to be used in IF statements, but the syntax would be very odd
with respect to how it would look if you used ELSE statements. This is
broader. I would suggest CONTEXT be allowed both within a process body
and outside of it for the benefit of concurrent statements. This
models one of the uses of the curly brackets in C++.
2. Often times signals are used only within a single process because
the semantics are ideal if you don't want changes to take effect until
the next clock cycle. For example, all of my state machines, even if
they're only defined within a process, are signals. Similar to the
above reasoning of keeping variable declarations close to where
they're used, I'd like to see the SIGNAL keyword be legal to use
wherever you can use VARIABLE. I realize simulators require more CPU
resources to simulate signals than variables and so some people try to
discourage their use, but for those of us who use them often I feel
this would help readability.
3. This is less well thought out than the two above and comes more in
the shape of a problem than a solution. VHDL's ability for static
elaboration is amazing in comparison to many other languages (i.e. C+
+). However, consider the following type. Imagine that I wanted to
implement a LFSR that cycles every N increments. Can this be coded in
VHDL 2008? I.E., can I have something like the following:
TYPE lfsr5 IS lfsr( period => 5 );
....
VARIABLE state : lfsr5 := lfsr5'POS(0);
....
CASE state IS
WHEN lfsr5'POS(0) => ...
WHEN lfsr5'POS(1) => ...
...
WHEN lfsr5'POS(4) => ...
END CASE;
state := state + 1;
I don't see how to do anything quite like that at the moment. The
values of POS(0) through POS(1) for an LFSR depend on the period so
they would need to be generated during elaboration. I wouldn't mind a
custom attribute other than POS to be used, I just don't see how to do
this as a generic variable. If I'm mistaken please let me know.