vdiff a program differencing algorithm for verilog hdl
play

Vdiff: A Program Differencing Algorithm for Verilog HDL Adam Duley - PowerPoint PPT Presentation

Vdiff: A Program Differencing Algorithm for Verilog HDL Adam Duley Christopher Spandikow Miryung Kim ARM Inc IBM Corporation The University of Texas at Austin Problem: Limitations of using diff on evolving hardware designs assumes sequential


  1. Vdiff: A Program Differencing Algorithm for Verilog HDL Adam Duley Christopher Spandikow Miryung Kim ARM Inc IBM Corporation The University of Texas at Austin

  2. Problem: Limitations of using diff on evolving hardware designs • assumes sequential execution semantics • relies on code elements having unique names • does not leverage Boolean expression equivalence checking despite the availability of SAT solvers

  3. Solution: Vdiff • a position-independent differencing algorithm with intimate knowledge of Verilog semantics • 96.8% precision with 97.3% recall compared to manually classified differences • produces syntactic differencing results in terms of Verilog-specific change types

  4. Outline • Motivation • Verilog Background • Vdiff Algorithm • Evaluation • Conclusions

  5. Motivation • hardware designers collaboratively evolve large Verilog programs • hard to use diff -like tools during code reviews • develop a foundation for reasoning about evolving hardware design descriptions

  6. Verilog HDL Background include "uart_defines.v ” module uart_rfifo (clk, reset, data_out); input clk, reset; output [fifo_width-1:0] data_out; reg [fifo_counter_w-1:0] fifo; wire [fifo_pointer_w-1:0] overrun; always @(posedge clk or posedge reset) begin if(reset) begin fifo[1] <= 0; fifo[0] <= 0; end end assign data_out = fifo[0]; endmodule

  7. Verilog HDL Background include "uart_defines.v ” module uart_rfifo (clk, reset, data_out); input clk, reset; output [fifo_width-1:0] data_out; reg [fifo_counter_w-1:0] fifo; wire [fifo_pointer_w-1:0] overrun; Modules are building blocks with always @(posedge clk or posedge reset) an explicit input and output port interface. begin if(reset) A module is similar to a Java class. begin fifo[1] <= 0; fifo[0] <= 0; end end assign data_out = fifo[0]; endmodule

  8. Verilog HDL Background include "uart_defines.v“ module uart_rfifo (clk, reset, data_out); input clk, reset; output [fifo_width-1:0] data_out; reg [fifo_counter_w-1:0] fifo; wire [fifo_pointer_w-1:0] overrun; always @(posedge clk or posedge reset) Input and output ports are public interfaces that begin connect modules to external hierarchy. if(reset) begin fifo[1] <= 0; They are similar to a constructor ʼ s parameter list in Java. fifo[0] <= 0; end end assign data_out = fifo[0]; endmodule

  9. Verilog HDL Background include "uart_defines.v“ module uart_rfifo (clk, reset, data_out); input clk, reset; output [fifo_width-1:0] data_out; reg [fifo_counter_w-1:0] fifo; wire [fifo_pointer_w-1:0] overrun; always @(posedge clk or posedge reset) begin if(reset) begin fifo[1] <= 0; Wires, registers, & integers are variable declarations. fifo[0] <= 0; end end assign data_out = fifo[0]; endmodule

  10. Verilog HDL Background include "uart_defines.v“ module uart_rfifo (clk, reset, data_out); always blocks are similar to Java methods. input clk, reset; However, they execute concurrently output [fifo_width-1:0] data_out; when the sensitivity list is true. reg [fifo_counter_w-1:0] fifo; wire [fifo_pointer_w-1:0] overrun; always @(posedge clk or posedge reset) begin if(reset) begin fifo[1] <= 0; fifo[0] <= 0; end end // always assign data_out = fifo[0]; endmodule

  11. Verilog HDL Background include "uart_defines.v“ module uart_rfifo (clk, reset, data_out); input clk, reset; output [fifo_width-1:0] data_out; reg [fifo_counter_w-1:0] fifo; wire [fifo_pointer_w-1:0] overrun; always @(posedge clk or posedge reset) begin if(reset) begin fifo[1] <= 0; fifo[0] <= 0; Assign statements model concurrent dataflow. end end // always assign data_out = fifo[0]; endmodule

  12. Verilog HDL Background include "uart_defines.v“ module uart_rfifo (clk, reset, data_out); input clk, reset; Blocking statements are sequential assignments. output [fifo_width-1:0] data_out; reg [fifo_counter_w-1:0] fifo; wire [fifo_pointer_w-1:0] overrun; always @(posedge clk or posedge reset) begin if(reset) begin fifo[1] = 0; fifo[0] = 0; end end assign data_out = fifo; endmodule

  13. Verilog HDL Background include "uart_defines.v“ module uart_rfifo (clk, reset, data_out); input clk, reset; Non-blocking statements are concurrent assignments, output [fifo_width-1:0] data_out; and they are prevalent in Verilog designs. reg [fifo_counter_w-1:0] fifo; wire [fifo_pointer_w-1:0] overrun; always @(posedge clk or posedge reset) begin if(reset) begin fifo[1] <= 0; fifo[0] <= 0; end end assign data_out = fifo; endmodule

  14. Diff Results + always @(posedge clk) always @(posedge clk) + begin begin + if (reset) if(reset) + overrun <= 0; begin + end fifo[1] <= 0; always @(posedge clk) - fifo[0] <= 0; begin end if(reset) end // always begin - always @(posedge clk ) + fifo[0] <= 0; -begin fifo[1] <= 0; - if (reset) + fifo[2] <= 0; - overrun <= 0; end - end // always end // always Verilog ʼ s non-unique identifiers and concurrent semantics cause assign data_out = fifo[0]; assign data_out = fifo[0]; diff to identify a large amount of false positives.

  15. Outline • Motivation • Verilog Background • Vdiff Algorithm • Evaluation • Conclusions

  16. Algorithm • input: two versions of a Verilog file • output: syntactic differences in terms of change types 1. extract Abstract Syntax Tree (AST) from each file 2. compare the two trees 3. filter false positives in changes to sensitivity lists using a SAT solver 4. categorize differences based on Verilog syntax

  17. Extract AST module uart_rfifo (clk, reset, data_out, overrun); always @(posedge clk) module begin if(reset) begin always always fifo[1] <= 0; (run) (fifo) fifo[0] <= 0; assign end end // always if if always @(posedge clk) begin if (reset) overrun <= 0; <= <= <= end // always fifo[0] fifo[1] overrun assign data_out = fifo[0]; endmodule

  18. Tree Differencing Algorithm • hierarchically compare tree nodes from the top down • initially align nodes using the longest common subsequence (LCS) algorithm—unmatched nodes are split into ADD and DELETE sets • for each pair in ADD x DELETE, calculate the textual similarity • use greedy weighted bipartite graph matching to associate a DELETE node to a corresponding ADD node

  19. Tree Comparison ? uart_rfifo.v rev 87 uart_rfifo.v rev 88 module module always always always always (run) (fifo) (run) (fifo) assign assign if if if if <= <= fifo[2] <= <= <= <= fifo[0] <= fifo[1] fifo[0] overrun overrun fifo[1]

  20. mapped Tree Comparison LCS uart_rfifo.v rev 87 uart_rfifo.v rev 88 Match module module add always always always always delete (fifo) (run) (run) (fifo) assign assign if if if if <= <= fifo[2] <= <= <= <= fifo[0] <= fifo[1] fifo[0] overrun overrun fifo[1]

  21. Tree Comparison uart_rfifo.v rev 87 uart_rfifo.v rev 88 ? module module always always always always (fifo) (run) (run) (fifo) assign assign if if if if <= <= fifo[2] <= <= <= <= fifo[0] <= fifo[1] fifo[0] overrun overrun fifo[1]

  22. Tree Comparison uart_rfifo.v rev 87 uart_rfifo.v rev 88 ? module module always always always always (fifo) (run) (run) (fifo) assign assign if if if if <= <= fifo[2] <= <= <= <= fifo[0] <= fifo[1] fifo[0] overrun overrun fifo[1]

  23. Tree Comparison uart_rfifo.v rev 87 uart_rfifo.v rev 88 module module ? always always always always (fifo) (run) (run) (fifo) assign assign if if if if <= <= fifo[2] <= <= <= <= fifo[0] <= fifo[1] fifo[0] overrun overrun fifo[1]

  24. Tree Comparison uart_rfifo.v rev 87 uart_rfifo.v rev 88 module module ? always always always always (fifo) (run) (run) (fifo) assign assign if if if if <= <= fifo[2] <= <= <= <= fifo[0] <= fifo[1] fifo[0] overrun overrun fifo[1]

  25. mapped Tree Comparison LCS uart_rfifo.v rev 87 uart_rfifo.v rev 88 Match module module add always always always always delete (fifo) (run) (run) (fifo) assign assign if if if if <= <= fifo[2] <= <= <= <= fifo[0] <= fifo[1] fifo[0] overrun overrun fifo[1]

  26. mapped Tree Comparison LCS uart_rfifo.v rev 87 uart_rfifo.v rev 88 Match module module add always always always always delete (fifo) (run) (run) (fifo) assign assign if if if if <= <= fifo[2] <= <= <= <= fifo[0] <= fifo[1] fifo[0] overrun overrun fifo[1]

  27. Tree Comparison uart_rfifo.v rev 87 uart_rfifo.v rev 88 module module always always always always (fifo) (run) (run) (fifo) assign assign ? if if if if <= <= fifo[2] <= <= <= <= fifo[0] <= fifo[1] fifo[0] overrun overrun fifo[1]

  28. Tree Comparison uart_rfifo.v rev 87 uart_rfifo.v rev 88 module module always always always always (fifo) (run) (run) (fifo) ? assign assign if if if if <= <= fifo[2] <= <= <= <= fifo[0] <= fifo[1] fifo[0] overrun overrun fifo[1]

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend