Skip to content

Commit e57f96d

Browse files
authored
Merge pull request #43 from GaloisInc/develop
Task 1 deliverable release into main
2 parents 65c7955 + 7cadaa7 commit e57f96d

File tree

77 files changed

+12477
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+12477
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*/#*#
2+
*/.*

.project

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>hardens</name>
4+
<comment></comment>
5+
<projects>
6+
<project>sysml.library</project>
7+
</projects>
8+
<buildSpec>
9+
<buildCommand>
10+
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
11+
<arguments>
12+
</arguments>
13+
</buildCommand>
14+
</buildSpec>
15+
<natures>
16+
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
17+
</natures>
18+
</projectDescription>

Dockerfile

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
FROM ubuntu:21.04
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
5+
RUN apt-get update && apt-get upgrade
6+
RUN apt-get install -y wget git vim python pip\
7+
python3-dev software-properties-common \
8+
iproute2 usbutils srecord
9+
10+
# Yosys
11+
RUN apt-get install -y build-essential clang bison flex \
12+
libreadline-dev gawk tcl-dev libffi-dev git \
13+
graphviz xdot pkg-config python3 libboost-system-dev \
14+
libboost-python-dev libboost-filesystem-dev zlib1g-dev
15+
RUN git clone https://github.com/YosysHQ/yosys.git /tools/yosys
16+
WORKDIR /tools/yosys
17+
RUN make -j$(nproc)
18+
RUN make install PREFIX=/opt
19+
20+
# Trellis
21+
RUN apt-get install -y libboost-all-dev python3 python3-pip \
22+
cmake openocd
23+
RUN git clone --recursive https://github.com/SymbiFlow/prjtrellis /tools/prjtrellis
24+
WORKDIR /tools/prjtrellis/libtrellis
25+
RUN cmake -DCMAKE_INSTALL_PREFIX=/opt .
26+
RUN make -j$(nproc)
27+
RUN make install
28+
ENV TRELLIS="/opt/share/trellis"
29+
30+
# nextpnr
31+
RUN apt-get install -y python3-dev libboost-all-dev \
32+
libeigen3-dev qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools
33+
RUN git clone https://github.com/YosysHQ/nextpnr.git /tools/nextpnr
34+
WORKDIR /tools/nextpnr
35+
RUN cmake . -DARCH=ecp5 -DTRELLIS_INSTALL_PREFIX=/opt
36+
RUN make -j$(nproc)
37+
RUN make install
38+
39+
# RISCV toolchain
40+
RUN apt-get install -y autoconf automake autotools-dev curl libmpc-dev \
41+
libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf \
42+
libtool patchutils bc zlib1g-dev libexpat-dev
43+
RUN git clone --recursive https://github.com/riscv/riscv-gnu-toolchain /tools/riscv-gnu-toolchain
44+
WORKDIR /tools/riscv-gnu-toolchain
45+
RUN ./configure --prefix=/opt/riscv --enable-multilib
46+
RUN export MAKEFLAGS="-j$(nproc)"
47+
RUN make
48+
RUN make linux
49+
ENV PATH="/opt/riscv/bin:/opt/bin:${PATH}"
50+
51+
# ecpprog
52+
RUN apt-get install -y libftdi-dev
53+
RUN git clone https://github.com/gregdavill/ecpprog /tools/ecpprog
54+
WORKDIR /tools/ecpprog/ecpprog
55+
RUN make -j$(nproc)
56+
RUN make install
57+
58+
# Iverilog
59+
RUN apt-get install -y iverilog
60+
61+
# Bluespec compiler
62+
RUN apt-get install -y libffi7
63+
WORKDIR /tmp
64+
RUN wget https://github.com/B-Lang-org/bsc/releases/download/2021.07/bsc-2021.07-ubuntu-20.04.tar.gz
65+
RUN tar xvzf bsc-2021.07-ubuntu-20.04.tar.gz
66+
RUN mv bsc-2021.07-ubuntu-20.04 /tools/bsc-2021.07-ubuntu-20.04
67+
ENV PATH="/tools/bsc-2021.07-ubuntu-20.04/bin:${PATH}"
68+
69+
# Verilator
70+
RUN apt-get install -y verilator
71+
72+
# OpenFPGAloader
73+
RUN apt-get install -y libftdi1-2 libftdi1-dev libhidapi-libusb0 libhidapi-dev libudev-dev cmake pkg-config make g++
74+
RUN git clone https://github.com/trabucayre/openFPGALoader.git /tools/openFPGALoader
75+
WORKDIR /tools/openFPGALoader
76+
RUN mkdir build
77+
WORKDIR /tools/openFPGALoader/build
78+
RUN cmake ../
79+
RUN cmake --build .
80+
RUN make install
81+
#WORKDIR /tools/openFPGALoader
82+
#RUN cp 99-openfpgaloader.rules /etc/udev/rules.d/
83+
#RUN udevadm control --reload-rules && sudo udevadm trigger # force udev to take new rule
84+
#RUN usermod -a $USER -G plugdev # add user to plugdev group
85+
86+
WORKDIR /

README.md

+171
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,174 @@
11
# HARDENS
22

3+
## Copyright (C) Galois 2021
4+
## Principal Investigator: Joe Kiniry <[email protected]>
5+
## Project Lead: Andrew Bivin <[email protected]>
6+
## Research Engineers: Alexander Bakst <[email protected]> and Michal Podhradsky <[email protected]>
7+
38
Repository for the HARDENS project for the [Nuclear Regulatory Commission](https://www.nrc.gov/about-nrc.html).
9+
10+
## Overview
11+
12+
The goal of HARDENS is to provide to the NRC expert technical services
13+
in order to (1) develop a better understanding of how Model-Based
14+
Systems Engineering (MBSE) methods and tools can support regulatory
15+
reviews of adequate design and design assurance, and (2) identify any
16+
barriers or gaps associated with MBSE in a regulatory review of
17+
Digital Instrumentation and Control Systems for existing Nuclear Power
18+
Plants (NPPs).
19+
20+
In the HARDENS project Galois will demonstrate to the Nuclear
21+
Regulatory Commission (NRC) cutting- edge capabilities in the
22+
model-based design, validation, and verification of safety-critical,
23+
mission-critical, high-assurance systems. Our demonstrator includes
24+
high-assurance software and hardware, includes open source RISC-V
25+
Central Processing Units (CPUs), and lays the groundwork for a
26+
high-assurance reusable product for safety critical Digital
27+
Instrumentation and Control Systems systems in NPPs.
28+
29+
Details about the HARDENS project are found in our
30+
[original proposal](docs/HARDENS.pdf), which was written in response
31+
to the [original NRC RFP](docs/RFP.pdf).
32+
33+
This document summarizes the current state of affairs of the project
34+
and demonstrator.
35+
36+
## Task 1: Implementation
37+
38+
As described in our proposal and the project Statement of Work, in
39+
Task 1 (Implementation), the first task of the HARDENS project, Galois
40+
will implement the system described above using both (1) highly
41+
integrated computer-based engineering development processes and (2)
42+
model-based systems engineering. All the modules of the simple
43+
protection system will be modeled functionally, and one FPGA-based
44+
circuit card will be modeled/designed in detail. The deliverable will
45+
be the model-based design itself. We will use Galois’s RDE process and
46+
methodology to achieve this goal, as well as the V&V in Task 2.
47+
48+
All project models---the SysMLv2 model, the executable, rigorously
49+
validated and formally verified Cryptol model, and the semi-formal and
50+
formal requirements model---are included in this release and are found
51+
in the `develop` branch of the repository.
52+
53+
Also, the initial implementation of the system which runs as an
54+
application on a POSIX host (e.g., a Linux or macOS development
55+
machine or in the HARDENS Docker image) is found in the
56+
as-of-yet-unmerged `c-impl` branch in the HARDENS repository. That
57+
implementation includes both hand-written C code conforming to the
58+
model-based specifications discussed above, as well as automatically
59+
synthesized formally verified sub-components, as described in the
60+
HARDENS proposal, for a small handful of critical sub-components.
61+
These synthesized components are generated in formally verified C
62+
source code and in the System Verilog HDL. The POSIX-based simulation
63+
can execute both the generated C components and the generated System Verilog
64+
components by means of a shim library wrapping the Verilated components.
65+
66+
Finally, we have a formally verified RISC-V CPU, called the `nerv`
67+
CPU, built and tested on the ECP5-5G board. We have sketched out
68+
an initial three core SoC design using Bluespec SystemVerilog, but
69+
have not yet built that SoC for emulation or put it on the FGPA. We
70+
will accomplish such early in Task 2, and cross-compile our POSIX C
71+
implementation to that SoC. That ongoing work is found in the `nerv`
72+
branch of the repository.
73+
74+
## Repository Structure
75+
76+
The repository is structured as follows:
77+
78+
- [specs](./specs) contains a domain model (`*.lando`, `*.lobot`), requirements
79+
(exported from `FRET` to `RTS_requirements.json`), and a specification of the RTS architecture
80+
(`*.sysml`).
81+
- [models](./models) contains the executable Cryptol model
82+
- [assets](./assets) and [docs](./docs) contain project and device documentation
83+
84+
## Submodules
85+
86+
This repository does not currently use any submodules. If/when it
87+
does, initialize with:
88+
89+
```
90+
$ git submodule init
91+
$ git submodule update --recursive
92+
```
93+
94+
## Docker
95+
96+
A Docker container has been built to make for easier use, evaluation,
97+
reusability, and repeatibility of project results. We are adding
98+
tools to this container as necessary during project execution.
99+
100+
### HARDENS Container
101+
102+
To build and run the core HARDENS Docker image, use the `build` and
103+
`run` commands.
104+
105+
```
106+
$ docker build -t hardens:latest .
107+
$ docker run --network host --privileged -v $PWD:/HARDENS -it hardens:latest
108+
```
109+
110+
In order to run a long-lived Docker container for reuse, use a `docker
111+
run` command like the following, ensuring that you are in the right
112+
directory in order to bind your sandbox properly into the container.
113+
114+
```
115+
$ docker run -d -it --name HARDENS --network host --privileged -v $PWD:/HARDENS hardens:latest
116+
```
117+
118+
After running such a detacted container, attach to it for interactive
119+
use by running a command like:
120+
```
121+
$ docker exec -it HARDENS bash -l
122+
```
123+
124+
### SysMLv2 Container
125+
126+
To pull and use the pre-build SysMLv2 container, use the following
127+
`pull` command to pull the container from DockerHub. See
128+
https://hub.docker.com/r/gorenje/sysmlv2-jupyter for details.
129+
130+
```
131+
$ docker pull gorenje/sysmlv2-jupyter:latest
132+
$ docker run -d -it --name SysMLv2 --network host -v $PWD:/HARDENS gorenje/sysmlv2-jupyter:latest
133+
```
134+
135+
## Lattice ECP5 evaluation board
136+
137+
We are using an ECP5-5G FPGA board for the RTS demonstrator.
138+
139+
Details [here](https://www.latticesemi.com/products/developmentboardsandkits/ecp5evaluationboard#_C694C444BC684AD48A3ED64C227B6455). The board uses ECP5-5G FPGA ([LFE5UM5G-85F-8BG381](https://www.latticesemi.com/en/Products/FPGAandCPLD/ECP5)) which has:
140+
141+
- 84k LUTs
142+
- On-board Boot Flash – 128 Mbit Serial Peripheral Interface (SPI) Flash, with Quad read featu
143+
- 8 input DIP switches, 3 push buttons and 8 LEDs for demo purposes
144+
145+
![ECP_board](assets/ecp5_top.png)
146+
147+
### GPIO headers
148+
149+
Headers are: J5, J8, J32, J33 and Max I_OUT for 3V3 is 1.35A
150+
151+
J5 Pinout:
152+
153+
* 1, 2 - VCCIO2 (Sensor 1 VIN, Sensor 2 VIN)
154+
* 3, 4 - H20, G19 (Sensor 1 I2C)
155+
* 5, 6 - GND (Sensor 1 GND, Sensor 2 GND)
156+
* 7, 8 - K18, J18 (Sensor 2 I2C)
157+
158+
### LEDs:
159+
160+
![ECP_LED](assets/ecp5_leds.png)
161+
162+
### Switches
163+
164+
![ECP_DIP](assets/ecp5_dip.png)
165+
166+
### Buttons
167+
168+
General purpose button `SW4` is connected to `P4`
169+
170+
## Sensors/Actuators
171+
172+
* MOSFET power control kit: https://www.sparkfun.com/products/12959
173+
* 12 V Latch solenoid: https://www.sparkfun.com/products/15324
174+
* Pressure sensor: https://www.sparkfun.com/products/11084

Toolchain.md

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Toolchain
2+
3+
Internal documentation explaining different pieces of the toolchain.
4+
5+
Note that [this page](https://craigjb.com/2020/01/22/ecp5/#appendix---installing-the-symbiflow-tools) was very helpful for setting up the toolchains.
6+
7+
## Symbiflow
8+
9+
- https://symbiflow.readthedocs.io/en/latest/
10+
- https://github.com/SymbiFlow/symbiflow-arch-defs
11+
12+
Symbiflow claims to be an umbrella tool encapsulating all the elements of Electronic Design Automation ([EDA](https://en.wikipedia.org/wiki/Electronic_design_automation)) workflow:
13+
14+
![eda](assets/symbiflow_eda.svg)
15+
16+
Specifically we are talking about the following tools:
17+
18+
![tools](assets/symbiflow_parts.svg)
19+
20+
Interestingly, Symbiflow claims to support Lattice ECP5 board, but doesn't provide any examples so the usability of Symbiflow proper is questionable.
21+
A brief google search also indicates that for ECP5 a combination of Yosys+Prjtrellis is used, not Symbiflow.
22+
23+
## Yosys
24+
25+
- https://github.com/YosysHQ/yosys
26+
27+
Yosys is tool suite that contains a Verilog synthesis tool. The way I understand it is that it reads multiple Verilog files, does some optimizations, and returns a single Verilog file that can be then used to generate a bitstream.
28+
29+
## Project Trellis
30+
31+
- https://github.com/YosysHQ/prjtrellis
32+
33+
Project Trellis enables a fully open-source flow for ECP5 FPGAs using *Yosys* for Verilog synthesis and *nextpnr* for place and route. Project Trellis itself provides the device database and tools for bitstream creation.
34+
35+
## nextpnr
36+
37+
- https://github.com/YosysHQ/nextpnr
38+
39+
nextpnr portable FPGA place and route tool.
40+
41+
## ecpprog
42+
43+
- https://github.com/gregdavill/ecpprog
44+
45+
For programming the flash memory of ECP5.
46+
47+
## Icarus Verilog
48+
49+
- http://iverilog.icarus.com/
50+
51+
Stricter Verilog parser than Yosys, used by the *icicle* project for validation.
52+
53+
## Other tools
54+
55+
### Migen, Litex
56+
57+
- https://github.com/m-labs/migen
58+
- https://github.com/litex-hub
59+
60+
High level tools for designing hardware. *Migen* lets you create hardware in Python.
61+
62+
### Older prebuilt ECP5 toolchain
63+
64+
- https://github.com/xobs/ecp5-toolchain
65+
66+
For reference only.
67+
68+
### icicle
69+
70+
- https://github.com/grahamedgecombe/icicle
71+
72+
32-bit RISC-V system on chip for iCE40 and ECP5 FPGAs, has instructions for a build using Symbiflow/Yosys.
73+
74+
```
75+
$ git clone https://github.com/grahamedgecombe/icicle
76+
$ cd icicle
77+
$ make BOARD=ecp5-evn syntax
78+
$ make BOARD=ecp5-evn
79+
```

assets/ecp5_dip.png

119 KB
Loading

assets/ecp5_leds.png

226 KB
Loading

assets/ecp5_top.png

2.16 MB
Loading

assets/symbiflow_eda.svg

+1
Loading

assets/symbiflow_parts.svg

+1
Loading
Loading
Loading
Loading
Binary file not shown.
Binary file not shown.
Binary file not shown.

docs/ECP-5/docs/107439.pdf

569 KB
Binary file not shown.
887 KB
Binary file not shown.

0 commit comments

Comments
 (0)