Pre-release

Describe hardware in C++.

A C++ extension and compiler for FPGAs.

counter.flux

counter.flux

__fpga void counter(clock clk, bits<1> reset, bits<32>& count) {
    __onRise(clk) {
        if (reset)
            count = 0;
        else
            count = count + 1;
    }
}

Inspect the hardware

flux --emit=hardware blink.flux
module @blink [sequential] {
    clock %clk
    output %led : u1
    state %divider : u25 [init=u25 0]
    state %ledState : u1 [init=u1 1]
    on_rise %clk {
        if equal<bit> %divider, i32 13500000 {
            next %divider = u25 0
            next %ledState = xor<i32> %ledState, i32 1
        }
        else {
            next %divider = add<i32> %divider, i32 1
        }
    }
    drive %led = %ledState
}

Build for a board

flux --emit=fs --board=tang-nano-20k \
  --top=blink blink_board.flux \
  --image-output=blink.fs \
  --manifest-output=blink.json
native-fs @blink [GW2AR-18C]:
    67 LUTs,
    26 storage elements,
    carry_blocks=0,
    dsp_blocks=0,
    bsram_blocks=0,
    1 outputs,
    1 clocks,
    8147 configuration fuses;
    validated .fs image at blink.fs

Simulate

flux --simulate-build counter_test.flux \
  -o counter_test
./counter_test
count = 5
Real command-line input and output. There is no graphical editor yet.

Works today

All capabilities

Simulate from C++

Your testbench is ordinary C++.

counter_test.flux
flux::sim::Simulator sim;
const auto clk = sim.createClock("clk", 10ns);
const auto dut = sim.instantiate(counter, {{"clk", clk}});

sim.setInput(dut, "reset", true);
sim.runFor(10ns);
sim.setInput(dut, "reset", false);
sim.runFor(50ns);

Clear errors

If it cannot be hardware, you are told why.

Compiler
loop.flux:2:5: error:
  Flux FPGA functions do not support
  ordinary for loops; use __unroll

Export netlists

Verilog, plus BLIF, JSON and EDIF through Yosys.

Shell
flux design.flux --verilog design.v

Native board images

A supported subset of designs. Hardware-tested on one board so far.

  • Sipeed Tang Nano 20KBasic hardware tests
  • Sipeed Tang Nano 9KOffline checks
  • 1BitSquared iCEBreaker V1.1bOffline checks
  • Radiona ULX3S 85FOffline checks
  • Digilent Basys 3Offline checks
  • Digilent Arty A7-100TOffline checks
Board coverage

See every stage

From Hardware IR to routed placement.

  • --emit=hardware
  • --emit=optimized-circuit
  • --emit=lut
  • --emit=placed
  • --emit=routed
  • --emit=timed
  • --emit=fs
How it works

From C++ to circuit

Experimental syntax. Only a subset of C++ becomes hardware.

counter.flux
__fpga void counter(clock clk, bits<1> reset, bits<32>& count) {
    __onRise(clk) {
        if (reset)
            count = 0;
        else
            count = count + 1;
    }
}
+10count32 flip-flopsresetclkout
An adder, a selector and a register.

Where it stands

Roadmap

Available

  • Hardware functions in C++
  • Hardware IR and logic mapping
  • Simulation from C++
  • Board configuration images
  • Netlist export
  • Compiler diagnostics

In development

  • Installable releases
  • Verification on physical boards
  • Loading designs over USB
  • Peripherals and video
  • Timing analysis for real devices
  • Processor and FPGA communication

Planned

  • Desktop engineering environment
  • Verilog and SystemVerilog input
  • Waveform viewer
  • Analog simulation with SPICE

Explore the docs.