> >Just curious, what was the original motivation behind this enum range syntax?
> How is it considered useful to generate a bunch of enum names like n_1, n_2,
> ..., n_10 automatically?
>
> Others like Dave obviously know more about the origin of this.
>
> I can imagine that it might be useful for certain state machines that
> have a sequence of states for counting something. And the next-state
> logic might be similarly compact if all these states could be lumped
> together and use the next() method to get to the next state. But you
> couldn't easily assign specific values to the states, such as one-hot
> values.
I don't see enum ranges as particularly useful in the fsm example, since
a side counter is typically implemented to track #cycles to stay in a
certain state.
On the other hand, I've used enum ranges to implement addresses of
register sets in RTL. e.g.:
package asic_regmap_pkg;
parameter bit [31:0] ASIC_IO_START = 32'h2000_0000;
parameter bit [31:0] BLK1_BASE = ASIC_IO_START;
parameter bit [31:0] BLK2_BASE = ASIC_IO_START + 'h100;
// hard-coded constants in the h/w
parameter max_colours = 4;
parmaeter max_levels = 6;
endpackage
package blk1_regmap_pkg;
import asic_regmap_pkg::*;
typedef enum bit [31:0] {
blk1_a_register = BLK1_BASE,
blk1_another_register,
blk1_reg_addr_offset1_[max_colours], // (a)
blk1_reg_addr_offset2_[max_colours*max_levels] // (b)
} blk1_reg_addrmap;
endpackage
This is, unfortunately, unambiguously illegal, making the construct
difficult to use. Consider the workarounds:
`define MAX_COLOURS 4
`define MAX_LEVELS 6
(c) blk1_reg_addr_offset1_[4] // legal
(d) blk1_reg_addr_offset1_[`MAX_COLOURS] // legal
(e) blk1_reg_addr_offset2_[`MAX_COLOURS*`MAX_LEVELS] // not legal
(f) blk1_reg_addr_offset2_[4*6] // not legal
Since we're on the subject of enum ranges, I propose that we consider
making, at minimum, (e) and (f) legal. The question of allowing (a)
or (b) came up a long time ago, though I did not follow the discussion.
See http://www.eda-stds.org/sv-bc/hm/1354.html. Would the fact that
the parameters (aka constants) are in a package help? Would making
these localparams also help?
As one can see in the example above, restricting the range to be
an integral_number makes the construct so much less useful.
kaiming
-- Kaiming Ho Fraunhofer-Institut für Integrierte Schaltungen IIS Am Wolfsmantel 33 91058 Erlangen -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Thu Mar 25 03:05:34 2010
This archive was generated by hypermail 2.1.8 : Thu Mar 25 2010 - 03:05:55 PDT