EdaphicStudio / SystemVerilog

Public issue tracker for Edaphic.Studio/SV
MIT License
0 stars 0 forks source link

Attribute instance"edaphic_include" doesn't resolve defines #16

Closed EdaphicStudio closed 5 years ago

EdaphicStudio commented 5 years ago

Edaphic Studio currently doesn't support global defines provided at the build step (we need an updated build structure for that). As a workaround, we provide an attribute_instance rule (* edaphic_include = "file.svh" *) that can be inserted in files. Edaphic Studio will parse file.svh and use it as another include file. Since this file would only be read by our tool it can be used to defines global defines etc. without affecting real builds.

There is currently a bug with this model where the lower level Compiler Directives doesn't look for this rule while higher level functions (like CTRL-B: Go to definition) does.

The intent of the following example is for SIMULATION to be defined as 1 inside the testbench.sv file. This is not happening so leaves the line module simulation; endmodule commented out.

This will be fixed in the next release.

edaphic_global_defines.svh

`define SIMULATION 1

parameter WIDTH = 32;

testbench.sv


(* edaphic_include = "edaphic_global_defines.svh" *)

//NOTE! Define SIMULATION resolves (CTRL-B) to edaphic_global_defines.svh
//      BUT underlying pre-compiler logic doesn't resolve it resulting in
//      module simulation; endmodule being commented out. This is a bug
`ifdef SIMULATION
    // THIS LINE IS INCORRECTLY COMMENTED OUT IN EDAPHIC STUDIO
    module simulation; endmodule
`endif

module testbench ();

    reg [WIDTH-1:0] foo;
         //^ Resolves to edaphic_global_defines.svh as expected

    simulation sim_inst ();
    //^ BUG: Should resolve to simulation above

endmodule
EdaphicStudio commented 5 years ago

Modified use model to instead allow for a magic global define called edaphic

So the following code works in BETA9

edaphic_global_defines.svh

`define SIMULATION 1

parameter WIDTH = 32;

testbench.sv

`ifdef edaphic
`include "edaphic_global_defines.svh"
`endif

//NOTE! Define SIMULATION resolves (CTRL-B) to edaphic_global_defines.svh
//      BUT underlying pre-compiler logic doesn't resolve it resulting in
//      module simulation; endmodule being commented out. This is a bug
`ifdef SIMULATION
    // THIS LINE IS INCORRECTLY COMMENTED OUT
    module simulation; endmodule
`endif

module testbench ();

    reg [WIDTH-1:0] foo;
           //^ Resolves to edaphic_global_defines.svh as expected

    simulation sim_inst ();
    //^ Resolves to module simulation above since SIMULATION is set in "edaphic_global_defines.svh"

endmodule