SPICE Backend

SPICE stands for Simulating Program with Integrated Circuit Emphasis. Essentially a program for simulation of electrical circuits. We will look at a very small spice backend, written in C. The project was part of CAD Lab assignment for electrical engineering students.
Since there will be many equations, i have compiled the document into a PDF using LYX, the document processor. But i will briefly explain about the project.

Circuit simulation, is an easy task, till there are only few nodes. However, as the nodes and elements increase, the complexity increases exponentially. To ease our task and solve the repetitive process of solving equations, we write a simple program.

Our job, as the end user is very simple:
1. Write a net list, containing all the information about the circuit. Please note that, you need to draw the circuit on paper, label the nodes and write the net list accordingly.
2. Invoke the program.

Simple isnt it?

Now let us look from the programmer’s perspective:
1. Read the netlist. Convert all the data into numericals and node names. Scan for all errors
2. Create the circuit as a set of structure elements.
3. Create a matrix to solve the simultaneous linear equations
4. Write the output to file

The first step is a little difficult among all of them. Parsing a file in C with numericals, especially with muultipliers like nano, pico, micro etc is not trivial.

Once done, we use linked lists to store the information about the elements, the nodes to which it is attached, the values, the dependencies if any etc. Once this is done, we traverse the linked list again to fit all the values into a neat matrix. Solving this matrix will give back all the node voltages.

Download the following file to read about the spice backend.


A few things i wanted to add:

1. The elements as plugins to the program, so that it is possible to add new elements

2. Better matrix inversion algorithms

3. A GUI frontend

In case you want the code, please drop a comment with your mail ID, so that i can mail it to you.


Put lift da!!

A very general comment our friends in IITM will know. Yes, i am talking about the cycles. Today morning, i was riding my cycle and i thought i should write an article on it. The cycles here, are not any other random vehicles to be neglected. They are the Benz for the lazy, rocket for the lazier and useless for the laziest. What the hell? does it make any sense at all?

Let me go ahead and explain. First things first, there is no person who doesn’t fall into the above three categories. So, people who are just lazy, will generally start a little early and slowly wile away their time on the cycle. The lazier, who don’t want to repair their punctured or tattered or whatever cycle, they wait for lift, hop on to the cycle and zoom past the roads. The laziest, will not even care to repair it once it goes out of condition. So, it is obvious it is of no use for them anymore.

But our focus is on the cycles, not on the riders. I am not sure if any enthusiastic biker has traveled more than us on our cycles. For every random reason, we take our cycle out. Go 200 meter away, get your cycle. Go 50KM away, get your cycle. Cycle is like the universal mode of transport here. I am unable to imagine life here without cycles. Life looks very energetic with all the cycles here.

We here, are also very proud of our cycles. We dont pollute our environment, it is a good exercise for us, and above that, a savior during the exams(we make promises to ourselves that we will wake up early during exams, but as expected, we dont wake up early, since we dont sleep early).

I personally feel like a racer when i ride my cycle, especially when i zap across a slow cycler or across an old(but the best and the sturdiest) cycle. I am quite generous also, i keep taking lift from people. You heard it right. I provide the lift, convince them that they are heavier than me and hence they need to ride the cycle and i get the lift on my own cycle. Fun isnt it? But there is also a trade off. I get frequent cycle repairs. Especially, if you buy the cycle in the campus during the start of the semester, you will realize that they are a sort of rotten cycle.

Experience has told me that simplicity is better than anything else. Not that riding cycles is simple enough, but my cycle, hercules fusion looks like a monster, but is a slowpoke. On the other hand, BSA photon, the simplest of all cycles looks like a lean, dead lizard, but flies across the road. I guess i need to get away with my cycle for another 2 years here, unless someone decides to keep it for themselves.

All in all, one sentence, cycle away with your cycle.