All Projects → scutdig → PyChip-py-hcl

scutdig / PyChip-py-hcl

Licence: MIT license
A Hardware Construct Language

Programming Languages

python
139335 projects - #7 most used programming language
C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to PyChip-py-hcl

Chisel3
Chisel 3: A Modern Hardware Design Language
Stars: ✭ 2,290 (+6261.11%)
Mutual labels:  rtl, firrtl, verilog
ofdm
Chisel Things for OFDM
Stars: ✭ 23 (-36.11%)
Mutual labels:  rtl, firrtl, verilog
Scr1
SCR1 is a high-quality open-source RISC-V MCU core in Verilog
Stars: ✭ 393 (+991.67%)
Mutual labels:  rtl, verilog
Spinalhdl
Scala based HDL
Stars: ✭ 696 (+1833.33%)
Mutual labels:  rtl, verilog
Ustc Rvsoc
FPGA-based RISC-V CPU+SoC.
Stars: ✭ 77 (+113.89%)
Mutual labels:  rtl, verilog
vga-clock
Show the time on a VGA monitor. Submitted for the Google MPW1 ASIC shuttle.
Stars: ✭ 48 (+33.33%)
Mutual labels:  rtl, verilog
Openlane
OpenLANE is an automated RTL to GDSII flow based on several components including OpenROAD, Yosys, Magic, Netgen, Fault and custom methodology scripts for design exploration and optimization.
Stars: ✭ 293 (+713.89%)
Mutual labels:  rtl, verilog
Rggen
Code generation tool for configuration and status registers
Stars: ✭ 54 (+50%)
Mutual labels:  rtl, verilog
sv-tests
Test suite designed to check compliance with the SystemVerilog standard.
Stars: ✭ 148 (+311.11%)
Mutual labels:  rtl, verilog
Logic
CMake, SystemVerilog and SystemC utilities for creating, building and testing RTL projects for FPGAs and ASICs.
Stars: ✭ 149 (+313.89%)
Mutual labels:  rtl, verilog
Fpga readings
Recipe for FPGA cooking
Stars: ✭ 164 (+355.56%)
Mutual labels:  rtl, verilog
Openroad
OpenROAD's unified application implementing an RTL-to-GDS Flow
Stars: ✭ 270 (+650%)
Mutual labels:  rtl, verilog
Cores
Various HDL (Verilog) IP Cores
Stars: ✭ 271 (+652.78%)
Mutual labels:  rtl, verilog
Verilog
Repository for basic (and not so basic) Verilog blocks with high re-use potential
Stars: ✭ 296 (+722.22%)
Mutual labels:  rtl, verilog
Fake-SDcard
Imitate SDcard using FPGAs.
Stars: ✭ 26 (-27.78%)
Mutual labels:  rtl, verilog
Darkriscv
opensouce RISC-V cpu core implemented in Verilog from scratch in one night!
Stars: ✭ 1,062 (+2850%)
Mutual labels:  rtl, verilog
OpenROAD-flow-scripts
OpenROAD's scripts implementing an RTL-to-GDS Flow. Documentation at https://openroad-flow-scripts.readthedocs.io/en/latest/
Stars: ✭ 124 (+244.44%)
Mutual labels:  rtl, verilog
blarney
Haskell library for hardware description
Stars: ✭ 81 (+125%)
Mutual labels:  rtl, verilog
Sv Tests
Test suite designed to check compliance with the SystemVerilog standard.
Stars: ✭ 108 (+200%)
Mutual labels:  rtl, verilog
SpinalDev
Docker Development Environment for SpinalHDL
Stars: ✭ 17 (-52.78%)
Mutual labels:  rtl, verilog

PyHCL

Build Status codecov PyPI

PyHCL is a hardware construct language like Chisel but more lightweight and more relaxed to use. As a novel hardware construction framework embedded in Python, PyHCL supports several useful features include object-oriented, functional programming, and dynamically typed objects.

The goal of PyHCL is providing a complete design and verification tool flow for heterogeneous computing systems flexibly using the same design methodology.

PyHCL is powered by FIRRTL, an intermediate representation for digital circuit design.

PyHCL-generated circuits can be compiled to the widely-used HDL Verilog.

Attention: The back end of the compilation is highly experimental.

Getting Started

Writing A Full Adder

PyHCL defines modules using only simple Python syntax that looks like this:

from pyhcl import *

class FullAdder(Module):
    io = IO(
        a=Input(Bool),
        b=Input(Bool),
        cin=Input(Bool),
        sum=Output(Bool),
        cout=Output(Bool),
    )

    # Generate the sum
    io.sum @= io.a ^ io.b ^ io.cin

    # Generate the carry
    io.cout @= io.a & io.b | io.b & io.cin | io.a & io.cin

Compiling To High FIRRTL

Compiling module by calling compile_to_highform:

Emitter.dump(Emitter.emit(FullAdder(), HighForm), "FullAdder.fir")

Will generate the following FIRRTL codes:

circuit FullAdder :
  module FullAdder :
    input clock : Clock
    input reset : UInt<1>
    output io : {flip a : UInt<1>, flip b : UInt<1>, flip cin : UInt<1>, s : UInt<1>, cout : UInt<1>}
  
    node _T = xor(io.a, io.b)
    node _T_1 = xor(_T, io.cin)
    io.s <= _T_1
    node _T_2 = and(io.a, io.b)
    node _T_3 = and(io.a, io.cin)
    node _T_4 = or(_T_2, _T_3)
    node _T_5 = and(io.b, io.cin)
    node _T_6 = or(_T_4, _T_5)
    io.cout <= _T_6

Compiling To Lowered FIRRTL

Compiling module by calling compile_to_lowform:

Emitter.dump(Emitter.emit(FullAdder(), LowForm), "FullAdder.lo.fir")

Will generate the following FIRRTL codes:

circuit FullAdder :
  module FullAdder :
    input clock : Clock
    input reset : UInt<1>
    input io_a : UInt<1>
    input io_b : UInt<1>
    input io_cin : UInt<1>
    output io_s : UInt<1>
    output io_cout : UInt<1>
  
    node _T = xor(io_a, io_b)
    node _T_1 = xor(_T, io_cin)
    io_s <= _T_1
    node _T_2 = and(io_a, io_b)
    node _T_3 = and(io_a, io_cin)
    node _T_4 = or(_T_2, _T_3)
    node _T_5 = and(io_b, io_cin)
    node _T_6 = or(_T_4, _T_5)
    io_cout <= _T_6

Compiling To Verilog

Compiling module by calling compile_to_verilog:

Emitter.dump(Emitter.emit(FullAdder(), Verilog), "FullAdder.v")

Then FullAdder.v will be generated:

module FullAdder(
  input		clock,
  input		reset,
  input		io_a,
  input		io_b,
  input		io_cin,
  output		io_s,
  output		io_cout
);

  assign io_s = io_a ^ io_b ^ io_cin;
  assign io_cout = io_a & io_b | io_a & io_cin | io_b & io_cin;
  
endmodule

Features

  • Supports multiple data types: UInt, SInt, Vector, Bundle, Clock, Memory, and casual combination between them.
  • Supports object-oriented inheritance, can compose modules by writing fewer codes.
  • Supports a bunch of convenient operations, such as the addition of UInts, SInts, Vectors and Bundles.
  • Supports the parameterization of variables, such as bit width, with the syntax facilities of the host language Python.

TODO

  • Supports more operations
  • PyHCL's verification facility
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].