Skip to main content

Build Status Appveyor Build status PyPI - Version Coverage Documentation Status

Kratos is a hardware design language written in C++/Python. It differentiates itself from other DSL with the following design philosophy:

  • Fully debuggable: debug hardware just like debugging Python code! Thanks to hgdb.

  • Highly efficient: Python frontend powered by Modern C++ binding. Designed with multi-processing in mind.

  • Human-readable verilog: we know how difficult it is to read machine generated verilog. kratos has multiple passes to produce nice-looking verilog.

  • Generator of generators: every python object is a generator that can be modified at any time, even after instantiation. This allows complex passes on the generators without ripping old structure apart.

  • Keep the good parts of SystemVerilog, such as always_ff, always_comb, interface, and unique case. Users control how and when to generate these semantics.

  • Single source of truth: kratos encourages users to infuse generator information inside generator itself. This makes debugging and verification much easier.

  • Static elaboration: kratos allows user to write parametrized code, even in the always block, all in Python.

  • Type checking: kratos check the variable types for each assignment to make sure there is no implicit conversion.

Install

pip install kratos

Pre-built wheels support all Python 3.6+ on Linux, Windows, and OSX. To build it from scratch, you need a C++17 compatible compiler, such as g++-8 or clang-8.

Documentation and Examples

You can check the documentation at Read the Docs.

Here are some examples to showcase the ability of kratos.

Async Reset Register

Python code that parametrizes based on the width. Notice that we specify the sensitivity of the always_ff block when defining seq_code_block.

class AsyncReg(Generator):
    def __init__(self, width):
        super().__init__("register")

        # define inputs and outputs
        self._in = self.input("in", width)
        self._out = self.output("out", width)
        self._clk = self.clock("clk")
        self._rst = self.reset("rst")

        # add combination and sequential blocks
        self.add_code(self.seq_code_block)

    @always_ff((posedge, "clk"), (posedge, "rst"))
    def seq_code_block(self):
        if self._rst:
            self._out = 0
        else:
            self._out = self._in

Here is the generated SystemVerilog

module register (
  input logic clk,
  input logic [15:0] in,
  output logic [15:0] out,
  input logic rst
);


always_ff @(posedge clk, posedge rst) begin
  if (rst) begin
    out <= 16'h0;
  end
  else out <= in;
end
endmodule   // register

Fanout module

This is another example to showcase the kratos’ ability to produce high-quality SystemVerilog. In practice we would not write it this way.

class PassThrough(Generator):
    def __init__(self, num_loop):
        super().__init__("PassThrough")
        self.in_ = self.input("in", 1)
        self.out_ = self.output("out", num_loop)
        self.num_loop = num_loop

        self.add_code(self.code)

    @always_comb
    def code(self):
        if self.in_:
            for i in range(self.num_loop):
                self.out_[i] = 1
        else:
            for i in range(self.num_loop):
                self.out_[i] = 0

Here is generated SystemVerilog. Notice that the iteration variable i has been properly checked and resized to avoid index out of range.

module PassThrough (
  input logic in,
  output logic [3:0] out
);

always_comb begin
  if (in) begin
    for (int unsigned i = 0; i < 4; i += 1) begin
        out[2'(i)] = 1'h1;
      end
  end
  else begin
    for (int unsigned i = 0; i < 4; i += 1) begin
        out[2'(i)] = 1'h0;
      end
  end
end
endmodule   // PassThrough

How to debug

Because Python is quite slow, By default the debug option is off. You can turn on debugging for individual modules. See tests/test_generator.py for more details).

Use an IDE Debugger

demo

Thanks to the native support of hgdb, you can debug the generated RTL with a professional debugger as if you are debugging Python code. gdb-like console version is also available. Check out hgdb to see how it works!

Metadata

Release files for kratos 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kratos 0.1.3
File Size Uploaded
kratos-0.1.3.tar.gz 1.8 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for kratos 0.1.3
File
kratos-0.1.3-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
kratos-0.1.3-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.12+ x86-64 Details
kratos-0.1.3-cp310-cp310-macosx_10_9_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.9+ x86-64 Details
kratos-0.1.3-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
kratos-0.1.3-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.12+ x86-64 Details
kratos-0.1.3-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details
kratos-0.1.3-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
kratos-0.1.3-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.12+ x86-64 Details
kratos-0.1.3-cp38-cp38-macosx_10_9_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.9+ x86-64 Details
kratos-0.1.3-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
kratos-0.1.3-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64 Details
kratos-0.1.3-cp37-cp37m-macosx_10_9_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64 Details
kratos-0.1.3-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
kratos-0.1.3-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.12+ x86-64 Details
kratos-0.1.3-cp36-cp36m-macosx_10_9_x86_64.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.9+ x86-64 Details

Total release size: 30.2 MB

Release files / kratos-0.1.3.tar.gz

Download URL kratos-0.1.3.tar.gz
Size 1.8 MB
Tags Source
SHA-256 checksum
How to use checksums
96168b94a0647257f44149f8fde856d49ca77b0b0fb13fc95726513fe4153696
BLAKE2b-256 checksum
How to use checksums
ee8f0e9534f55b2495fe02e6dc706e865e591c3c9b6f3def1c4d10bbcfdfe560
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.13

Release files / kratos-0.1.3-cp310-cp310-win_amd64.whl

Download URL kratos-0.1.3-cp310-cp310-win_amd64.whl
Size 1.3 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
14ce3bcec4dd5c9af51beefdb899d8c8dc6375242d0ead6feb83e76853ea2883
BLAKE2b-256 checksum
How to use checksums
0308b432b078fedabe11109d469b94bf6aa52ba155fd4620bcc290579e4f0f8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Release files / kratos-0.1.3-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl

Download URL kratos-0.1.3-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Size 2.1 MB
Tags CPython 3.10 Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
0905cc985d2d9035f2fc9a9ccfc2262bf78eb3feacd22caf06ba8dba197a1617
BLAKE2b-256 checksum
How to use checksums
0be323086c5fb31ec52d363db959af509674f02250675c7cbed5adf5f63d463b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.13

Release files / kratos-0.1.3-cp310-cp310-macosx_10_9_x86_64.whl

Download URL kratos-0.1.3-cp310-cp310-macosx_10_9_x86_64.whl
Size 2.2 MB
Tags CPython 3.10 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
5a03e3361af66dd39b13c875ee490f185e474fa68b2e279f40297002e8c8f16a
BLAKE2b-256 checksum
How to use checksums
515ad59aaed7ed25d622ad55f67077391de81ce1bf45382e824f269ad6be8a12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Release files / kratos-0.1.3-cp39-cp39-win_amd64.whl

Download URL kratos-0.1.3-cp39-cp39-win_amd64.whl
Size 1.3 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
4ad069197f38ac0eea009701383b1b457d5b79bd759847ccb9faed37a416c91f
BLAKE2b-256 checksum
How to use checksums
970ca81ca3eb5f4cab1ebc55f6e03b0cf76759f669aed9f6d4b4d94ab8ad5aca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Release files / kratos-0.1.3-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl

Download URL kratos-0.1.3-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Size 2.1 MB
Tags CPython 3.9 Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
b2a0970d5c74020c6b811a612d668dc26aa9ad1cb86fff04789cfe20399d70c9
BLAKE2b-256 checksum
How to use checksums
1fc27b6e7048ffdf3ac191a243fe1baa1634a7ccaa547f506d6d718e5de8bb78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.13

Release files / kratos-0.1.3-cp39-cp39-macosx_10_9_x86_64.whl

Download URL kratos-0.1.3-cp39-cp39-macosx_10_9_x86_64.whl
Size 2.2 MB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
e7ec2e98d5a0b9055ece74fddd1b4e8636e7698fb7e763bc3b34626e9c441877
BLAKE2b-256 checksum
How to use checksums
884451d663c88e54849363361989bed537b40c3bcd99ae32f5611e268bbe9e5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / kratos-0.1.3-cp38-cp38-win_amd64.whl

Download URL kratos-0.1.3-cp38-cp38-win_amd64.whl
Size 1.3 MB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
16ec743b384ab67919a0d80bf131d605eb51cfe83c84412bfac3da3e4cf84695
BLAKE2b-256 checksum
How to use checksums
196f8550746247a63d1d379c86910104bf7507b7f063508ea0ad450ddb79bee2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release files / kratos-0.1.3-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl

Download URL kratos-0.1.3-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Size 2.1 MB
Tags CPython 3.8 Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
dfa0344721a28fa91cf094951c51bc8dc3017fcffbd6a2201fa68900343d3f4e
BLAKE2b-256 checksum
How to use checksums
55daa60fef7d997a7e9c3aa4a1deb3ca0d2de0c7769a71f2358b2e6f8f56b30b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.13

Release files / kratos-0.1.3-cp38-cp38-macosx_10_9_x86_64.whl

Download URL kratos-0.1.3-cp38-cp38-macosx_10_9_x86_64.whl
Size 2.2 MB
Tags CPython 3.8 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
92421d853f232543ea55291ef9a0d7aa527c646526cdf73e91b93b98cd8851b8
BLAKE2b-256 checksum
How to use checksums
30b70d32642a3cc76e205283b504fdb794046680e2930f4ab3f74d6cf03aa352
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.13

Release files / kratos-0.1.3-cp37-cp37m-win_amd64.whl

Download URL kratos-0.1.3-cp37-cp37m-win_amd64.whl
Size 1.3 MB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
3a14a9e30e92806d7df7562eb1b1db6a122c57fb18a3b0b390be8d3c28d398b1
BLAKE2b-256 checksum
How to use checksums
752e8c72c88951eb8a1221e4af81ffa7913295395af2caca012dfccaaa2e2305
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.7.9

Release files / kratos-0.1.3-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl

Download URL kratos-0.1.3-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Size 2.2 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
bb8c316b898d47d01d7810bd0f192b6e53198e18d4e57d3e29e04617887b4dc0
BLAKE2b-256 checksum
How to use checksums
e0db3711c49b552cafa81785bc5d3d309f9ae4b1d8176edf7629eacad7c8f4a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.13

Release files / kratos-0.1.3-cp37-cp37m-macosx_10_9_x86_64.whl

Download URL kratos-0.1.3-cp37-cp37m-macosx_10_9_x86_64.whl
Size 2.2 MB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
0d2a640d03494710166cd62c06639017dd0a5bbf5056e99bd422077031357a6b
BLAKE2b-256 checksum
How to use checksums
9d42b7b4fc0a8592625f2798a867dcda0693e365719b084251b059d5f5e47e76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.7.13

Release files / kratos-0.1.3-cp36-cp36m-win_amd64.whl

Download URL kratos-0.1.3-cp36-cp36m-win_amd64.whl
Size 1.3 MB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
35e63bb877591dfff775f16b3863be81f1f15e5e7eb22e048b3b3643d912b6cf
BLAKE2b-256 checksum
How to use checksums
2ad4f463cda2ee341e62cd19cda1424c2b1c22b0c4833e23ef306e7be2e0feca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.8

Release files / kratos-0.1.3-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl

Download URL kratos-0.1.3-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Size 2.2 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
f6b1194b1e3771d9504936cfdaa8d6a5d11d8cb95860ca1181b61b79f3582c5f
BLAKE2b-256 checksum
How to use checksums
d66ee0e0ed1a5838dc0a9d7b10a6a6c85c942e4c43ab07d580dba37308110ece
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.13

Release files / kratos-0.1.3-cp36-cp36m-macosx_10_9_x86_64.whl

Download URL kratos-0.1.3-cp36-cp36m-macosx_10_9_x86_64.whl
Size 2.2 MB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
4fb26cdba3257baf0a8898ce31ccb2aef1125190055efd75a2cb0ab42a613f95
BLAKE2b-256 checksum
How to use checksums
79a7e87f59897e7e3c05e5eaed85d1d6c1e0a27598dd7389169c03027aa994d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.13

Release history Release notifications | RSS feed

This release

0.1.3 This release

16 release files

0.1.2

16 release files

0.1.1

16 release files

0.1.0

16 release files

0.0.23

6 release files

0.0.22

5 release files

0.0.19

5 release files

0.0.18

4 release files

0.0.17

4 release files

0.0.15

4 release files

0.0.14

4 release files

0.0.13

4 release files

0.0.12

4 release files

0.0.10

4 release files

0.0.9

5 release files

0.0.8

5 release files

0.0.7

5 release files

0.0.6

3 release files

0.0.5

3 release files

0.0.4

3 release files

0.0.3

3 release files

0.0.2

3 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page