Setup
โ๏ธ Environment Setup
This project requires Python 3.5, Anaconda/miniconda, and runs in any Linux environment with x86_64 CPU.
๐ฆ 1. Install Conda
Please install either Anaconda or Miniconda for Python 3.5 support.
For csh Shell Users
After installation, add the following to your .cshrc
(e.g., cshrc.gf55BCDlite_v1090
):
# model path
setenv SPECTRE_MODEL_PATH /net/vlsiserver/usr11/library/CSM/gf55BCDlite_v1090_stack7A/55BCDlite/V1.0_9.0/Models/Spectre/55bcdlite/models/
# Conda setup
setenv PATH "${HOME}/anaconda3/bin:${PATH}"
if ( -f "${HOME}/anaconda3/etc/profile.d/conda.csh" ) then
source "${HOME}/anaconda3/etc/profile.d/conda.csh"
else
echo "No Conda csh file found in the specified path."
endif
Then run:
source path/to/csh/file
conda activate
You may need to manually install some additional packages via
pip
later.
๐ 2. Clone the Project
git clone https://github.com/lwasoo/AutoCkt.git
cd AutoCkt
๐ 3. Create Conda Environment
From the root directory:
conda env create -f environment.yml #only need to create once
conda activate autockt
If needed, use pip
to manually install missing packages.
๐๏ธ 4. Project Structure
`-- AutoCkt
|-- autockt \\Core model code
| |-- envs
| | `-- ngspice_vanilla_opamp.py \\OpenAI Gym environments
| |-- gen_specs
| | `-- ngspice_specs_gen_two_stage_opamp \\generate targets from gen_spec
| |-- gen_specs.py \\generate target spec
| |-- rollout.py \\validation entry point
| `-- val_autobag_ray.py \\Training entry point
|-- environment.yml \\conda env
|-- eval_engines \\interacts with simulator
| |-- ngspice
| | |-- TwoStageClass.py \\calculate gain, ibias, ugbw, phm
| | |-- ngspice_inputs
| | | |-- netlist
| | | `-- yaml_files
| | | `-- two_stage_opamp.yaml \\circuit parameters spec
| | `-- ngspice_wrapper.py \\simulator interface
๐งช 5. Simulate and Train
Generate Specs
python autockt/gen_specs.py --num_specs 350
Specs will be saved as pickle files under gen_specs/
.
Run Training
ipython
run autockt/val_autobag_ray.py
Training results will be stored in ~/ray_results
.
To monitor training:
tensorboard --logdir ~/ray_results
โ 6. Run Validation
To test generalization of the trained model:
- Generate new specs:
python autockt/gen_specs.py --num_specs 100
- Run validation:
ipython run autockt/rollout.py /path/to/checkpoint --run PPO --env opamp-v0 --num_val_specs 100 --traj_len 20 --no-render
Validation results will be saved as:
opamp_obs_reached_test
opamp_obs_nreached_test
The steps for checking the netlist are described in detail in Others.
๐ง 7. Customize Circuit (2stage Example)
To modify for cascode topology:
- Edit line 121 in
ngspice_vanilla_opamp.py
:self.cur_params_idx = np.array([33, 33, 33, 33, 33, 14, 20])
- Modify the initial step vector:
env.step([2, 2, 2, 2, 2, 2, 2])
- Edit the YAML spec file
two_stage_opamp.yaml
:- Set custom parameter ranges
- Set
target_spec
for new design goals
๐ Notes
- Default netlist is located at:
eval_engines/ngspice/ngspice_inputs/netlist/2opamp
- Training performance is hardware-dependent. For reliable results, use at least 2 cores, ideally 8 cores.
- Results can vary depending on
random seed
and spec generation.