that i use in a module that generates a clock signal as shown below:
"RANDOMCLOCK":begin
gen_CLK_period();
gen_CLK_high();
forever
begin
I.CLKRESET.CLK <= 1;
#(clockgen.high);
I.CLKRESET.CLK <= 0;
#(clockgen.period-clockgen.high);
end
end
"SETCLOCK":begin
set_CLK(I.clock_period, I.clock_high);
forever
begin
I.CLKRESET.CLK <= 1;
#(clockgen.high);
I.CLKRESET.CLK <= 0;
#(clockgen.period-clockgen.high);
end
end
when i compile i got:
Enum literal name 'RANDOM_CLOCK' already exists.
Enum literal name 'FIXED_CLOCK' already exists.
Typedef 'clocktype' multiply defined.
no, i don’t included twice the enumeration
i took advice and i put the enumeration in a package, but now i got a warning
'enums' already exists and will be overwritten.
i declared a package named ‘enums’ and i put the above enumeration in it
It looks to me like your compile filelist issue. My guess - you are passing the same file twice to the compiler - one perhaps via `include and another via command line/-f option etc.
Either show us more/full code or explore your compile script/command.
Show us your intf.sv file - what is data type of “ct”? Is that this “enum type”, if yes, how does that compile? Is it string by any chance? I’m surprised by your case choices being enclosed in “” (double quotes)
And remove the enums.sv from intf.sv file. You will still have the “” issue I mentioned earlier.
I would classify this as error-message enhancement to your vendor - it could have shown the first inclusion of enums.sv to avoid these many typings :-)
This is one of the common issues with SV first tomers - it requires some thought on file inclusion/file list - unlike plain Verilog.
thank you very much, but now i have another problem
in intf.sv when i compile i got: ‘clocktype’ is an unknown type.
it seems that 'include enums.sv above 'include intf.sv does not have effect
It is always good to use ifdef, ifndef directives so that it automatically avoids the double declaration.
ifndef _ENUMS_SV_ define ENUMS_SV
…
…
…
`endif
So whenever next include “enums.sv” will come it will first check “ENUMS_SV” is defined or not if defined it will not compile till associated “`endif”.