Skip to content

Commit

Permalink
Merge pull request #28 from imuguruza/alhambra_II
Browse files Browse the repository at this point in the history
Add Alhambra II support to tutorials
  • Loading branch information
Obijuan committed Apr 15, 2020
2 parents dcc138c + 61feb80 commit b138902
Show file tree
Hide file tree
Showing 697 changed files with 2,297,582 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -4,3 +4,5 @@
*.bin
*.blif
*.txt
*.asc
*.json
24 changes: 24 additions & 0 deletions tutorial/Alhambra_II/Readme.md
@@ -0,0 +1,24 @@
# README

Tutorial ports to [Alhambra II board](https://alhambrabits.com/alhambra/). Now using [nextpnr](https://github.com/YosysHQ/nextpnr) instead of `arachne`.

## Requisites

Apart from the tools described in the tutorials, you need to install `nextpnr`. Steps:

Install the dependencies:

```bash
$ sudo apt install python3-dev
$ sudo apt install libboost-dev libboost-filesystem-dev libboost-thread-dev libboost-program-options-dev libboost-python-dev libboost-iostreams-dev libboost-dev
$ sudo apt install libeigen3-dev
$ sudo apt install qt5-default
```

Now compile & install `nextpnr`:

```bash
$ cmake -DARCH=ice40 .
$ make -j$(nproc)
$ sudo make install
```
68 changes: 68 additions & 0 deletions tutorial/Alhambra_II/T01-setbit/Makefile
@@ -0,0 +1,68 @@
#-------------------------------------------------------
#-- Objetivo por defecto: hacer simulacion y sintesis
#-------------------------------------------------------
all: sim sint

#----------------------------------------------
#-- make sim
#----------------------------------------------
#-- Objetivo para hacer la simulacion del
#-- banco de pruebas
#----------------------------------------------
sim: setbit_tb.vcd

#-----------------------------------------------
#- make sint
#-----------------------------------------------
#- Objetivo para realizar la sintetis completa
#- y dejar el diseno listo para su grabacion en
#- la FPGA
#-----------------------------------------------
sint: setbit.bin

#-------------------------------
#-- Compilacion y simulacion
#-------------------------------
setbit_tb.vcd: setbit.v setbit_tb.v

#-- Compilar
iverilog -o setbit_tb.out setbit.v setbit_tb.v

#-- Simular
./setbit_tb.out

#-- Ver visualmente la simulacion con gtkwave
gtkwave setbit_tb.vcd setbit_tb.gtkw &

#------------------------------
#-- Sintesis completa
#------------------------------
setbit.bin: setbit.v setbit.pcf

#-- Sintesis
#OLD
#yosys -p "synth_ice40 -blif setbit.blif" setbit.v
yosys -p 'synth_ice40 -top setbit -json setbit.json' setbit.v

#-- Place & route
#OLD
#arachne-pnr -d 8k -P tq144:4k -p setbit.pcf setbit.blif -o setbit.txt
#NEW - use nextpnr
nextpnr-ice40 --hx8k --package tq144:4k --json setbit.json --pcf setbit.pcf --asc setbit.asc

#-- Generar binario final, listo para descargar en fgpa
#OLD
#icepack setbit.txt setbit.bin
icepack setbit.asc setbit.bin

#------------------------------
#-- Upload the bitsream to board
#------------------------------
flash:
iceprog -d i:0x0403:0x6010:0 setbit.bin

#-- Limpiar todo
clean:
rm -f *.bin *.asc *.json *.out *.vcd *~

.PHONY: all clean
23 changes: 23 additions & 0 deletions tutorial/Alhambra_II/T01-setbit/Readme.md
@@ -0,0 +1,23 @@
## Descripción
Componente "hola mundo" con un pin de salida que siempre está a '1'.
Al cargarlo en la Alhambra II se enciende el led D0

## Simulación

Para realizar la simulacion entrar en el directorio y ejecutar:

`$ make sim`

Automaticamente se invocará al icarus verilog para hacer la compilacion / simulación y al gtkwave para ver el resultado de la simulacion gráficamente

## Síntesis

Para implementar el diseño en la FPGA ejecutamos el comando:

`$ make sint`

Se nos genera el fichero setbit.bin que contiene la conguración de la FPGA para que se nos implemente nuestro circuito digital.

Lo descargamos en la fpga mediante el comando:

`$ make flash`
3 changes: 3 additions & 0 deletions tutorial/Alhambra_II/T01-setbit/bitstreams/Readme.md
@@ -0,0 +1,3 @@
Bitstreams ya generados listos para cargar en la fpga
(para hacer pruebas sin tener que sintetizar)

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
141 changes: 141 additions & 0 deletions tutorial/Alhambra_II/T01-setbit/images/setbit-1.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b138902

Please sign in to comment.