# generated from XKB map hr include common map 0x41a exclam 0x02 shift asciitilde 0x02 altgr dead_tilde 0x02 shift altgr quotedbl 0x03 shift dead_caron 0x03 altgr caron 0x03 shift altgr numbersign 0x04 shift asciicircum 0x04 altgr dead_circumflex 0x04 shift altgr dollar 0x05 shift dead_breve 0x05 altgr breve 0x05 shift altgr percent 0x06 shift degree 0x06 altgr dead_abovering 0x06 shift altgr ampersand 0x07 shift dead_ogonek 0x07 altgr ogonek 0x07 shift altgr slash 0x08 shift grave 0x08 altgr dead_grave 0x08 shift altgr parenleft 0x09 shift dead_abovedot 0x09 altgr abovedot 0x09 shift altgr parenright 0x0a shift dead_acute 0x0a altgr apostrophe 0x0a shift altgr equal 0x0b shift dead_doubleacute 0x0b altgr doubleacute 0x0b shift altgr apostrophe 0x0c question 0x0c shift dead_diaeresis 0x0c altgr diaeresis 0x0c shift altgr plus 0x0d asterisk 0x0d shift dead_cedilla 0x0d altgr cedilla 0x0d shift altgr backslash 0x10 altgr Greek_OMEGA 0x10 shift altgr bar 0x11 altgr Lstroke 0x11 shift altgr EuroSign 0x12 altgr paragraph 0x13 altgr registered 0x13 shift altgr tslash 0x14 altgr Tslash 0x14 shift altgr z 0x15 addupper leftarrow 0x15 altgr yen 0x15 shift altgr downarrow 0x16 altgr uparrow 0x16 shift altgr rightarrow 0x17 altgr idotless 0x17 shift altgr oslash 0x18 altgr Ooblique 0x18 shift altgr thorn 0x19 altgr THORN 0x19 shift altgr scaron 0x1a Scaron 0x1a shift division 0x1a altgr dead_abovering 0x1a shift altgr dstroke 0x1b Dstroke 0x1b shift multiply 0x1b altgr dead_macron 0x1b shift altgr ae 0x1e altgr AE 0x1e shift altgr ssharp 0x1f altgr section 0x1f shift altgr eth 0x20 altgr ETH 0x20 shift altgr bracketleft 0x21 altgr ordfeminine 0x21 shift altgr bracketright 0x22 altgr ENG 0x22 shift altgr hstroke 0x23 altgr Hstroke 0x23 shift altgr lstroke 0x25 altgr ampersand 0x25 shift altgr Lstroke 0x26 altgr ccaron 0x27 Ccaron 0x27 shift dead_acute 0x27 altgr dead_doubleacute 0x27 shift altgr cacute 0x28 Cacute 0x28 shift ssharp 0x28 altgr dead_caron 0x28 shift altgr dead_cedilla 0x29 dead_diaeresis 0x29 shift notsign 0x29 altgr zcaron 0x2b Zcaron 0x2b shift currency 0x2b altgr dead_breve 0x2b shift altgr y 0x2c addupper guillemotleft 0x2c altgr less 0x2c shift altgr guillemotright 0x2d altgr greater 0x2d shift altgr cent 0x2e altgr copyright 0x2e shift altgr at 0x2f altgr grave 0x2f shift altgr braceleft 0x30 altgr apostrophe 0x30 shift altgr braceright 0x31 altgr section 0x32 altgr masculine 0x32 shift altgr comma 0x33 semicolon 0x33 shift horizconnector 0x33 altgr multiply 0x33 shift altgr period 0x34 colon 0x34 shift periodcentered 0x34 altgr division 0x34 shift altgr minus 0x35 underscore 0x35 shift dead_belowdot 0x35 altgr dead_abovedot 0x35 shift altgr >/README.md
blob: 3542da70c9ce854d21d3d0ac11cb08df23a5679f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# MachXO2 Architecture Example
This directory contains a simple example of running `nextpnr-machxo2`:

* `simple.sh` produces nextpnr output in the files `{pack,place,pnr}*.json`,
  as well as pre-pnr and post-pnr diagrams in `{pack,place,pnr}*.{dot, png}`.
* `simtest.sh` extends `simple.sh` by generating `{pack,place,pnr}*.v` from
  `{pack,place,pnr}*.json`. The script calls the [`iverilog`](http://iverilog.icarus.com)
  compiler and `vvp` runtime to compare the behavior of `{pack,place,pnr}*.v`
  and the original Verilog input (using a testbench `*_tb.v`). This is known as
  post-place-and-route simulation.
* `mitertest.sh` is similar to `simtest.sh`, but more comprehensive. This
  script creates a [miter circuit](https://www21.in.tum.de/~lammich/2015_SS_Seminar_SAT/resources/Equivalence_Checking_11_30_08.pdf)
  to compare the output port values of `{pack,place,pnr}*.v` against the
  original Verilog code _when both modules are fed the same values on their input
  ports._

  All possible inputs and resulting outputs can be tested in reasonable time by
  using `yosys`' built-in SAT solver or [`z3`](https://github.com/Z3Prover/z3),
  an external SMT solver.
* `demo.sh` creates bitstreams for [TinyFPGA Ax](https://tinyfpga.com/a-series-guide.html)
  and writes the resulting bitstream to MachXO2's internal flash using
  [`tinyproga`](https://github.com/tinyfpga/TinyFPGA-A-Programmer).

As `nextpnr-machxo2` is developed the contents `simple.sh`, `simtest.sh`,
`mitertest.sh`, and `demo.sh` are subject to change.

## How To Run
Each script requires a prefix that matches one of the self-contained Verilog
examples in this directory. For instance, to create a bitstream from
`tinyfpga.v`, use `demo.sh tinyfpga` (the `*` glob used throughout this file
is filled with the the prefix).

Each of `simple.sh`, `simtest.sh`, and `mitertest.sh` runs yosys and nextpnr
to validate a Verilog design in various ways. They require an additional `mode`
argument- `pack`, `place`, or `pnr`- which stops `nextpnr-machxo2` after the
specified phase and writes out a JSON file of the results in
`{pack,place,pnr}*.json`; `pnr` runs all of the Pack, Place, and Route phases.

`mitertest.sh` requires an third option- `sat` or `smt`- to choose between
verifying the miter with either yosys' built-in SAT solver, or an external
SMT solver.

Each script will exit if it finds an input Verilog example it knows it can't
handle. To keep file count lower, all yosys scripts are written inline inside
the `sh` scripts using the `-p` option.

### Clean
To clean output files from _all_ scripts, run:

```
rm -rf *.dot *.json *.png *.vcd *.smt2 *.log *.txt *.bit {pack,place,pnr}*.v *_simtest*
```

## Known Issues
In principle, `mitertest.sh` should work in `sat` or `smt` mode with all
example Verilog files which don't use the internal oscillator (OSCH) or other
hard IP. However, as of this writing, only `blinky.v` passes correctly for a
few reasons:

  1. The sim models for MachXO2 primitives used by the `gate` module contain
     `initial` values _by design_, as it matches chip behavior. Without any of
     the following in the `gold` module (like `blinky_ext.v` currently):

     * An external reset signal
     * Internal power-on reset signal (e.g. `reg int_rst = 1'd1;`)
     * `initial` values to manually set registers

     the `gold` and `gate` modules will inherently not match.

     Examples using an internal power-on reset (e.g. `uart.v`) also have issues
     that I haven't debugged yet in both `sat` and `smt` mode.
  2. To keep the `gold`/`gate` generation simpler, examples are currently
     assumed to _not_ instantiate MachXO2 simulation primitives directly
    (`FACADE_IO`, `FACADE_FF`, etc).
  3. `synth_machxo2` runs `deminout` on `inouts` when generating the `gate`
     module. This is not handled yet when generating the `gold` module.

## Verilog Examples
* `blinky.v`/`blinky_tb.v`- A blinky example meant for simulation.
* `tinyfpga.v`- Blink the LED on TinyFPA Ax.
* `rgbcount.v`- Blink an RGB LED using TinyFPGA Ax, more closely-based on
  [the TinyFPGA Ax guide](https://tinyfpga.com/a-series-guide.html).
* `blinky_ext.v`- Blink the LED on TinyFPA Ax using an external pin (pin 6).
* `uart.v`- UART loopback demo at 19200 baud. Requires the following pins:

  * Pin 1- RX LED
  * Pin 2- TX (will echo RX)
  * Pin 3- RX
  * Pin 4- TX LED
  * Pin 5- Load LED
  * Pin 6- 12 MHz clock input
  * Pin 7- Take LED
  * Pin 8- Empty LED

## Environment Variables For Scripts
* `YOSYS`- Set to the location of the `yosys` binary to test. Defaults to the
  `yosys` on the path. You may want to set this to a `yosys` binary in your
  source tree if doing development.
* `NEXTPNR`- Set to the location of the `nextpnr-machxo2` binary to test.
  Defaults to the `nextpnr-machxo2` binary at the root of the `nextpnr` source
  tree. This should be set, for instance, if doing an out-of-tree build of
  `nextpnr-machxo2`.
* `CELLS_SIM`- Set to the location of `machxo2/cells_sim.v` simulation models.
  Defaults to whatever `yosys-config` associated with the above `YOSYS` binary
  returns. You may want to set this to `/path/to/yosys/src/share/machxo2/cells_sim.v`
  if doing development; `yosys-config` cannot find these "before-installation"
  simulation models.
* `TRELLIS_DB`- Set to the location of the Project Trellis database to use.
  Defaults to nothing, which means `ecppack` will use whatever database is on
  its path.