Python and Circuits: HSPICE Binary File Parsing

Hi everyone, my name is Raphael Gonzalez and I am a rising sophomore with an undeclared major. This summer I’ve been working with Prof Spencer’s ACE lab on a number of projects. Among these projects has been the creation of an HSPICE post1 file parser. HSPICE is a circuit simulator, a program that predicts voltages and currents in a user-specified circuit, and it has notoriously opaque binary output file formats that are collectively referred to as “post1 formats”. This is a problem because understanding output files is important for writing automation scripts or using tools like Matlab for analyzing simulation results. 


Binary file contents as rendered my computer.


I’ve included the figure above to make this problem concrete. It’s a screenshot of the output when we open up a post1 output file as text. This is the computer’s best guess of what the file says (it’s not a very good guess). We can force the computer to show us binary it is trying to decipher by using a tool called a hexdump, and I’ve included a screenshot of a hexdump’s interpretation of a file below.


Binary file contents as seen by the computer in base 16.


Better, but we still need to figure out what this long string of numbers means in terms of Volts, Hz, and seconds. That has required a combination of reading existing, but sparse, documentation, and engaging in reverse engineering, where I make guesses about what the numbers mean and then test them against simulations with known results.  We’ve made really good progress with this, see the figures below!


CSV output file snippet

CSV output file snippet


Matlab.m output file snippet


This is much more readable both to humans and to other applications that can take these more general formats. 


Now I’m putting the finishing touches like flags the user of this can use to customize the output a bit, as well as a second extra program that will need some extra python software but will work well for programmers looking to make their own software. Once all of the software I’m writing is complete, we plan to release a python package, and the tool we wrote, as well as two documents; one that outlines the tool and package, and one that describes the post1 file formats. Ultimately we hope to release a tool that allows people to view their output data with a greater deal of control and provide a single, clear, and comprehensive description of the post1 file format.


Raffa Gonzalez (rcgonzalez@hmc.edu)

Thank you to Prof. Spencer for your help with editing.


Comments