PDA

View Full Version : Problem configuring enum fields



dlong
01-17-2008, 08:29 AM
Hi,

There is an OVM field macro that can be applied to enum members of a class derived from ovm_component, e.g.




`include "ovm.svh"

package my_pkg;
import ovm_pkg::*;

class tb_comp extends ovm_component;
typedef enum {NONE,UP,DOWN} dir_t;

dir_t dir = NONE;

function new(string name="", ovm_component parent=null);
super.new(name,parent);
endfunction : new

`ovm_component_utils_begin(tb_comp)
`ovm_field_enum(dir_t,dir,OVM_ALL_ON)
`ovm_component_utils_end

endclass : tb_comp

endpackage

module top();
import my_pkg::*;
import ovm_pkg::*;

tb_comp c1;

initial
begin
set_config_int("*","dir",tb_comp::UP);
c1 = new("c1",null);
c1.build();
c1.print();
c1.dir = tb_comp::DOWN; c1.print();
end
endmodule // top



This macro generates code to print the enum values but ignores the configuration - the printed values are "NONE" + "DOWN" rather than "UP" + "DOWN".

Replacing the macro with `ovm_field_int(dir,OVM_ALL_ON) enables Incisive to set the "correct" values which it prints as "1"+"2". Questa detects the enumerated variable is being assigned from an integer which it reports as a compiler error.

Note that there is no set_config_enum function in OVM (I don't think there is any need to provide one). I believe the fault is in the implementation of the ovm_field_enum macro.

I like the idea of being able to use enums for testbench configuration so look forward to this being fixed.

Regards,
Dave
================
David Long
Doulos
http://www.doulos.com

jlrose
01-23-2008, 03:12 AM
Hi Dave,

There is a bug in the macro code for enums (it got caught a little too late). Sorry about that. In the 1.0 kit, the pack/unpack and config setting are broken for `ovm_field_enum types.

This will be fixed in the next kit. The fix is easy, it is just a condition in the wrong place. If you are interested in manually fixing your ovm code, the problem is in the file src/macros/ovm_object_defines.svh
859d858
< end \
877a877
> end \

Basically, the PACK/UNPACK/CONFIG stuff was put inside the wrong condition. The end at line 877 needs to be moved up before the pack implementation.

john

dlong
01-23-2008, 03:50 AM
Hi John,

Moving the "end /" from line 858 to 877 does indeed fix the problem!

Thanks for that.

Regards,
Dave

gordon
02-20-2008, 06:22 AM
The 1.0.1 release includes this fix (and also adds pack/unpack support to the more complex field macros). It works as required now.

- Note to developers: this macro (ovm_field_enum) is still missing from the dummy macro defines in the `ifdef OVM_EMPTY_MACROS section. So is ovm_field_sarray_int.

- Note 2. macro ovm_field_aa_string_int is still unimplemented.

hansv
02-20-2008, 07:24 AM
Since we're on the topic, does one of you involved in this thread perhaps have an answer for the thread "array of enum type" about the (absence of) a field enumeration macro for arrays of an enum type.

Thanks