Generalized Numerical P Systems simulator package
Project description
GNPS Project
GNPS (Generalized Numerical P Systems) is a Python package for parsing and simulating numerical P systems, and for exporting them to generated code.
Current Capabilities
- Python simulation of standalone and import-composed GNPS YAML systems
- Python source export through
gnps-transform -t python, including import-composed systems as a single generated file - Verilog/SystemVerilog export through
gnps-transform -t verilog - Optional import/composition metadata for Verilog generation
CLI
Simulator
python -m gnps <gnps_file.yaml> [input.csv] [output.csv] [options]
Options:
-c,--compute_mode: run in continuous compute mode-s,--steps N: number of steps to run--csv: emit CSV in continuous mode
The simulator supports standalone GNPS YAML and import-composed GNPS systems. Files using externals still fail clearly in the Python runtime.
Transformer
gnps-transform <gnps_file.yaml> -t {python,verilog} [options]
Options:
-o,--output-dir DIR: output directory--output-suffix SUFFIX: suffix inserted before the generated file extension--import-path DIR: extra import search path, may be repeated--import-paths LIST: path-separated import search list-v,--verbose: verbose logging
Import resolution order:
- relative to the importing YAML file
--import-path/--import-pathsdirectories in the order provided
YAML Schema
Standalone legacy files still work:
cells:
- id: 1
contents:
- x = 0
- y = 1
input: [x]
output: [y]
rules:
- x + 1 -> y
Verilog/SystemVerilog-oriented extensions are optional:
module:
name: controller_top
real_encoding:
kind: fixed_point
signed: true
width: 32
frac_bits: 16
clock:
name: clk
reset:
name: rst
active_high: true
top_ports:
- name: uart_rx
dir: input
kind: logic
width: 1
signed: false
constants:
THRESHOLD: 5
aliases:
sensed: sensor0.level
imports:
- module: sensor.yaml
as: sensor0
connections:
raw: sample
externals:
- header: uart.header.yaml
as: uart0
connections:
clk: top.clk
rst: top.rst
rx: top.uart_rx
cells:
- id: 1
contents:
- sample = 0
- alarm = 0
output: [alarm]
rules:
- sensed > THRESHOLD && uart0.rx_valid == 1 | uart0.rx_data + 1 -> alarm
Qualified references supported by the parser:
- local variable:
x - imported GNPS IO:
sensor0.level - external port:
uart0.rx_valid - top-level signal:
top.uart_rx,top.clk,top.rst
Defaults
If module is absent, the effective defaults are:
- module name: source filename stem
real_encoding.kind:fixed_pointreal_encoding.signed:truereal_encoding.width:32real_encoding.frac_bits:16- clock name:
clk - reset name:
rst - reset polarity: active high
- top ports: none
If constants, aliases, imports, or externals are absent, they default to empty.
These defaults are also documented in rules.md.
Generated RTL
The verilog backend emits SystemVerilog-style RTL:
- file extension:
.sv - module parameters in the module header
always_combfor next-state logicalways_fffor sequential updates- fixed-point values stay as integer literals in the emitted RTL, wrapped in generated module-local
localparamaliases such as_VAL_1_0 - boundary conversions use generated integer-only helper functions rather than
real-based helpers - generated literal aliases are documented with comments showing the original source values and fixed-point format
Supported expression subset:
- constants
- local variables
- qualified references
- addition and subtraction
- unary minus
- constant multiplication and constant division
- boolean comparisons
- boolean
&&,||,!
Rejected constructs:
- generic function calls
- variable-by-variable multiplication
- non-constant division
- arrays
Each GNPS module uses its own real_encoding. Boundary conversions are inserted automatically for imported GNPS IO and external ports.
In the Verilog backend, consumed variables are reset to zero explicitly before productions are accumulated.
Examples
See src/examples/ for:
- standalone legacy-style YAML
- import-only Python/Verilog composition
- imported multicell Verilog composition
- external UART header and controller top module examples
Notes
- Top-level
nameanddescriptionare treated as metadata and ignored by Verilog generation. - Python composition currently supports
importsonly. externalsare not yet supported by the Python backend or runtime simulator.- Declaring a variable in
outputonly exposes it at the module boundary; it does not implicitly consume or reset that variable each step. If an output should behave like a per-step pulse/value rather than accumulated state, add an explicit consume/reset rule for it. - Detailed behavior and schema rules live in
rules.md.
Example:
cells:
- id: 1
contents:
- alarm = 0
output: [alarm]
rules:
# Persistent output/state: alarm keeps its previous value unless consumed
- sensor0.level > 2 | 1 -> alarm
cells:
- id: 1
contents:
- alarm = 0
output: [alarm]
rules:
# Per-step output: first produce the value you want
- sensor0.level > 2 | 1 -> alarm
# Then consume/reset alarm each step so it does not accumulate
- alarm * 0 -> alarm
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gnps-0.2.0.tar.gz.
File metadata
- Download URL: gnps-0.2.0.tar.gz
- Upload date:
- Size: 51.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.25.9 CPython/3.12.11 Linux/6.12.74+deb13+1-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4866c1b254ab947f2c6d5cc1c733048bdbcb7ff00871d740c267752d0cbb92f
|
|
| MD5 |
0f73252719edb8e178926d7ab9ec0ab9
|
|
| BLAKE2b-256 |
b820e13d57ca43d6857cad8e4829808ab4a53c513a2c75d5d4b4f8b1d23221d7
|
File details
Details for the file gnps-0.2.0-py3-none-any.whl.
File metadata
- Download URL: gnps-0.2.0-py3-none-any.whl
- Upload date:
- Size: 36.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.25.9 CPython/3.12.11 Linux/6.12.74+deb13+1-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27276f9e062ca936b1e1bb5393051eed4c686a224a24b998cb2f56a88d0ebe8a
|
|
| MD5 |
324ae2b9605a0072c5885f6268d3b7ed
|
|
| BLAKE2b-256 |
9b500ba957d45439b7323af057b0d6fa3105ff76012767d74f66f2d040dbdd87
|