Skip to main content

Linear Feedback Shift Registers in pure Python3

Project description

FSR-Tools: Feedback/Feedforward Shift Registers in Python

Designed to test FSR Mathematically for verification of Verilog Design. This package provides an abstract base class for Feedback/Feedforward Shift Registers (FSRs) and two concrete implementations:

  • Fibonacci LFSR (linear feedback)
  • Galois LFSR (linear feedforward)

Supports:

  • Custom characteristic polynomials
  • Arbitrary initial states
  • State table generation
  • Algebraic polynomial form
  • Bitwise access to register positions

Installation

Clone the repo and place the module in your project:

git clone https://github.com/anubhav-narayan/fsr-tools.git

Use poetry

poetry install

Usage

General Usage

from fsr_tools import Galois_LFSR as LFSR

lfsr = LFSR(poly=0b10011, state=0b1010)

# Get full cycle of states
print(lfsr.state_table)
# Access bits
print(lfsr[0]) # Read a bit
lfsr[4] = lfsr[3] & 0b1 # Write a bit

Usage with CoCoTB

from fsr_tools import Galois_LFSR as LFSR
from cocotb import BinaryValue

lfsr = LFSR(poly=0b10011, state=0b1010)

# Assign state
dut.lfsr.value = BinaryValue(lfsr.state, n_bits=lfsr.field_order)

Extend the FSR Abstract Class to create custom Feedback/Feedforward Shift Registers. Just override the round function.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fsr_tools-1.0.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fsr_tools-1.0.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file fsr_tools-1.0.0.tar.gz.

File metadata

  • Download URL: fsr_tools-1.0.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for fsr_tools-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b4bb5187d0d9e291c20e4f1ab5c085dcd9b32499a50736e726ef3b7f8983268e
MD5 d356e4f363b5a6b73eab3bc27fd7e2ff
BLAKE2b-256 3f0a392ffaadb6fc37b94ae296f8f2dbfe6739d4b50ef615005f75acdb07a418

See more details on using hashes here.

Provenance

The following attestation bundles were made for fsr_tools-1.0.0.tar.gz:

Publisher: python-publish.yml on anubhav-narayan/fsr-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fsr_tools-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: fsr_tools-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for fsr_tools-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a9abd8c8de9e2e9fbcfdc61b3b889a17652fceeba1a22f0aab509088f8fc7886
MD5 0471624627ef4ee4e131444b1074e300
BLAKE2b-256 49aadbdd6cfc9c0a51f793a6b795d3ed7a81aadf9edb484f9ea016f0822d9792

See more details on using hashes here.

Provenance

The following attestation bundles were made for fsr_tools-1.0.0-py3-none-any.whl:

Publisher: python-publish.yml on anubhav-narayan/fsr-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page