skip to main content
research-article
Open access

Loop Rerolling for Hardware Decompilation

Published: 06 June 2023 Publication History

Abstract

We introduce the new problem of hardware decompilation. Analogous to software decompilation, hardware decompilation is about analyzing a low-level artifact—in this case a netlist, i.e., a graph of wires and logical gates representing a digital circuit—in order to recover higher-level programming abstractions, and using those abstractions to generate code written in a hardware description language (HDL). The overall problem of hardware decompilation requires a number of pieces. In this paper we focus on one specific piece of the puzzle: a technique we call hardware loop rerolling. Hardware loop rerolling leverages clone detection and program synthesis techniques to identify repeated logic in netlists (such as would be synthesized from loops in the original HDL code) and reroll them into syntactic loops in the recovered HDL code. We evaluate hardware loop rerolling for hardware decompilation over a set of hardware design benchmarks written in the PyRTL HDL and industry standard SystemVerilog. Our implementation identifies and rerolls loops in 52 out of 53 of the netlists in our benchmark suite, and we show three examples of how hardware decompilation can provide concrete benefits: transpilation between HDLs, faster simulation times over netlists (with mean speedup of 6x), and artifact compaction (39% smaller on average).

References

[1]
Armaiti Ardeshiricham, Yoshiki Takashima, Sicun Gao, and Ryan Kastner. 2019. VeriSketch: Synthesizing Secure Hardware Designs with Timing-Sensitive Information Flow Properties. In Proceedings of the 2019 ACM SIGSAC Conference on Computer and Communications Security (CCS ’19). Association for Computing Machinery, New York, NY, USA. 1623–1638. isbn:9781450367479 https://doi.org/10.1145/3319535.3354246
[2]
B. Baker. 1995. On finding duplication and near-duplication in large software systems. Proceedings of 2nd Working Conference on Reverse Engineering, 86–95. https://doi.org/10.1109/WCRE.1995.514697
[3]
Scott Beamer. 2020. A Case for Accelerating Software RTL Simulation. IEEE Micro, 40, 4 (2020), 112–119. https://doi.org/10.1109/MM.2020.2997639
[4]
A. Becker, D. Novo, and P. Ienne. 2014. SKETCHILOG: Sketching combinational circuits. In 2014 Design, Automation Test in Europe Conference Exhibition (DATE). 1–4. https://doi.org/10.7873/DATE.2014.165
[5]
UC Berkeley. 1992. Berkeley logic interchange format (BLIF). Oct Tools Distribution, 2 (1992), 197–247.
[6]
Per Bjesse, Koen Claessen, Mary Sheeran, and Satnam Singh. 1998. Lava: Hardware Design in Haskell. SIGPLAN Not., 34, 1 (1998), Sept., 174–184. issn:0362-1340 https://doi.org/10.1145/291251.289440
[7]
James Bornholt and Emina Torlak. 2018. Finding Code That Explodes under Symbolic Evaluation. Proc. ACM Program. Lang., 2, OOPSLA (2018), Article 149, Oct., 26 pages. https://doi.org/10.1145/3276519
[8]
Burcin Cakir and Sharad Malik. 2018. Reverse Engineering Digital ICs through Geometric Embedding of Circuit Graphs. ACM Trans. Des. Autom. Electron. Syst., 23, 4 (2018), Article 50, July, 19 pages. issn:1084-4309 https://doi.org/10.1145/3193121
[9]
J. Clow, G. Tzimpragos, D. Dangwal, S. Guo, J. McMahan, and T. Sherwood. 2017. A pythonic approach for rapid hardware prototyping and instrumentation. In 2017 27th International Conference on Field Programmable Logic and Applications (FPL). 1–7. https://doi.org/10.23919/FPL.2017.8056860
[10]
Malay K. Ganai and Andreas Kuehlmann. 2000. On-the-Fly Compression of Logical Circuits. In International Workshop on Logic Synthesis. 7 pages.
[11]
A. Gascón, P. Subramanyan, B. Dutertre, A. Tiwari, D. Jovanović, and S. Malik. 2014. Template-based circuit understanding. In 2014 Formal Methods in Computer-Aided Design (FMCAD). 83–90. https://doi.org/10.1109/FMCAD.2014.6987599
[12]
Tianao Ge, Zewei Mo, Kan Wu, Xianwei Zhang, and Yutong Lu. 2022. RollBin: Reducing Code-Size via Loop Rerolling at Binary Level. In Proceedings of the 23rd ACM SIGPLAN/SIGBED International Conference on Languages, Compilers, and Tools for Embedded Systems (LCTES 2022). Association for Computing Machinery, New York, NY, USA. 99–110. isbn:9781450392662 https://doi.org/10.1145/3519941.3535072
[13]
Andy Gill, Tristan Bull, Garrin Kimmell, Erik Perrins, Ed Komp, and Brett Werling. 2010. Introducing Kansas Lava. In Implementation and Application of Functional Languages, Marco T. Morazán and Sven-Bodo Scholz (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg. 18–35. isbn:978-3-642-16478-1 https://doi.org/10.1007/978-3-642-16478-1_2
[14]
Erh-Wen Hu, Bogong Su, and Jian Wang. 2016. Instruction Level Loop De-optimization. In Computer and Information Science 2015, Roger Lee (Ed.). Springer International Publishing, Cham. 221–234. isbn:978-3-319-23467-0 https://doi.org/10.1007/978-3-319-23467-0_15
[15]
A. Izraelevitz, J. Koenig, P. Li, R. Lin, A. Wang, A. Magyar, D. Kim, C. Schmidt, C. Markley, J. Lawson, and J. Bachrach. 2017. Reusability is FIRRTL ground: Hardware construction languages, compiler frameworks, and transformations. In 2017 IEEE/ACM International Conference on Computer-Aided Design (ICCAD). 209–216. issn:1558-2434 https://doi.org/10.1109/ICCAD.2017.8203780
[16]
T. Kamiya, S. Kusumoto, and K. Inoue. 2002. CCFinder: a multilinguistic token-based code clone detection system for large scale source code. IEEE Transactions on Software Engineering, 28, 7 (2002), 654–670. https://doi.org/10.1109/TSE.2002.1019480
[17]
Toru Kasai, Gunho Lee, Hiroki Arimura, Setsuo Arikawa, and Kunsoo Park. 2001. Linear-Time Longest-Common-Prefix Computation in Suffix Arrays and Its Applications. In Combinatorial Pattern Matching, Amihood Amir (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg. 181–192. isbn:978-3-540-48194-2 https://doi.org/10.1007/3-540-48194-X_17
[18]
W. Li, A. Gascon, P. Subramanyan, W. Y. Tan, A. Tiwari, S. Malik, N. Shankar, and S. A. Seshia. 2013. WordRev: Finding word-level structures in a sea of bit-level gates. In 2013 IEEE International Symposium on Hardware-Oriented Security and Trust (HOST). 67–74. https://doi.org/10.1109/HST.2013.6581568
[19]
W. Li, Z. Wasson, and S. A. Seshia. 2012. Reverse engineering circuits using behavioral pattern mining. In 2012 IEEE International Symposium on Hardware-Oriented Security and Trust. 83–88. https://doi.org/10.1109/HST.2012.6224325
[20]
T. Meade, Y. Jin, M. Tehranipoor, and S. Zhang. 2016. Gate-level netlist reverse engineering for hardware security: Control logic register identification. In 2016 IEEE International Symposium on Circuits and Systems (ISCAS). 1334–1337. https://doi.org/10.1109/ISCAS.2016.7527495
[21]
T. Meade, S. Zhang, and Y. Jin. 2016. Netlist reverse engineering for high-level functionality reconstruction. In 2016 21st Asia and South Pacific Design Automation Conference (ASP-DAC). 655–660. https://doi.org/10.1109/ASPDAC.2016.7428086
[22]
Alan Mycroft and Richard Sharp. 2003. Higher-level techniques for hardware description and synthesis. International Journal on Software Tools for Technology Transfer, 4, 3 (2003), 271–297. https://doi.org/10.1007/s10009-002-0086-1
[23]
Chandrakana Nandi, Max Willsey, Adam Anderson, James R. Wilcox, Eva Darulova, Dan Grossman, and Zachary Tatlock. 2020. Synthesizing Structured CAD Models with Equality Saturation and Inverse Transformations. In Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2020). Association for Computing Machinery, New York, NY, USA. 31–44. isbn:9781450376136 https://doi.org/10.1145/3385412.3386012
[24]
J.T. O’Donnell. 2006. Overview of Hydra: a concurrent language for synchronous digital circuit design. International Journal of Information, 9, 2 (2006), March, 249–264. http://eprints.gla.ac.uk/3461/
[25]
J. Portillo, T. Meade, J. Hacker, S. Zhang, and Y. Jin. 2019. RERTL: Finite State Transducer Logic Recovery at Register Transfer Level. In 2019 Asian Hardware Oriented Security and Trust Symposium (AsianHOST). 1–6. https://doi.org/10.1109/AsianHOST47458.2019.9006699
[26]
Rodrigo C. O. Rocha, Pavlos Petoumenos, Björn Franke, Pramod Bhatotia, and Michael O’Boyle. 2022. Loop Rolling for Code Size Reduction. In 2022 IEEE/ACM International Symposium on Code Generation and Optimization (CGO). 217–229. https://doi.org/10.1109/CGO53902.2022.9741256
[27]
N. Rubanov. 2006. A High-Performance Subcircuit Recognition Method Based on the Nonlinear Graph Optimization. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, 25, 11 (2006), 2353–2363. https://doi.org/10.1109/TCAD.2006.881335
[28]
Y. Shi, C. W. Ting, B. Gwee, and Y. Ren. 2010. A highly efficient method for extracting FSMs from flattened gate-level netlist. In Proceedings of 2010 IEEE International Symposium on Circuits and Systems. 2610–2613. https://doi.org/10.1109/ISCAS.2010.5537093
[29]
Zachary D. Sisco, Jonathan Balkind, Timothy Sherwood, and Ben Hardekopf. 2023. Loop Rerolling For Hardware Decompilation artifact. https://doi.org/10.5281/zenodo.7823993
[30]
Wilson Snyder. 2021. Verilator. https://www.veripool.org/verilator/
[31]
M. Soeken, B. Sterin, R. Drechsler, and R. Brayton. 2015. Simulation graphs for reverse engineering. In 2015 Formal Methods in Computer-Aided Design (FMCAD). 152–159. https://doi.org/10.1109/FMCAD.2015.7542265
[32]
Armando Solar-Lezama. 2013. Program sketching. International Journal on Software Tools for Technology Transfer, 15, 5 (2013), 475–495. https://doi.org/10.1007/s10009-012-0249-7
[33]
Armando Solar-Lezama, Liviu Tancau, Rastislav Bodik, Sanjit Seshia, and Vijay Saraswat. 2006. Combinatorial Sketching for Finite Programs. In Proceedings of the 12th International Conference on Architectural Support for Programming Languages and Operating Systems (ASPLOS XII). Association for Computing Machinery, New York, NY, USA. 404–415. isbn:1595934510 https://doi.org/10.1145/1168857.1168907
[34]
G. Stiff and F. Vahid. 2005. New Decompilation Techniques for Binary-Level Co-Processor Generation. In Proceedings of the 2005 IEEE/ACM International Conference on Computer-Aided Design (ICCAD ’05). IEEE Computer Society, USA. 547–554. isbn:078039254X https://doi.org/10.1109/ICCAD.2005.1560127
[35]
Jens Stoye and Dan Gusfield. 2002. Simple and flexible detection of contiguous repeats using a suffix tree. Theoretical Computer Science, 270, 1 (2002), 843–856. issn:0304-3975 https://doi.org/10.1016/S0304-3975(01)00121-9
[36]
Bogong Su, Shiyuan Ding, and Lan Jin. 1984. An Improvement of Trace Scheduling for Global Microcode Compaction. In Proceedings of the 17th Annual Workshop on Microprogramming (MICRO 17). IEEE Press, 78–85. https://doi.org/10.1145/800016.808217
[37]
B. Su, S. Ding, and J. Xia. 1986. URPR—An Extension of URCR for Software Pipelining. In Proceedings of the 19th Annual Workshop on Microprogramming (MICRO 19). Association for Computing Machinery, New York, NY, USA. 94–103. isbn:081860736X https://doi.org/10.1145/19551.19541
[38]
P. Subramanyan, N. Tsiskaridze, W. Li, A. Gascon, W. Tan, A. Tiwari, N. Shankar, S. A. Seshia, and S. Malik. 2014. Reverse Engineering Digital Circuits Using Structural and Functional Analyses. IEEE Transactions on Emerging Topics in Computing, 2, 01 (2014), jan, 63–80. issn:2168-6750 https://doi.org/10.1109/TETC.2013.2294918
[39]
Lingshu Tang and Scott Davidson. 2019. BSG Micro Designs. https://github.com/bsg-idea/bsg_micro_designs
[40]
Michael Bedford Taylor. 2018. BaseJump STL: SystemVerilog Needs a Standard Template Library for Hardware Design. In Proceedings of the 55th Annual Design Automation Conference (DAC ’18). Association for Computing Machinery, New York, NY, USA. Article 73, 6 pages. isbn:9781450357005 https://doi.org/10.1145/3195970.3199848
[41]
Emina Torlak and Rastislav Bodik. 2014. A Lightweight Symbolic Virtual Machine for Solver-Aided Host Languages. SIGPLAN Not., 49, 6 (2014), June, 530–541. issn:0362-1340 https://doi.org/10.1145/2666356.2594340
[42]
Max Willsey, Chandrakana Nandi, Yisu Remy Wang, Oliver Flatt, Zachary Tatlock, and Pavel Panchekha. 2021. egg: Fast and Extensible Equality Saturation. Proc. ACM Program. Lang., 5, POPL (2021), Article 23, Jan., 29 pages. https://doi.org/10.1145/3434304
[43]
Claire Wolf. 2021. Yosys Open SYnthesis Suite. http://www.clifford.at/yosys/
[44]
T. Zhang, J. Wang, S. Guo, and Z. Chen. 2019. A Comprehensive FPGA Reverse Engineering Tool-Chain: From Bitstream to RTL Code. IEEE Access, 7 (2019), 38379–38389. https://doi.org/10.1109/ACCESS.2019.2901949

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image Proceedings of the ACM on Programming Languages
Proceedings of the ACM on Programming Languages  Volume 7, Issue PLDI
June 2023
2020 pages
EISSN:2475-1421
DOI:10.1145/3554310
Issue’s Table of Contents
Permission to make digital or hard copies of part or all of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for third-party components of this work must be honored. For all other uses, contact the Owner/Author.

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 06 June 2023
Published in PACMPL Volume 7, Issue PLDI

Permissions

Request permissions for this article.

Check for updates

Badges

Author Tags

  1. hardware decompilation
  2. loop rerolling
  3. program synthesis

Qualifiers

  • Research-article

Funding Sources

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)429
  • Downloads (Last 6 weeks)64
Reflects downloads up to 01 Jan 2025

Other Metrics

Citations

Cited By

View all

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Login options

Full Access

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media