Crate calyx

source · []
Expand description

The Calyx Intermediate Language

Calyx is an intermediate language for transforming high-level programs into synthesizable hardware designs. Calyx’s key novelty is a split representation that captures the control-flow and the structural detail of a hardware design. Take a look at the language tutorial for a complete overview for the Calyx intermediate langauge.

This library defines the intermediate representation, i.e., the data structures used by the compiler to analyze and transform programs. The following example shows how to parse a Calyx program and generate the core data structure, ir::Context which provides access to all the information in a program.

use std::io::Write;
use calyx::{frontend, ir, errors::CalyxResult};
fn main() -> CalyxResult<()> {
  // File to parse
  let file: std::path::PathBuf = "../tests/correctness/seq.futil".into();
  // Location of the calyx repository
  let lib_path: std::path::PathBuf = "../".into();
  // Parse the calyx program
  let ws = frontend::Workspace::construct(&Some(file), &lib_path)?;
  // Convert it into an ir::Context
  let mut ctx = ir::from_ast::ast_to_ir(ws)?;
  // Print out the components in the program
  let out = &mut std::io::stdout();
  for comp in &ctx.components {
      ir::Printer::write_component(comp, out)?;

  1. Calyx’s guarded assignments are different from Bluespec’s rules. Rules can be dynamically aborted if there are conflicts at runtime and the Bluespec compiler generates scheduling logic to detect such cases. In contract, Calyx’s schedule is defined using the control program and requires no additional scheduling logic to detect aborts. 


Analysis for Calyx programs.

Defines the default passes available to PassManager.

Errors generated by the compiler.

Frontend parsing and AST representation.

Internal representation for the Calyx compiler.

Define the PassManager structure that is used to construct and run pass passes.

Passes for the Calyx compiler.

Shared utilities.


Build guarded assignment statements and return a vector containing them.

Convinience macro to get a port and turn it into an ir::Guard.

Simple macro to register an alias with a pass manager.

Add primitives and constants to the component and let-bind the references.