Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,14 @@ Advanced capabilities include:


## Getting Started
See the [setup documentation](setup.md), then work through building a mechanical keyboard (including subcircuit layout replication) in the [getting started tutorial](getting-started.md).

**Setup tl;dr**: install from pip, published as `edg`: `pip install edg`.
You will need a Java 11+ JRE / JDK, to run the Scala-based core compiler.
```
pip install edg
```

On first run, the system will automatically download a compatible Java runtime for the core compiler.

Then, work through building a mechanical keyboard (including subcircuit layout replication) in the [getting started tutorial](getting-started.md).

Also check out the [reference documentation](reference.md) for a concise list of capabilities.

Expand Down
32 changes: 31 additions & 1 deletion edg/core/ScalaCompilerInterface.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from pathlib import Path
from typing import Optional, Any, Type, Iterable, Union, Dict, List, Tuple

import os
import subprocess
import sys
import jdk

from .. import edgir
from .. import edgrpc
Expand Down Expand Up @@ -88,12 +90,40 @@ def get_connected_block_ports(self, link_port: edgir.LocalPath) -> Optional[List
class ScalaCompilerInstance:
kDevRelpath = "../../compiler/target/scala-2.13/edg-compiler-assembly-0.1-SNAPSHOT.jar"
kPrecompiledRelpath = "resources/edg-compiler-precompiled.jar"
kJreVersion = 17
kInstallJrePath = Path.home() / ".edg" / f"jre-{kJreVersion}"

def __init__(self) -> None:
self.process: Optional[Any] = None

def check_started(self) -> None:
if self.process is None:
installed = False
java_bin: Optional[Path] = None
while java_bin is None:
if self.kInstallJrePath.exists():
items = [
item
for item in self.kInstallJrePath.iterdir()
if item.is_dir() and ("jre" in item.name or "jdk" in item.name)
]
if len(items) > 0:
if len(items) != 1:
raise RuntimeError(f"Expected one JRE in {self.kInstallJrePath}, delete extras and re-run.")
java_bin_path = items[0] / "bin"
if not java_bin_path.exists() or not java_bin_path.is_dir():
raise RuntimeError(f"Expected JRE bin folder {java_bin_path} to exist.")
java_exe = "java.exe" if os.name == "nt" else "java"
java_bin = java_bin_path / java_exe

if java_bin is None:
if installed:
raise RuntimeError("Internal error, failed to install JRE")
print("Installing JRE for compiler core...")
self.kInstallJrePath.mkdir(parents=True, exist_ok=True)
jdk.install(str(self.kJreVersion), path=str(self.kInstallJrePath), jre=True)
installed = True

dev_path = os.path.join(os.path.dirname(__file__), self.kDevRelpath)
precompiled_path = os.path.join(os.path.dirname(__file__), self.kPrecompiledRelpath)
if os.path.exists(dev_path):
Expand All @@ -105,7 +135,7 @@ def check_started(self) -> None:
raise ValueError(f"No EDG Compiler JAR found")

self.process = subprocess.Popen(
["java", "-jar", jar_path], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE
[str(java_bin), "-jar", jar_path], stdin=subprocess.PIPE, stdout=subprocess.PIPE
)
Comment on lines 137 to 139

def compile(
Expand Down
11 changes: 8 additions & 3 deletions getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ You can also write custom links and ports, though this will be unnecessary for m


### Setup
Instructions for setting up the IDE and compiler are in the [setup document](setup.md).

The rest of this tutorial requires that you have this `edg` package (available on `pip`) installed.
```
pip install edg
```

On first run, the system will automatically download a compatible Java runtime for the core compiler.

### Reference Document
While this getting started guide is meant to be self-contained, you may also find the [reference document](reference.md) helpful, especially as you build designs outside this tutorial.
Expand All @@ -74,7 +76,10 @@ Specifically, it:
- provides schematic-like graphical edit actions to insert HDL

The graphical edit actions have significant limitations (and probably bugs / unhandled edge cases) compared to the full HDL and are best suited for simple designs or as a learning tool.
**Consider it more of a tech demonstrator and proof-of-concept** but do give it a try.
It sees only minimal maintenance.
**Consider it more of a tech demonstrator and proof-of-concept**.

If you want to try it, see its [README](https://github.com/BerkeleyHCI/edg-ide/blob/main/README.md) for setup instructions.

![Annotated IDE screen](docs/ide/overview.png)

Expand Down
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "edg"
version = "0.5.0"
version = "0.5.1"
description = "Hardware description language for circuit boards"
readme = "README.md"
authors = [{ name = "Ducky", email = "richard.lin@berkeley.edu" }]
Expand All @@ -22,6 +22,7 @@ dependencies = [
"Deprecated==1.2.14",
"typing_extensions >= 4.4.0",
"pydantic == 2.8.2",
"install-jdk == 1.1.0",
]
requires-python = ">=3.9"

Expand All @@ -45,6 +46,10 @@ strict = true

implicit_reexport = true

[[tool.mypy.overrides]]
module = ["jdk"]
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = ["edg.edgir.*", "edg.edgrpc.*"] # generated code
ignore_errors = true
Expand Down
64 changes: 0 additions & 64 deletions setup.md

This file was deleted.