diff --git a/examples/lattice_ice40/lattice_ice40-counter/.gitignore b/examples/lattice_ice40/lattice_ice40-counter/.gitignore new file mode 100644 index 0000000000..e90612ed7f --- /dev/null +++ b/examples/lattice_ice40/lattice_ice40-counter/.gitignore @@ -0,0 +1 @@ +.pioenvs \ No newline at end of file diff --git a/examples/lattice_ice40/lattice_ice40-counter/.travis.yml b/examples/lattice_ice40/lattice_ice40-counter/.travis.yml new file mode 100644 index 0000000000..b57f6fa879 --- /dev/null +++ b/examples/lattice_ice40/lattice_ice40-counter/.travis.yml @@ -0,0 +1,65 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < http://docs.platformio.org/en/latest/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < http://docs.platformio.org/en/latest/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < http://docs.platformio.org/en/latest/userguide/cmd_ci.html > +# +# +# Please choice one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to by used as a library with examples +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# +# script: +# - platformio ci --lib="." --board=TYPE_1 --board=TYPE_2 --board=TYPE_N diff --git a/examples/lattice_ice40/lattice_ice40-counter/README.rst b/examples/lattice_ice40/lattice_ice40-counter/README.rst new file mode 100644 index 0000000000..3fe2930ee5 --- /dev/null +++ b/examples/lattice_ice40/lattice_ice40-counter/README.rst @@ -0,0 +1,29 @@ +.. Copyright 2014-2016 Ivan Kravets + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO `_ +2. Download `source code with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platformio-develop/examples/lattice_ice40/lattice_ice40-counter + + # Generate the bitstream + > platformio run + + # Upload the bitstream into the FPGA + > platformio run --target upload diff --git a/examples/lattice_ice40/lattice_ice40-counter/lib/readme.txt b/examples/lattice_ice40/lattice_ice40-counter/lib/readme.txt new file mode 100644 index 0000000000..607a92af17 --- /dev/null +++ b/examples/lattice_ice40/lattice_ice40-counter/lib/readme.txt @@ -0,0 +1,38 @@ + +This directory is intended for the project specific (private) libraries. +PlatformIO will compile them to static libraries and link to executable file. + +The source code of each library should be placed in separate directory, like +"lib/private_lib/[here are source files]". + +For example, see how can be organized `Foo` and `Bar` libraries: + +|--lib +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| |--Foo +| | |- Foo.c +| | |- Foo.h +| |- readme.txt --> THIS FILE +|- platformio.ini +|--src + |- main.c + +Then in `src/main.c` you should use: + +#include +#include + +// rest H/C/CPP code + +PlatformIO will find your libraries automatically, configure preprocessor's +include paths and build them. + +See additional options for PlatformIO Library Dependency Finder `lib_*`: + +http://docs.platformio.org/en/latest/projectconf.html#lib-install + diff --git a/examples/lattice_ice40/lattice_ice40-counter/platformio.ini b/examples/lattice_ice40/lattice_ice40-counter/platformio.ini new file mode 100644 index 0000000000..b2e4917263 --- /dev/null +++ b/examples/lattice_ice40/lattice_ice40-counter/platformio.ini @@ -0,0 +1,23 @@ +# +# Project Configuration File +# +# A detailed documentation with the EXAMPLES is located here: +# http://docs.platformio.org/en/latest/projectconf.html +# + +# A sign `#` at the beginning of the line indicates a comment +# Comment lines are ignored. + +# Simple and base environment +# [env:mybaseenv] +# platform = %INSTALLED_PLATFORM_NAME_HERE% +# framework = +# board = +# +# Automatic targets - enable auto-uploading +# targets = upload + +[env:icestick] +platform = lattice_ice40 +framework = icestorm +board = icestick diff --git a/examples/lattice_ice40/lattice_ice40-counter/src/counter.pcf b/examples/lattice_ice40/lattice_ice40-counter/src/counter.pcf new file mode 100644 index 0000000000..07a73b9cfe --- /dev/null +++ b/examples/lattice_ice40/lattice_ice40-counter/src/counter.pcf @@ -0,0 +1,6 @@ +set_io leds[0] 99 +set_io leds[1] 98 +set_io leds[2] 97 +set_io leds[3] 96 +set_io leds[4] 95 +set_io clk 21 diff --git a/examples/lattice_ice40/lattice_ice40-counter/src/counter.v b/examples/lattice_ice40/lattice_ice40-counter/src/counter.v new file mode 100644 index 0000000000..b7b44ab423 --- /dev/null +++ b/examples/lattice_ice40/lattice_ice40-counter/src/counter.v @@ -0,0 +1,25 @@ +module counter #( + parameter N = 29 //-- Counter bits lentgh + )( + input wire clk, + output wire [4:0] leds +); + +reg [N-1:0] cont; +reg rstn = 0; + +//-- Initialization +always @(posedge clk) + rstn <= 1; + +//-- counter, with synchronous reset +always @(posedge clk) + if (!rstn) + cont <= 0; + else + cont <= cont + 1; + +//-- Connect the 5 most significant bits to the leds +assign leds = cont[N-1: N-6]; + +endmodule diff --git a/examples/lattice_ice40/lattice_ice40-counter/src/counter_tb.gtkw b/examples/lattice_ice40/lattice_ice40-counter/src/counter_tb.gtkw new file mode 100644 index 0000000000..3485174a4f --- /dev/null +++ b/examples/lattice_ice40/lattice_ice40-counter/src/counter_tb.gtkw @@ -0,0 +1,24 @@ +[*] +[*] GTKWave Analyzer v3.3.66 (w)1999-2015 BSI +[*] Sun Jan 31 16:34:34 2016 +[*] +[dumpfile] "/home/obijuan/develop/Platformio-FPGA/examples/lattice_ice40/lattice_ice40_counter/simulation.vcd" +[dumpfile_mtime] "Sun Jan 31 16:33:04 2016" +[dumpfile_size] 9956 +[savefile] "/home/obijuan/develop/Platformio-FPGA/examples/lattice_ice40/lattice_ice40_counter/src/simulation.gtkw" +[timestart] 0 +[size] 1000 600 +[pos] 918 413 +*-8.616491 110 -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 +[treeopen] counter_tb. +[sst_width] 223 +[signals_width] 176 +[sst_expanded] 1 +[sst_vpaned_height] 160 +@28 +counter_tb.clk +counter_tb.CONT0.rstn +@22 +counter_tb.leds[4:0] +[pattern_trace] 1 +[pattern_trace] 0 diff --git a/examples/lattice_ice40/lattice_ice40-counter/src/counter_tb.v b/examples/lattice_ice40/lattice_ice40-counter/src/counter_tb.v new file mode 100644 index 0000000000..6d717d78ba --- /dev/null +++ b/examples/lattice_ice40/lattice_ice40-counter/src/counter_tb.v @@ -0,0 +1,34 @@ +`timescale 100 ns / 10 ns +`default_nettype none + +module counter_tb; + +localparam N = 6; //-- Counter bits length + +reg clk = 0; + +wire [4:0] leds; + +//-- Clock generator +always + # 0.5 clk <= ~clk; + + counter #( + .N(N) + ) CONT0 ( + .clk(clk), + .leds(leds) + ); + +initial begin + + //-- File where to store the simulation + $dumpfile("counter_tb.vcd"); + $dumpvars(0, counter_tb); + + #200 $display("END of the simulation"); + $finish; + end + + +endmodule diff --git a/examples/lattice_ice40/lattice_ice40-leds/.gitignore b/examples/lattice_ice40/lattice_ice40-leds/.gitignore new file mode 100644 index 0000000000..e90612ed7f --- /dev/null +++ b/examples/lattice_ice40/lattice_ice40-leds/.gitignore @@ -0,0 +1 @@ +.pioenvs \ No newline at end of file diff --git a/examples/lattice_ice40/lattice_ice40-leds/.travis.yml b/examples/lattice_ice40/lattice_ice40-leds/.travis.yml new file mode 100644 index 0000000000..93562520a5 --- /dev/null +++ b/examples/lattice_ice40/lattice_ice40-leds/.travis.yml @@ -0,0 +1,65 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < http://docs.platformio.org/en/latest/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < http://docs.platformio.org/en/latest/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < http://docs.platformio.org/en/latest/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to by used as a library with examples +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# +# script: +# - platformio ci --lib="." --board=TYPE_1 --board=TYPE_2 --board=TYPE_N diff --git a/examples/lattice_ice40/lattice_ice40-leds/README.rst b/examples/lattice_ice40/lattice_ice40-leds/README.rst new file mode 100644 index 0000000000..8611f5a3c1 --- /dev/null +++ b/examples/lattice_ice40/lattice_ice40-leds/README.rst @@ -0,0 +1,29 @@ +.. Copyright 2014-2016 Ivan Kravets + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO `_ +2. Download `source code with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platformio-develop/examples/lattice_ice40/lattice_ice40-leds + + # Process example project (bitstream generation) + > platformio run + + # Upload the bitstream into the FPGA + > platformio run --target upload diff --git a/examples/lattice_ice40/lattice_ice40-leds/lib/readme.txt b/examples/lattice_ice40/lattice_ice40-leds/lib/readme.txt new file mode 100644 index 0000000000..607a92af17 --- /dev/null +++ b/examples/lattice_ice40/lattice_ice40-leds/lib/readme.txt @@ -0,0 +1,38 @@ + +This directory is intended for the project specific (private) libraries. +PlatformIO will compile them to static libraries and link to executable file. + +The source code of each library should be placed in separate directory, like +"lib/private_lib/[here are source files]". + +For example, see how can be organized `Foo` and `Bar` libraries: + +|--lib +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| |--Foo +| | |- Foo.c +| | |- Foo.h +| |- readme.txt --> THIS FILE +|- platformio.ini +|--src + |- main.c + +Then in `src/main.c` you should use: + +#include +#include + +// rest H/C/CPP code + +PlatformIO will find your libraries automatically, configure preprocessor's +include paths and build them. + +See additional options for PlatformIO Library Dependency Finder `lib_*`: + +http://docs.platformio.org/en/latest/projectconf.html#lib-install + diff --git a/examples/lattice_ice40/lattice_ice40-leds/platformio.ini b/examples/lattice_ice40/lattice_ice40-leds/platformio.ini new file mode 100644 index 0000000000..b2e4917263 --- /dev/null +++ b/examples/lattice_ice40/lattice_ice40-leds/platformio.ini @@ -0,0 +1,23 @@ +# +# Project Configuration File +# +# A detailed documentation with the EXAMPLES is located here: +# http://docs.platformio.org/en/latest/projectconf.html +# + +# A sign `#` at the beginning of the line indicates a comment +# Comment lines are ignored. + +# Simple and base environment +# [env:mybaseenv] +# platform = %INSTALLED_PLATFORM_NAME_HERE% +# framework = +# board = +# +# Automatic targets - enable auto-uploading +# targets = upload + +[env:icestick] +platform = lattice_ice40 +framework = icestorm +board = icestick diff --git a/examples/lattice_ice40/lattice_ice40-leds/src/leds_on.pcf b/examples/lattice_ice40/lattice_ice40-leds/src/leds_on.pcf new file mode 100644 index 0000000000..80405e59fb --- /dev/null +++ b/examples/lattice_ice40/lattice_ice40-leds/src/leds_on.pcf @@ -0,0 +1,11 @@ +# -- IceZUM Alhambra leds + +set_io LPORT[0] 95 +set_io LPORT[1] 96 +set_io LPORT[2] 97 +set_io LPORT[3] 98 + +set_io LPORT[4] 99 +set_io LPORT[5] 101 +set_io LPORT[6] 102 +set_io LPORT[7] 104 diff --git a/examples/lattice_ice40/lattice_ice40-leds/src/leds_on.v b/examples/lattice_ice40/lattice_ice40-leds/src/leds_on.v new file mode 100644 index 0000000000..4ccea6c71a --- /dev/null +++ b/examples/lattice_ice40/lattice_ice40-leds/src/leds_on.v @@ -0,0 +1,16 @@ +//-------------------------------------------------------------------- +//-- IceZUM Alhambra test +//-- Hello world example +//-- Turn on all the yellow leds +//-------------------------------------------------------------------- +//-- (c) BQ March, 2016. Written by Juan Gonzalez (obijuan) +//-------------------------------------------------------------------- +//-- Releases under the GPL v2+ license +//-------------------------------------------------------------------- + +module leds_on(output wire [7:0] LPORT); + +//-- Turn on all the leds +assign LPORT = 8'hFF; + +endmodule diff --git a/examples/lattice_ice40/lattice_ice40-leds/src/leds_on_tb.gtkw b/examples/lattice_ice40/lattice_ice40-leds/src/leds_on_tb.gtkw new file mode 100644 index 0000000000..99ec7b0cf9 --- /dev/null +++ b/examples/lattice_ice40/lattice_ice40-leds/src/leds_on_tb.gtkw @@ -0,0 +1,23 @@ +[*] +[*] GTKWave Analyzer v3.3.66 (w)1999-2015 BSI +[*] Tue Mar 15 08:22:44 2016 +[*] +[dumpfile] "/home/obijuan/development/icezum/examples/leds/leds_on/src/leds_on_tb.vcd" +[dumpfile_mtime] "Tue Mar 15 08:22:30 2016" +[dumpfile_size] 460 +[savefile] "/home/obijuan/development/icezum/examples/leds/leds_on/src/leds_on_tb.gtkw" +[timestart] 0 +[size] 1000 600 +[pos] -1 -1 +*-8.314166 964 -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 +[treeopen] leds_on_tb. +[sst_width] 223 +[signals_width] 134 +[sst_expanded] 1 +[sst_vpaned_height] 160 +@29 +leds_on_tb.clk +@22 +leds_on_tb.UUT.LPORT[7:0] +[pattern_trace] 1 +[pattern_trace] 0 diff --git a/examples/lattice_ice40/lattice_ice40-leds/src/leds_on_tb.v b/examples/lattice_ice40/lattice_ice40-leds/src/leds_on_tb.v new file mode 100644 index 0000000000..fae27d4167 --- /dev/null +++ b/examples/lattice_ice40/lattice_ice40-leds/src/leds_on_tb.v @@ -0,0 +1,36 @@ +//------------------------------------------------------------------- +//-- leds_on_tb.v +//-- Testbench +//------------------------------------------------------------------- +//-- BQ March 2016. Written by Juan Gonzalez (Obijuan) +//------------------------------------------------------------------- +`default_nettype none +`timescale 100 ns / 10 ns + +module leds_on_tb(); + +//-- Simulation time: 1us (10 * 100ns) +parameter DURATION = 10; + +//-- Clock signal. It is not used in this simulation +reg clk = 0; +always #0.5 clk = ~clk; + +//-- Leds port +wire [7:0] lport; + +//-- Instantiate the unit to test +leds_on UUT (.LPORT(lport)); + + +initial begin + + //-- File were to store the simulation results + $dumpfile("leds_on_tb.vcd"); + $dumpvars(0, leds_on_tb); + + #(DURATION) $display("End of simulation"); + $finish; +end + +endmodule diff --git a/platformio/boards/lattice.json b/platformio/boards/lattice.json new file mode 100644 index 0000000000..977c762f40 --- /dev/null +++ b/platformio/boards/lattice.json @@ -0,0 +1,44 @@ +{ + "icestick": { + "build": { + "core": "icestick", + "f_cpu": "12000000L", + "cpu": "fpga", + "mcu": "ice40hx1k", + "variant": "1k", + "vid": "0x0403", + "pid": "0x6010" + }, + "frameworks": ["icestorm"], + "name": "Lattice iCEstick FPGA Evaluation Kit", + "platform": "lattice_ice40", + "upload": { + "maximum_ram_size": 32768, + "maximum_size": 32768 + }, + "url": "http://www.latticesemi.com/icestick", + "vendor": "Lattice" + }, + + "icezum": { + "build": { + "core": "icezum", + "f_cpu": "12000000L", + "cpu": "fpga", + "mcu": "ice40hx1k", + "variant": "1k", + "vid": "0x0403", + "pid": "0x6010" + }, + "frameworks": ["icestorm"], + "name": "BQ IceZUM Alhambra FPGA", + "platform": "lattice_ice40", + "upload": { + "maximum_ram_size": 32768, + "maximum_size": 32768 + }, + "url": "https://github.com/bqlabs/icezum/wiki", + "vendor": "BQ" + } + +} diff --git a/platformio/builder/scripts/lattice_ice40.py b/platformio/builder/scripts/lattice_ice40.py new file mode 100644 index 0000000000..c9d2017c6e --- /dev/null +++ b/platformio/builder/scripts/lattice_ice40.py @@ -0,0 +1,148 @@ +""" + Build script for lattice ice40 FPGAs + latticeice40-builder.py +""" +import os +from os.path import join +from SCons.Script import (AlwaysBuild, Builder, DefaultEnvironment, Exit, + Environment, Default, Glob, COMMAND_LINE_TARGETS, + GetOption) + +env = DefaultEnvironment() +env.Replace(PROGNAME="hardware") +env.Append(SIMULNAME="simulation") + +# -- Get the local folder in which the icestorm tools should be installed +piopackages_dir = env.subst('$PIOPACKAGES_DIR') +bin_dir = join(piopackages_dir, 'toolchain-icestorm', 'bin') + +# -- Add this path to the PATH env variable. First the building tools will be +# -- searched in the local PATH. If they are not founde, the global ones will +# -- be executed (if installed) +env.PrependENVPath('PATH', bin_dir) + +# -- Target name for synthesis +TARGET = join(env['BUILD_DIR'], env['PROGNAME']) + +# -- Target name for simulation +# TARGET_SIM = join(env['PROJECT_DIR'], env['SIMULNAME']) + +# -- Get a list of all the verilog files in the src folfer, in ASCII, with +# -- the full path. All these files are used for the simulation +v_nodes = Glob(join(env['PROJECTSRC_DIR'], '*.v')) +src_sim = ["{}".format(f) for f in v_nodes] + +# --------- Get the Testbench file (there should be only 1) +# -- Create a list with all the files finished in _tb.v. It should contain +# -- the test bench +list_tb = [f for f in src_sim if f[-5:].upper() == "_TB.V"] + +if len(list_tb) > 1: + print "---> WARNING: More than one testbenches used" + +# -- Error checking +try: + testbench = list_tb[0] + +# -- there is no testbench +except IndexError: + testbench = None + +if 'sim' in COMMAND_LINE_TARGETS: + if testbench is None: + print "ERROR!!! NO testbench found for simulation" + Exit(1) + + # -- Simulation name + testbench_file = os.path.split(testbench)[-1] + SIMULNAME, ext = os.path.splitext(testbench_file) +else: + SIMULNAME = '' + + +TARGET_SIM = join(env.subst('$BUILD_DIR'), SIMULNAME) + +# -------- Get the synthesis files. They are ALL the files except the +# -------- testbench +src_synth = [f for f in src_sim if f not in list_tb] + +# -- For debugging +print "Testbench: {}".format(testbench) + +# -- Get the PCF file +src_dir = env.subst('$PROJECTSRC_DIR') +PCFs = join(src_dir, '*.pcf') +PCF_list = Glob(PCFs) + +try: + PCF = PCF_list[0] +except IndexError: + print "\n--------> ERROR: no .pcf file found <----------\n" + Exit(2) + +# -- Debug +print "----> PCF Found: {}".format(PCF) + +# -- Builder 1 (.v --> .blif) +synth = Builder(action='yosys -p \"synth_ice40 -blif {}.blif\" \ + $SOURCES'.format(TARGET), + suffix='.blif', + src_suffix='.v') + +# -- Builder 2 (.blif --> .asc) +pnr = Builder(action='arachne-pnr -d 1k -o $TARGET -p {} \ + $SOURCE'.format(PCF), + suffix='.asc', + src_suffix='.blif') + +# -- Builder 3 (.asc --> .bin) +bitstream = Builder(action='icepack $SOURCE $TARGET', + suffix='.bin', + src_suffix='.asc') + +# -- Builder 4 (.asc --> .rpt) +time_rpt = Builder(action='icetime -mtr $TARGET $SOURCE', + suffix='.rpt', + src_suffix='.asc') + +env.Append(BUILDERS={'Synth': synth, 'PnR': pnr, 'Bin': bitstream, + 'Time': time_rpt}) + +blif = env.Synth(TARGET, [src_synth]) +asc = env.PnR(TARGET, [blif, PCF]) +binf = env.Bin(TARGET, asc) + +upload = env.Alias('upload', binf, 'iceprog ' + ' $SOURCE') +AlwaysBuild(upload) + +# -- Target for calculating the time (.rpt) +# rpt = env.Time(asc) +t = env.Alias('time', env.Time('time.rpt', asc)) + +# -------------------- Simulation ------------------ +# -- Constructor para generar simulacion: icarus Verilog +iverilog = Builder(action='iverilog -o $TARGET $SOURCES ', + suffix='.out', + src_suffix='.v') + +vcd = Builder(action=' $SOURCE', + suffix='.vcd', src_suffix='.out') + +simenv = Environment(BUILDERS={'IVerilog': iverilog, 'VCD': vcd}, + ENV=os.environ) + +out = simenv.IVerilog(TARGET_SIM, src_sim) +vcd_file = simenv.VCD(SIMULNAME, out) + +waves = simenv.Alias('sim', vcd_file, 'gtkwave ' + + join(env['PROJECT_DIR'], "{} ".format(vcd_file[0])) + + join(env['PROJECTSRC_DIR'], SIMULNAME) + + '.gtkw') +AlwaysBuild(waves) + +Default([binf]) + +# -- These is for cleaning the files generated using the alias targets +if GetOption('clean'): + env.Default([t]) + simenv.Default([out, vcd_file]) diff --git a/platformio/platforms/lattice_ice40.py b/platformio/platforms/lattice_ice40.py new file mode 100644 index 0000000000..4c36366123 --- /dev/null +++ b/platformio/platforms/lattice_ice40.py @@ -0,0 +1,30 @@ +import os +from platformio.platforms.base import BasePlatform + + +class Lattice_ice40Platform(BasePlatform): + """ + The iCE40 family of ultra-low power, non-volatile FPGAs has five devices + with densities ranging from 384 to 7680 Look-Up Tables (LUTs). In addition + to LUT-based,low-cost programmable logic, these devices feature Embedded + Block RAM (EBR), Non-volatile Configuration Memory (NVCM) and Phase Locked + Loops (PLLs). These features allow the devices to be used in low-cost, + high-volume consumer and system applications. + + http://www.latticesemi.com/Products/FPGAandCPLD/iCE40.aspx + """ + + PACKAGES = { + + "toolchain-icestorm": { + + # alias is used for quick access to package. + "alias": "toolchain", + + # Flag which allows PlatformIO to install this package by + # default via `> platformio install test` command + "default": True + }, + } + +