Giter Site home page Giter Site logo

liberty's Introduction

Liberty Parser

This is an open-source Parser for the Liberty Standard Cell Library format.

Please, refer to Open Source Liberty for format specification and reference parser.

Usage

Use the Api function to parse a file. The function liberty_parse receives a pair of iterators as input and writes the AST (abstract-syntax tree) on a liberty::ast::Library object. e.g.,:

  #include <fstream>
  #include <vector>
  #include <algorithm>
  #include <iterator>
  #include <iostream>
  #include "LibertyParser.hpp"
  
  int main() {
    const liberty::ast::Library library = [&]() {
      liberty::ast::Library library_;
      std::ifstream in("file.lib", std::fstream::in);
      const std::vector<char> buffer = []() {
        std::vector<char> buffer_(std::istreambuf_iterator<char>(in), std::istreambuf_iterator<char>());
        std::replace(buffer_.begin(), buffer_.end(), '\n', ' ');
        std::replace(buffer_.begin(), buffer_.end(), '\\', ' ');
        return buffer_;
      } ();
      auto first = buffer.begin();
      auto result = liberty::ast::liberty_parse(first, buffer.end(), library_);
      return library_;
    } ();
    const int numberOfCells = [&]() {
      int numberOfCells_ = 0;
      liberty::ast::Visitor visitor;
      visitor.onCell([&](const liberty::Cell&) { ++numberOfCells_; });
      visitor(library);
      return numberOfCells_;
    } ();
    std::cout << "This Library has " << numberOfCells << " cells." << std::endl;
    return 0;
}

Build Instructions

Requirements

First Time

  • Pull further dependencies:
git submodule update --init --recursive --depth 1
  • Invoke CMake
cmake .

Building and Testing

# Build
make

# Test
./Liberty_test

This Library is still in development. Feel free to create an issue.

liberty's People

Contributors

andrepuel avatar csguth avatar donn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.