Sitemap
A list of all the posts and pages found on the site. For you robots out there, there is an XML version available for digesting as well.
Pages
Posts
42030青春版–一套刚刚好的乐高
Published:
42209 浅浅的评测
Embedded Project: CircuitSim
Published:
A walkthrough of our Embedded final project: Circuit Simulator on FPGA
Demystifying Cache–From Bytes to Tags
Published:
Breaking down cache‐address bits is one of the trickiest parts of PS 6. In this review, we’ll step through in detail how to partition a 32-bit address into different fields. Then we’ll work through a sample address problem and cap things off with a challenge problem to test your knowledge :)
So What Is Carry Look Ahead
Published:
Someone asked me about carry lookahead during OH, and I felt that I didn’t explain it well enough. Here’s a better attempt:
FPGA Button UI
Published:
Embedded lab 1: code an FPGA to test the Collatz Conjecture over a range of numbers… with a user interface of buttons and switches
Coping with Oscilloscope Signals
Published:
A simple method to smoothen DC data. Worked perfectly for gate transfer curves.
AP Does Not Mean APlus
Published:
After the long, long wait, Jae finally posted his grades.
Instagram Follower Scraper
Published:
A script to scrape the set of Instagram followers
Columbia Fall 24 Recap
Published:
A few thoughts on the past semester. This is by no means a comprehensive review.
Welcome to Jekyll!
Published:
This is a log page.
articles
Applications
Now we have all the tools. Let’s build something interesting. I’ll show 3 example: one analog, one digital, and one mixed.
Circuit-Cim: SPICE in C
Contents
- Intro to SPICE Algorithm (this article)
- Framework and your first circuit!
- More Static Linear Components
- Nonlinear and Diode
- MOSFET
- Time Variance
- Applications
CircuitCim Framework
Framework
To code SPICE, the main challenges are: how do you keep the component information, and how do you tell which value goes where
MOSFETS: Multivariable Nonlinear
After building the framework for nonlinear components, I want to step into transistors. There are two choices:
- BJT: CCCS
- MOS: VCCS
Nonlinear Components
Time for the inner loop of the SPICE algorithm: nonlinear components!
More (Static) Linear Components
More Linear Components
Here is a set of more linear elements. Voltage sources need an additional row from MNA (instead of supernodes in the Tsividis textbook, because we do want to keep track of every subnode in the supernode)
typedef struct {
int n1, n2, ni; // VSrc has an internal node
float *V;
} VSrc;
// dependent sources
typedef struct {
int n1, n2;
int np, nn, ni;
float A; // gain
} Vcvs;
typedef struct {
int n1, n2;
int np, nn;
float A;
} Vccs;
Register functions
void add_vsrc(int n1,int n2, int ni, float V) {
// ni for an internal node for an extra row in the equation.
Component *c = &comps[ncomps++];
c->type = STA_T;
c->stamp = vsrc_stamp;
c->u.vsrc = (VSrc){n1,n2, ni, V};
}
void add_vcvs(int n1, int n2, int np, int nn, int ni, float A) {
Component *c = &comps[ncomps++];
c->type = STA_T;
c->stamp = vcvs_stamp;
c->u.vcvs = (Vcvs){n1,n2, np,nn, ni, A};
}
void add_vccs(int n1, int n2, int np, int nn, float A) {
Component *c = &comps[ncomps++];
c->type = STA_T;
c->stamp = vccs_stamp;
c->update = NULL;
c->u.vccs = (Vccs){n1,n2, np,nn, A};
}
Update functions ```c /* add an ideal voltage source; stamps a “virtual” node (ni) to the circuit.*/ void vsrc_stamp(Component *c, float Gm[][MAT_SIZE], float I[]) { VSrc *s = &c->u.vsrc; float E = vsrc.V;
Time Variance
Now let’s add another dimension to our simulation: time
AP Notes.md
This file may not be fully adapted for web. Download the raw file here
1 Git Version Control
git diff
shows unstaged changes- compares to the last commit if staging area empty (if haven’t
git add
ed) git diff --cached
shows staged changes
- compares to the last commit if staging area empty (if haven’t
10 Domain Sockets
UNIX IPC Summary
Shared Memory
- Multiple threads in the same process
- Process address space shared
- Need synchro
- Multiple related processes
- Anonymous mapping
mmap()
withMAP_SHARED | MAP_ANONYMOUS
, and thenfork()
- Anonymous mapping
- Multiple unrelated processes
mmap()
withMAP_SHARED
, backed up by a real file withopen()
, or virtual file withshm_open()
11 x86-64 Assembly
Data format and registers
16 64-bit general purpose registers (super fast memory locations)
12 Interrupts
Debugger breakpoint
How is it implemented? Tracer fork()
s, and the child program becomes the tracee, but before that, makes a syscall ptrace()
, so the parent process can control this.
13 ELF
Executable and Linking Format (for Linux)
readelf
reads executable and finds all information- Go through all the symbols, see if the calling return address falls between
14 Linking
Linker
seald
15 UNIX File System
Single root directory, not necessarily a single device Need to designate a disk to be the root file system For external devices’ file system, need to mount it to some place at that file system
mount -l
shows all mount points/dev/sda1 on / type ext4 students251 on /mnt/disks/aspstudents251 type zfs
dev
: a region for devicessda1
: hard disk devicetype ext4
: Metadata structure to use this device
16 Linux Container
VM and container
VM: Guest OS kernel run on top of a host OS (with the help of specialized software) controlling the actual hardware
- Give the illusion of physical machine to the guest OS
- Processes still touch the hardware, translation may be needed.
- VMs do not know the existence of each other
- Pro: Hard separation, very secure
- Con: each VM runs an entire OS kernel: resource intensive Container: A group of processes that has its own view of the underlying hardware and OS
- One OS
- Not complete isolation
- Need to make sure processes in different containers can’t communicate
2 Memory
Memory
Address Space
3 Process Control
ps axf # display process tree
ps axfj # with more info
ps axfjww # even if lines wrap around terminal
4 Signals
Signals and system calls
Sending signals
#include <signal.h>
int kill(pid_t pid, int signo);
int raise(int signo); // same as kill(), but yourself
- Both return: 0 if OK, -1 on error
- if
pid < 0
, the signal is sent to the process group withpgid == |pid|
5 File IO
System calls
open()
int open(const char *path, int oflag, mode_t mode);
mode
for file permission if new file created
6 Threads
Creating threads
An execution inside a process (two functions in a process running at the same time), sharing the same address space (same heap, same static var, but can’t share stack space) ^4bba4d
- When thread starts running, the OS assigns a new slab of space in the middle for stack.
- Limit of stack space for each process
#include <pthread.h> int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg); int pthread_join(pthread_t thread, void **retval);
- Limit of stack space for each process
thread
: thread IDattr
: typicallyNULL
, a fine-grain control of thread behaviorstart_routine
: inputvoid *
, returnvoid *
arg
: forstart_routine(arg)
retval
: stores the return value ofstart_routine()
Returns 0 if OK, error number on failure
7 Synchronization
Semaphore
Integer value manipulated by two methods
- Increment (aka V, up,
sem_post()
) - Decrement: wait until value > 0, then decrease value (aka P, down,
sem_wait()
)- Blocks until value is not 0.
8 Interprocess Communication
Pipes
Unnamed pipe
No file name, just an fd
#include <unistd.h>
int pipe(int fd[2]);
Kernel prepares a pipe structure, connecting fd[0]
(read) with fd[1]
(write) After fork()
, parent and child will share the same pipe.
- Pipe is one-way traffic (half duplex)
- Need to
close()
unused ends of pipe
9 IO Blocking and Multiplexing
Nonblocking IO
Making slow (blocking forever) syscalls nonblocking
- Call
open()
with `O_NONBLOCK - Call
fcntl()
(file control) to turn ono_NONBLOCK
file status flag on already opened fd- Will be recorded in the file table entry
- Returns
-1
and setserrno
toEAGAIN
if were to block
courses
Advanced Systems Programming
ASP notes page
AP
Welcome to AP!
Digital Electronics Lab
3082 Lab Reports
- Digital Elements
- 555
- 555 at high frequency failed to work. For better lab experience, change the cap to maybe 2.7 nF
- A/D
- Transmission Line
- Piano (TB)
- Piano (FPGA)
Fundies
Fundies ODS Notes
projects
Cell Cycle
Biology video project
Control Theory
ODE final project
Omega Automata
CST Final Project
Dog Cannot Catch
SCHUDEM VIII outstanding award winner
Climate Change
Eco-Literature Final Project
Exponential and Logarithm
Final project for MATH 312 Analysis I
Rogue Planets
Final project for PHYS 221 Relativity and Cosmology
HTTP Server and Client
HTTP server/client from scratch
Blockchain
Final Project for Computer Networks
CircuitSim
SPICE on FPGA
publications
An Improved Machine Learning Model for Pure Component Property Estimation
2024
A new Gaussian Process-based modeling framework that predicts the physico-chemical properties of chemical species.
Recommended citation: Cao, X., Gong, M., Tula, A., Chen, X., Gani, R., & Venkatasubramanian, V. (2024). An improved machine learning model for pure component property estimation. Engineering, 39, 61–73. https://doi.org/10.1016/j.eng.2023.08.024
Download Paper
Loss Function Evaluation
2025
Accurate tracing of grain boundaries in microscopy images is vital in material science, yet current models need more data and a more accurate loss function. In this report, we present a twofold contribution to improving grain-tracing U-nets.
Interpreting Inner Core Attenuation Scattering through Ultrasonic Experiments
2025
An experimental study of the scattering of ultrasonic compressional waves in an hcp Zn-Sn alloy, serving as an analog to the Fe alloy in Earth’s inner core to better understand the origin of inner core seismic attenuation.
talks
Talk 1 on Relevant Topic in Your Field
This is a description of your talk, which is a markdown file that can be all markdown-ified like any other post. Yay markdown!
Conference Proceeding talk 3 on Relevant Topic in Your Field
This is a description of your conference proceedings talk, note the different field in type. You can put anything in this field.
teaching
General Chemistry
Class Tutor, Bard College at Simon's Rock, 2023
Physics
Class Tutor, Bard College at Simon's Rock, 2023
Intro to Quantum Physics
Class Tutor, Bard College at Simon's Rock, 2023
Classical Mechanics
Class Tutor, Bard College at Simon's Rock, 2024
Ordinary Differential Equations
Class Tutor, Bard College at Simon's Rock, 2024
Organic Chemistry
Class Tutor, Bard College at Simon's Rock, 2024
Synthesis Toolkit
Fundamentals of Computer Systems
TA, Columbia University, 2025