Skip to content

Commit 271b4f6

Browse files
committed
* created a new folder structure that will allow multiple prototyping boards
* added first example for the HX8K board * created makefile to support both types of boards * suggested a new method to support automatic compilation via the Makefile * suggested new way to call folders so that they support automatic compilation * improved the first example for the HX8K to support all outputs
1 parent 7128323 commit 271b4f6

File tree

754 files changed

+1158
-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.

754 files changed

+1158
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#-----------------------------------------------------------------------------
2+
#- (C) D. Cuartielles for Arduino, December 2015
3+
#- GPLv3 License
4+
#- based on previous work by Obijuan for BQ
5+
#-----------------------------------------------------------------------------
6+
#-- Este Makefile soporta las arquitecturas de 1K y 8K de Lattice
7+
#-- se basa en la idea de que los ficheros estaran contenidos en una
8+
#-- carpeta que se llamara como el programa a ejecutar (al igual que se
9+
#-- hace en Arduino o Processing), de modo que el Makefile consultara
10+
#-- el nombre de la carpeta para lanzar la compilacion
11+
#--
12+
#-- Ejemplos:
13+
#-- make sint --> compila para el procesador de 1K
14+
#-- make sint MEMORY=8k --> compila para el procesador de 8K
15+
#-- make sint FILE=blabla --> compila el fichero blabla.v con blabla.pcf
16+
#-----------------------------------------------------------------------------
17+
18+
#-------------------------------------------------------
19+
#-- Declaracion de variables por defecto
20+
#-- usamos el nombre de la carpeta como nombre del programa
21+
#-- tal y como se hace en Arduino y Processing, de modo
22+
#-- que se simplifique la forma de llamar al Makefile
23+
#--
24+
#-- por defecto compila para el procesador de 1K de memoria
25+
#-------------------------------------------------------
26+
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
27+
CURRENT_DIR := $(notdir $(patsubst %/,%,$(dir $(MKFILE_PATH))))
28+
FILE = $(CURRENT_DIR)
29+
MEMORY = "1k"
30+
31+
#-------------------------------------------------------
32+
#-- Objetivo por defecto: hacer simulacion y sintesis
33+
#-------------------------------------------------------
34+
all: sim sint
35+
36+
#----------------------------------------------
37+
#-- make sim
38+
#----------------------------------------------
39+
#-- Objetivo para hacer la simulacion del
40+
#-- banco de pruebas
41+
#----------------------------------------------
42+
sim: $(FILE)_tb.vcd
43+
44+
#-----------------------------------------------
45+
#- make sint
46+
#-----------------------------------------------
47+
#- Objetivo para realizar la sintetis completa
48+
#- y dejar el diseno listo para su grabacion en
49+
#- la FPGA
50+
#-----------------------------------------------
51+
sint: $(FILE).bin
52+
53+
#-------------------------------
54+
#-- Compilacion y simulacion
55+
#-------------------------------
56+
$(FILE)_tb.vcd: $(FILE).v $(FILE)_tb.v
57+
58+
#-- Compilar
59+
iverilog $(FILE).v $(FILE)_tb.v -o $(FILE)_tb.out
60+
61+
#-- Simular
62+
./$(FILE)_tb.out
63+
64+
#-- Ver visualmente la simulacion con gtkwave
65+
gtkwave $(FILE)_tb.vcd $(FILE)_tb.gtkw &
66+
67+
#------------------------------
68+
#-- Sintesis completa
69+
#------------------------------
70+
$(FILE).bin: $(FILE).v $(FILE).pcf
71+
72+
#-- Sintesis
73+
yosys -p "synth_ice40 -blif $(FILE).blif" $(FILE).v
74+
75+
#-- Place & route
76+
arachne-pnr -d $(MEMORY) -p $(FILE).pcf $(FILE).blif -o $(FILE).txt
77+
78+
#-- Generar binario final, listo para descargar en fgpa
79+
icepack $(FILE).txt $(FILE).bin
80+
81+
82+
#-- Limpiar todo
83+
clean:
84+
rm -f *.bin *.txt *.blif *.out *.vcd *~
85+
86+
.PHONY: all clean
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Descripción
2+
Componente "hola mundo" con un pin de salida que siempre está a '1'.
3+
Al cargarlo en la iCE40-HX8K se enciende el led LED1
4+
5+
## Simulación
6+
7+
Para realizar la simulacion entrar en el directorio y ejecutar:
8+
9+
$ make sim
10+
11+
Automaticamente se invocará al icarus verilog para hacer la compilacion / simulación y al gtkwave para ver el resultado de la simulacion gráficamente
12+
13+
## Síntesis
14+
15+
Para implementar el diseño en la FPGA ejecutamos el comando:
16+
17+
$ make sint MEMORY=8k
18+
19+
Se nos genera el fichero T01-setbit.bin que contiene la conguración de la FPGA para que se nos implemente nuestro circuito digital.
20+
21+
Lo descargamos en la fpga mediante el comando:
22+
23+
sudo iceprog T01-setbit.bin
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# ##############################################################################
2+
# iCEcube PCF
3+
# Version: 2012.09SP1.22498
4+
# File Generated: Sep 14 2013 17:36:59
5+
# Tested by: D. Cuartielles
6+
# Latest test: Dec 25 2015
7+
# Family & Device: iCE40HX8K
8+
# Package: CT256
9+
# ##############################################################################
10+
11+
set_io LED1 B5
12+
set_io LED2 B4
13+
set_io LED3 A2
14+
set_io LED4 A1
15+
set_io LED5 C5
16+
set_io LED6 C4
17+
set_io LED7 B3
18+
set_io LED8 C3
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//-----------------------------------------------------------------------------
2+
// setbit.v
3+
//-----------------------------------------------------------------------------
4+
//- (C) D. Cuartielles for Arduino, December 2015
5+
//- GPLv3 License
6+
//- based on previous work by Obijuan for BQ
7+
//-----------------------------------------------------------------------------
8+
//-- Componente "hola mundo" que simplemente pone a '1' su salida
9+
//-- Es el ejemplo mas sencillo que se puede sintetizar en
10+
//-- la fpga. Su principal utilidad es comprobar que toda la cadena de
11+
//-- compilacion/sintesis/simulacion funciona correctamente
12+
//-----------------------------------------------------------------------------
13+
14+
//-----------------------------------------------------------------------------
15+
//-- Modulo setbit
16+
//--
17+
//-- Definimos nuestro componente como un modulo que tiene solo una salida, que
18+
//-- denominamos LED1. Este pin esta cableado a '1'
19+
//-- para evitar que las otras salidas queden a nivel de voltaje incierto, hay
20+
//-- que declararlas y asignarles una salida a nivel '0'
21+
//-----------------------------------------------------------------------------
22+
module setbit(
23+
output LED1,
24+
output LED2,
25+
output LED3,
26+
output LED4,
27+
output LED5,
28+
output LED6,
29+
output LED7,
30+
output LED8
31+
);
32+
33+
wire LED1;
34+
wire LED2;
35+
wire LED3;
36+
wire LED4;
37+
wire LED5;
38+
wire LED6;
39+
wire LED7;
40+
wire LED8;
41+
42+
//-- Implementacion: el pin deseado esta cableado a '1'
43+
// los demas estan cableados a '0'
44+
assign LED1 = 1;
45+
assign LED2 = 0;
46+
assign LED3 = 0;
47+
assign LED4 = 0;
48+
assign LED5 = 0;
49+
assign LED6 = 0;
50+
assign LED7 = 0;
51+
assign LED8 = 0;
52+
53+
endmodule
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[*]
2+
[*] GTKWave Analyzer v3.3.58 (w)1999-2014 BSI
3+
[*] Thu Dec 31 00:38:23 2015
4+
[*]
5+
[dumpfile] "/home/david/Dropbox/UbuntuOne/GITHUB/FPGA/open-fpga-verilog-tutorial/tutorial/ICE40-HX8K_Breakout_Board/T01-setbit/T01-setbit_tb.vcd"
6+
[dumpfile_mtime] "Thu Dec 31 00:37:59 2015"
7+
[dumpfile_size] 450
8+
[savefile] "/home/david/Dropbox/UbuntuOne/GITHUB/FPGA/open-fpga-verilog-tutorial/tutorial/ICE40-HX8K_Breakout_Board/T01-setbit/T01-setbit_tb.gtkw"
9+
[timestart] 0
10+
[size] 1000 600
11+
[pos] -1 -1
12+
*-2.672039 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
13+
[treeopen] setbit_tb.
14+
[sst_width] 225
15+
[signals_width] 78
16+
[sst_expanded] 1
17+
[sst_vpaned_height] 160
18+
@28
19+
setbit_tb.SB1.LED1
20+
setbit_tb.SB1.LED2
21+
[pattern_trace] 1
22+
[pattern_trace] 0
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//-----------------------------------------------------------------------------
2+
//-- Banco de prueba para setbit
3+
//-- (c) BQ August 2015
4+
//-- Written by Juan Gonzalez (obijuan)
5+
//-- mods by D. Cuartielles for Arduino, 2015 December, GPLv3
6+
//-----------------------------------------------------------------------------
7+
//-- Para la simulacion del componente es necesario hacer un banco de pruebas
8+
//-- que coloque el componente, asigne valor a las entradas y compruebe las
9+
//-- salidas. En el caso del compoente setbit, es muy sencillo. Solo tiene
10+
//-- una salida, así que colocamos un cable a su salida y comprobamos que
11+
//-- efectivamente se encuentra a valor 1
12+
//-----------------------------------------------------------------------------
13+
14+
//-- Modulo para el test bench
15+
module setbit_tb;
16+
17+
//-- Cable para conectar al componente que pone
18+
//-- el bit a uno
19+
wire LED1;
20+
21+
//--Instanciar el componente. Conectado al cable A
22+
setbit SB1 (
23+
.LED1 (LED1)
24+
);
25+
26+
//-- Comenzamos las pruebas
27+
initial begin
28+
29+
//-- Definir el fichero donde volvar los datos
30+
//-- para ver graficamente la salida
31+
$dumpfile("T01-setbit_tb.vcd");
32+
33+
//-- Volcar todos los datos a ese fichero
34+
$dumpvars(0, setbit_tb);
35+
36+
//-- Pasadas 10 unidades de tiempo comprobamos
37+
//-- si el cable esta a 1
38+
//-- En caso de no estar a 1, se informa del problema, pero la
39+
//-- simulacion no se detiene
40+
# 10 if (LED1 != 1)
41+
$display("---->¡ERROR! Salida no esta a 1");
42+
else
43+
$display("Componente ok!");
44+
45+
//-- Terminar la simulacion 10 unidades de tiempo
46+
//-- despues
47+
# 10 $finish;
48+
end
49+
50+
51+
endmodule
File renamed without changes.
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#IMPORTANTE
2+
3+
Estas imágenes han de ser actualizadas para la placa HX8K, actualmente son para el ICESTICK

0 commit comments

Comments
 (0)