aboutsummaryrefslogtreecommitdiffstats
path: root/machxo2/examples
diff options
context:
space:
mode:
Diffstat (limited to 'machxo2/examples')
-rw-r--r--machxo2/examples/README.md21
-rw-r--r--machxo2/examples/blinky.v2
-rw-r--r--machxo2/examples/simple.sh4
-rw-r--r--machxo2/examples/simtest.sh6
4 files changed, 23 insertions, 10 deletions
diff --git a/machxo2/examples/README.md b/machxo2/examples/README.md
index f82da63a..87f50f6d 100644
--- a/machxo2/examples/README.md
+++ b/machxo2/examples/README.md
@@ -10,7 +10,20 @@ This contains a simple example of running `nextpnr-machxo2`:
using the [`iverilog`](http://iverilog.icarus.com) compiler and `vvp`
runtime. This is known as post-place-and-route simulation.
-As `nextpnr-machxo2` is developed the `nextpnr` invocation in `simple.sh` and
-`simtest.sh` is subject to change. Other command invocations, such as `yosys`,
-_should_ remain unchanged, even as files under the [synth](../synth) directory
-change.
+As `nextpnr-machxo2` is developed the contents `simple.sh` and `simtest.sh`
+are subject to change.
+
+## Environment Variables For `simple.sh` And `simtest.sh`
+
+* `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.
diff --git a/machxo2/examples/blinky.v b/machxo2/examples/blinky.v
index 42becb72..c7cde26d 100644
--- a/machxo2/examples/blinky.v
+++ b/machxo2/examples/blinky.v
@@ -1,4 +1,4 @@
-module top(input clk, rst, output reg [7:0] leds);
+module top(input clk, rst, output [7:0] leds);
reg [7:0] ctr;
always @(posedge clk)
diff --git a/machxo2/examples/simple.sh b/machxo2/examples/simple.sh
index 7f973033..9eb06886 100644
--- a/machxo2/examples/simple.sh
+++ b/machxo2/examples/simple.sh
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -ex
-yosys -p "tcl ../synth/synth_machxo2.tcl 4 blinky.json" blinky.v
+${YOSYS:yosys} -p "synth_machxo2 -json blinky.json" blinky.v
${NEXTPNR:-../../nextpnr-machxo2} --json blinky.json --write pnrblinky.json
-yosys -p "read_verilog -lib ../synth/prims.v; read_json pnrblinky.json; dump -o blinky.il; show -format png -prefix blinky"
+${YOSYS:yosys} -p "read_verilog -lib +/machxo2/cells_sim.v; read_json pnrblinky.json; dump -o blinky.il; show -format png -prefix blinky"
diff --git a/machxo2/examples/simtest.sh b/machxo2/examples/simtest.sh
index 5e7d821d..4cb8d5ca 100644
--- a/machxo2/examples/simtest.sh
+++ b/machxo2/examples/simtest.sh
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -ex
-yosys -p "tcl ../synth/synth_machxo2.tcl 4 blinky.json" blinky.v
+${YOSYS:-yosys} -p "synth_machxo2 -json blinky.json" blinky.v
${NEXTPNR:-../../nextpnr-machxo2} --no-iobs --json blinky.json --write pnrblinky.json
-yosys -p "read_json pnrblinky.json; write_verilog -noattr -norename pnrblinky.v"
-iverilog -o blinky_simtest ../synth/prims.v blinky_tb.v pnrblinky.v
+${YOSYS:-yosys} -p "read_json blinky.json; write_verilog -noattr -norename pnrblinky.v"
+iverilog -o blinky_simtest ${CELLS_SIM:-`${YOSYS:yosys}-config --datdir/machxo2/cells_sim.v`} blinky_tb.v pnrblinky.v
vvp -N ./blinky_simtest