Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libtrellis: offer serialise_chip/serialise_chip_delta in Python api #113

Merged
merged 1 commit into from
Jan 2, 2020

Conversation

rrika
Copy link
Contributor

@rrika rrika commented Jan 2, 2020

This commit makes two functions to serialize full and partial bitstreams usable from python. The C++ signatures are

static Bitstream serialise_chip(const Chip &chip, const map<string, string> options);
static Bitstream serialise_chip_partial(const Chip &chip, const vector<uint32_t> &frames, const map<string, string> options);

The issues with wrapping these are:

  1. I can't figure out how to make boost-python allow passing the maps/vectors for the arguments.
  2. serialise_chip_partial takes a list of frames, which AFAICT can currently only be built from python by calling get_bit on both chips for every bit, or looping over a CRAMDelta (which occupies 12 bytes per changed bit)

This patch instead adds

static Bitstream serialise_chip_py(const Chip &chip);
static Bitstream serialise_chip_delta_py(const Chip &chip1, const Chip &chip2);

Usage example:

#!/usr/bin/env python3

import sys; sys.path.append("[...]/prjtrellis/libtrellis")
import pytrellis; pytrellis.load_database("[...]/prjtrellis/database")

chip1 = pytrellis.Bitstream.read_bit("before.bit").deserialise_chip()
chip2 = pytrellis.Bitstream.read_bit("after.bit").deserialise_chip()
bit_delta = pytrellis.Bitstream.serialise_chip_delta(chip1, chip2)
bit_delta.write_bit("delta.bit")

@daveshah1 daveshah1 merged commit d8c5e9d into YosysHQ:master Jan 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants