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
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