Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lattice ice40 fpga #590

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/lattice_ice40/lattice_ice40-counter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.pioenvs
65 changes: 65 additions & 0 deletions examples/lattice_ice40/lattice_ice40-counter/.travis.yml
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions examples/lattice_ice40/lattice_ice40-counter/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.. Copyright 2014-2016 Ivan Kravets <me@ikravets.com>
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 <http://docs.platformio.org/en/latest/installation.html>`_
2. Download `source code with examples <https://github.com/platformio/platformio/archive/develop.zip>`_
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
38 changes: 38 additions & 0 deletions examples/lattice_ice40/lattice_ice40-counter/lib/readme.txt
Original file line number Diff line number Diff line change
@@ -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 <Foo.h>
#include <Bar.h>

// 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

23 changes: 23 additions & 0 deletions examples/lattice_ice40/lattice_ice40-counter/platformio.ini
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions examples/lattice_ice40/lattice_ice40-counter/src/counter.pcf
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions examples/lattice_ice40/lattice_ice40-counter/src/counter.v
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions examples/lattice_ice40/lattice_ice40-counter/src/counter_tb.gtkw
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions examples/lattice_ice40/lattice_ice40-counter/src/counter_tb.v
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions examples/lattice_ice40/lattice_ice40-leds/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.pioenvs
65 changes: 65 additions & 0 deletions examples/lattice_ice40/lattice_ice40-leds/.travis.yml
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions examples/lattice_ice40/lattice_ice40-leds/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.. Copyright 2014-2016 Ivan Kravets <me@ikravets.com>
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 <http://docs.platformio.org/en/latest/installation.html>`_
2. Download `source code with examples <https://github.com/platformio/platformio/archive/develop.zip>`_
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
38 changes: 38 additions & 0 deletions examples/lattice_ice40/lattice_ice40-leds/lib/readme.txt
Original file line number Diff line number Diff line change
@@ -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 <Foo.h>
#include <Bar.h>

// 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

Loading