MCPcopy Index your code
hub / github.com/Redcrafter/verilog2factorio

github.com/Redcrafter/verilog2factorio @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
419 symbols 820 edges 58 files 2 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Factorio verilog compiler

This project will compile verilog (a hardware description language) into factorio blueprints.\ Using this it should also be possible to compile vhdl. (not tested)

Web Demo

You can check out the web demo here.

Install

Manually compile Yosys 0.34 (later releases might not work) and add it to your PATH.

Run npm install to install all dependencies.

Usage

Usage: v2f [options] <files..>

Options:
  -v, --verbose
  -d  --debug               Generate debug information. (A graph of the output circuit.)
  -o, --output <file>       File to output the compiled blueprint to.
  -m, --modules <names...>  Verilog modules to output blueprint for. (defaults to all).
  -f, --files <files...>    List of Verilog files to compile. (only has to be explicitly specified after -m).
  -g, --generator [type]    Layout generator to use. annealing(default),matrix,chunkAnnealing
  -h, --help                Display this information.

Quick Start

Run ./v2f with verilog files as parameters. Example: ./v2f ./samples/counter.v

The compiled blueprint will be output on the command line unless otherwise specified with -f.

The circuit will have inputs and outputs at the top in the order in which they were written in the code. Clock pulses are required to be exactly one tick high. (since adding edge detectors would produce a lot of overhead)

Examples

samples/counter.v

module counter(input clk, input rst, input inc, output reg [3:0] cnt);
  always @(posedge clk) begin
    if (rst)
      cnt <= 0;
    else if (inc)
      cnt <= cnt + 1'b1;
  end
endmodule

image

At the top in order clk, rst, inc and cnt.

6502 CPU from https://github.com/Arlet/verilog-6502/

using the new layout method "chunkAnnealing" image

Extension points exported contracts — how you extend this code

Signal (Interface)
(no doc)
test/simulator.ts
IDict (Interface)
(no doc)
src/yosys.ts
Logger (Interface)
(no doc)
src/logger.ts
ConnectionData (Interface)
(no doc)
src/blueprint.ts
El (Interface)
(no doc)
src/layout/netMatrix.ts
MergeEl (Interface)
(no doc)
src/nodes/MergeNode.ts
DeciderControlBehavior (Interface)
(no doc)
src/entities/Decider.ts
SimEnd (Interface)
(no doc)
test/simulator.ts

Core symbols most depended-on inside this repo

makeConnection
called by 102
src/entities/Entity.ts
assert
called by 90
src/logger.ts
output
called by 50
src/nodes/Mem.ts
getInputNode
called by 38
src/parser.ts
add
called by 32
src/optimization/groups.ts
delete
called by 29
src/nets.ts
log
called by 26
src/logger.ts
getValue
called by 23
test/simulator.ts

Shape

Method 173
Function 113
Class 83
Interface 47
Enum 3

Languages

TypeScript100%

Modules by API surface

test/simulator.ts50 symbols
src/optimization/groups.ts27 symbols
src/layout/annealing.ts23 symbols
src/yosys.ts22 symbols
src/blueprint.ts15 symbols
src/nets.ts14 symbols
src/entities/Entity.ts14 symbols
src/nodes/Mem.ts12 symbols
test/tests/gates.ts10 symbols
src/layout/chunkAnnealing.ts10 symbols
src/entities/Decider.ts10 symbols
src/entities/Constant.ts10 symbols

For agents

$ claude mcp add verilog2factorio \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page