SourceRange Information question #819
Practical-UVM-Step-By-Step
started this conversation in
General
Replies: 1 comment
-
Sure, if you have a SyntaxNode (for example, a ModuleDeclarationSyntax which is what also represents interface declarations) you can call sourceRange() on it to get a source range. This tells you the start and end points of the declaration. You can get line number information from the locations using the SourceManager. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Mike:
I cannot say this enough. Wonderful library. I have learnt a lot from just perusing your code.
Is there a way to use SourceRange to get information on ranges of lines of SystemvVerilog sources from the Parser if we were to use something like the rewriter application for instance.
I'm looking to apply more extensive refactoring to some sources. Was hoping to make some detection.. (maybe delete some functions, or alter some contents inside them etc).
For example Consider this snippet
1
2 interface wb_slave_if (input bit clk, input bit rst);
3
4 // ToDo: Define default setup & hold times
5
6 parameter setup_time = 5/ns/;
7 parameter hold_time = 3/ns/;
8
9 ,,,
10 ,,,
11
12
13 clocking slave_cb @(posedge clk);
14 default input #setup_time output #hold_time;
15
16 // Common Signals
17 input CYC_I;
18 ...
19 ...
20 endclocking: slave_cb
21
22 endinterface: wb_slave_if
23
24
include "wb_master_if.sv" 25 26 class wb_master_callbacks extends uvm_callback; 27 28 // Called before a transaction is executed 29 virtual task pre_tx( wb_master xactor, wb_transaction tr); 30
uvm_info("WB_MASTER_CALLBACKS"," This is in the pre-callback phase",UVM_LOW)31 endtask: pre_tx
32
33
34 // Called after a transaction has been executed
35 virtual task post_tx( wb_master xactor, wb_transaction tr);
36 endtask: post_tx
37 endclass: wb_master_callbacks
38
39 class wb_master extends uvm_driver # (wb_transaction);
40
41 wb_config mstr_drv_cfg;
42
43 typedef virtual wb_master_if v_if;
44 v_if drv_if;
45
uvm_register_cb(wb_master,wb_master_callbacks); 46 47 extern function new(string name = "wb_master", 48 uvm_component parent = null); 49 50
uvm_component_utils_begin(wb_master)51 `uvm_component_utils_end
52
53 endclass: wb_master
54
55
56 function wb_master::new(string name = "wb_master",
57 uvm_component parent = null);
58 super.new(name, parent);
59 endfunction: new
60
MY question:
is there a way to get the source range
for wb_slave_if it would be lines 2-22 for the interface,
for wb_master_callbacks class it would be lines 26-37
for wb_master class it would be lines 39-53
and for the function wb_master::new it would be lines 56-59
I wasnt sure if the SourceRange class that you had in the sources would have this information populated by the parser.
Could you let me know if this is indeed the case, and any suggestive code snippet showing would be super useful.
I couldnt find any usage of this in in your tests directory, hence asking.
Thank you,
Beta Was this translation helpful? Give feedback.
All reactions