OpenRAM/docs/source/python_library.md

2.0 KiB

Go Back

Python Library

This page explains the Python library of OpenRAM.

Table of Contents

  1. Installation
  2. Environment Variables
  3. Usage

Installation

OpenRAM is available as a Python library. There are a few ways to install it:

  • Install the latest stable version with pip:
pip3 install openram
  • Install the latest dev version:
pip3 install git+https://git@github.com/VLSIDA/OpenRAM.git@dev
  • Install using Makefile (you need to clone the repo):
git clone git@github.com:VLSIDA/OpenRAM.git
cd OpenRAM
make library

Environment Variables

OpenRAM library doesn't need any envinronment variable by default. However, if you have set the environment variables explained on basic usage, the library will use the OpenRAM source code located at OPENRAM_HOME.

If you want the convenience of being able to call OpenRAM from any Python script and have a custom OpenRAM setup, you can set these environment variables to point to that OpenRAM installation.

If you don't want to use this feature, you can simply unset these environment variables.

Usage

With the OpenRAM library, you can use OpenRAM in any Python script. You can import "openram" as follows:

import openram
openram.init_openram("myconfig.py") # Config files are explained on "Basic Usage" page
# Now you can use modules from openram
from openram import tech
...

Note that you need to initialize OpenRAM so that the modules are imported properly. You can also look at sram_compiler.py as an example on how to use "openram."

If you want to pass custom configuration when generating an SRAM, you can use the sram_config class.

import openram
openram.init_openram("myconfig.py")

from openram import sram_config
c = sram_config(...)

from openram import sram
s = sram(sram_config=c,
         name="custom_name")

s.save()

openram.end_openram()