Skip to content

Commit

Permalink
Merge pull request #194 from FPGAwars/develop
Browse files Browse the repository at this point in the history
Develop to 0.5v
  • Loading branch information
cavearr authored Feb 21, 2020
2 parents 1955a0a + b577c3a commit d0c3da4
Show file tree
Hide file tree
Showing 30 changed files with 998 additions and 195 deletions.
33 changes: 27 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
 
![][raspbian-logo]

Open source **ecosystem for open FPGA boards**. It was inspired by [PlatformIO](https://github.com/platformio/platformio).
Open source **ecosystem for open FPGA boards**

Apio (pronounced [ˈa.pjo]) is a **multiplatform toolbox**, with static pre-built packages, project configuration tools and easy command interface to verify, synthesize, simulate and upload your **verilog** designs.

Expand Down Expand Up @@ -45,7 +45,9 @@ Apio is used by [Icestudio](https://github.com/FPGAwars/icestudio).
| [drivers](https://github.com/FPGAwars/tools-drivers) | apio install drivers | Drivers tools (only for Windows)
| [examples](https://github.com/FPGAwars/apio-examples) | apio install examples | Verilog basic examples, pinouts, etc
| [gtkwave](https://github.com/FPGAwars/tool-gtkwave) | apio install gtkwave | Simulation viewer. [GTKWave project](http://gtkwave.sourceforge.net) (only for Windows)
| [icestorm](https://github.com/FPGAwars/toolchain-icestorm) | apio install icestorm | iCE40 FPGA synthesis, place & route and configuration tools. [Icestorm project](http://www.clifford.at/icestorm)
| [yosys](https://github.com/FPGAwars/toolchain-yosys) | apio install yosys | FPGA synthesis. [Yosys project](http://www.clifford.at/yosys)
| [ice40](https://github.com/FPGAwars/toolchain-ice40) | apio install ice40 | iCE40 place & route and configuration tools. [Icestorm project](http://www.clifford.at/icestorm)
| [ecp5](https://github.com/FPGAwars/toolchain-ecp5) | apio install ecp5 | ECP5 tools including [Project Trellis](https://github.com/SymbiFlow/prjtrellis) and [nextpnr](https://github.com/YosysHQ/nextpnr)
| [iverilog](https://github.com/FPGAwars/toolchain-iverilog) | apio install iverilog | Verilog simulation and synthesis tool. [Icarus Verilog project](http://iverilog.icarus.com)
| [scons](https://github.com/FPGAwars/tool-scons) | apio install scons | A software construction tool. [Scons project](http://scons.org)
| [system](https://github.com/FPGAwars/tools-system) | apio install system | Tools for listing the USB devices and retrieving information from the FTDI chips
Expand All @@ -70,9 +72,11 @@ Apio is used by [Icestudio](https://github.com/FPGAwars/icestudio).

| Board name | Interface |
|:-|:-:|
| [Alchitry-Cu](https://alchitry.com/products/alchitry-cu-fpga-development-board) | | FTDI |
| [Alhambra II](https://github.com/FPGAwars/Alhambra-II-FPGA) | FTDI |
| [BlackIce](https://hackaday.io/project/12930-blackice-low-cost-open-hardware-fpga-dev-board) | Serial |
| [BlackIce II](https://github.com/mystorm-org/BlackIce-II) | Serial |
| [Blackice-mx](https://www.tindie.com/products/Folknology/blackice-mx/) | Serial |
| [CAT Board](https://hackaday.io/project/7982-cat-board) | GPIO RPi |
| [icoBOARD 1.0](http://icoboard.org/about-icoboard.html) | GPIO RPi |
| [Kéfir I iCE40-HX4K](http://fpgalibre.sourceforge.net/Kefir/) | FTDI |
Expand All @@ -90,13 +94,27 @@ Apio is used by [Icestudio](https://github.com/FPGAwars/icestudio).

| Board name | Interface |
|:-|:-:|
| [UPDuino v1.0](http://gnarlygrey.atspace.cc/development-platform.html#upduino) | FTDI |
| [UPDuino v2.0](http://gnarlygrey.atspace.cc/development-platform.html#upduino_v2) | FTDI |
| arice1 | |
| [Fomu](https://github.com/im-tomu/fomu-hardware) | FTDI |
| [FPGA 101 Workshop Badge Board](https://github.com/mmicko/workshop_badge) | FTDI |
| [iCEBreaker](https://github.com/icebreaker-fpga/icebreaker) | FTDI |
| [iCEBreaker bitsy](https://github.com/icebreaker-fpga/icebreaker) | FTDI |
| [FPGA 101 Workshop Badge Board](https://github.com/mmicko/workshop_badge) | FTDI |
| [iCE40 UltraPlus Breakout Board](http://www.latticesemi.com/en/Products/DevelopmentBoardsAndKits/iCE40UltraPlusBreakoutBoard) | FTDI |
| [Fomu](https://github.com/im-tomu/fomu-hardware) | FTDI |
| [UPDuino v1.0](http://gnarlygrey.atspace.cc/development-platform.html#upduino) | FTDI |
| [UPDuino v2.0](http://gnarlygrey.atspace.cc/development-platform.html#upduino_v2) | FTDI |


#### ECP5
| Board name | Interface |
|:-|:-:|
| [TinyFPGA-EX-rev1](https://github.com/tinyfpga/TinyFPGA-EX) | Serial |
| [TinyFPGA-EX-rev2](https://www.crowdsupply.com/tinyfpga/tinyfpga-ex) | Serial |
| [ULX3S-12F](https://radiona.org/ulx3s/) | Ujprog |
| [ULX3S-25F](https://radiona.org/ulx3s/) | Ujprog |
| [ULX3S-45F](https://radiona.org/ulx3s/) | Ujprog |
| [ULX3S-85F](https://radiona.org/ulx3s/) | Ujprog |
| [Versa](https://www.mouser.es/new/lattice-semiconductor/lattice-lfe5um-45f-versa-evn/) | |


NOTE: all supported [Icestorm FPGAs](http://www.clifford.at/icestorm/) can be used with [--fpga or --size, --type and --pack options](http://apiodoc.readthedocs.io/en/develop/source/user_guide/project_commands/cmd_build.html#options).

Expand Down Expand Up @@ -157,9 +175,12 @@ Thanks Salvador E. Tropea!
* [Miguel Sánchez de León Peque](https://github.com/peque)
* [devbisme](https://github.com/devbisme)
* [Miodrag Milanovic](https://github.com/mmicko)
* [Carlos Venegas](https://github.com/cavearr)

## Credits

* APIO was inspired by [PlatformIO](https://github.com/platformio/platformio).

* [FPGAwars](http://fpgawars.github.io/) community has developed this project in a voluntary and altruistic way since 11/2016.

<img src="https://avatars3.githubusercontent.com/u/18257418?s=100">
Expand Down
2 changes: 1 addition & 1 deletion apio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# -- Author Jesús Arroyo
# -- Licence GPLv2

VERSION = (0, 4, 1)
VERSION = (0, 5, '0b1')
__version__ = '.'.join([str(s) for s in VERSION])

__title__ = 'apio'
Expand Down
8 changes: 4 additions & 4 deletions apio/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
help='Show the entire output of the command.')
@click.option('--verbose-yosys', is_flag=True,
help='Show the yosys output of the command.')
@click.option('--verbose-arachne', is_flag=True,
help='Show the arachne output of the command.')
@click.option('--verbose-pnr', is_flag=True,
help='Show the pnr output of the command.')
def cli(ctx, board, fpga, pack, type, size, project_dir,
verbose, verbose_yosys, verbose_arachne):
verbose, verbose_yosys, verbose_pnr):
"""Synthesize the bitstream."""

# Run scons
Expand All @@ -48,7 +48,7 @@ def cli(ctx, board, fpga, pack, type, size, project_dir,
'verbose': {
'all': verbose,
'yosys': verbose_yosys,
'arachne': verbose_arachne
'pnr': verbose_pnr
}
})
ctx.exit(exit_code)
Expand Down
13 changes: 11 additions & 2 deletions apio/commands/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@
@click.pass_context
@click.option('-p', '--project-dir', type=unicode, metavar='path',
help='Set the target directory for the project.')
def cli(ctx, project_dir):
@click.option('-b', '--board', type=unicode, metavar='board',
help='Set the board.')
@click.option('-v', '--verbose', is_flag=True,
help='Show the entire output of the command.')
def cli(ctx, board, project_dir, verbose):
"""Clean the previous generated files."""
exit_code = SCons(project_dir).clean()
exit_code = SCons(project_dir).clean({
'board': board,
'verbose': {
'all': verbose
}
})
ctx.exit(exit_code)
2 changes: 1 addition & 1 deletion apio/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def cli(ctx, board, scons, project_dir, sayyes):
"""Manage apio projects."""

if scons:
Project().create_sconstruct(project_dir, sayyes)
Project().create_sconstruct(project_dir, 'ice40', sayyes)
elif board:
Project().create_ini(board, project_dir, sayyes)
else:
Expand Down
8 changes: 4 additions & 4 deletions apio/commands/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
help='Show the entire output of the command.')
@click.option('--verbose-yosys', is_flag=True,
help='Show the yosys output of the command.')
@click.option('--verbose-arachne', is_flag=True,
help='Show the arachne output of the command.')
@click.option('--verbose-pnr', is_flag=True,
help='Show the pnr output of the command.')
def cli(ctx, board, fpga, pack, type, size, project_dir,
verbose, verbose_yosys, verbose_arachne):
verbose, verbose_yosys, verbose_pnr):
"""Bitstream timing analysis."""

# Run scons
Expand All @@ -48,7 +48,7 @@ def cli(ctx, board, fpga, pack, type, size, project_dir,
'verbose': {
'all': verbose,
'yosys': verbose_yosys,
'arachne': verbose_arachne
'pnr': verbose_pnr
}
})
ctx.exit(exit_code)
3 changes: 2 additions & 1 deletion apio/commands/uninstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from apio.managers.installer import Installer
from apio.resources import Resources
from apio.profile import Profile

platforms = ['linux_x86_64',
'linux_i686',
Expand All @@ -34,7 +35,7 @@ def cli(ctx, packages, all, list, platform):
if packages:
_uninstall(packages, platform)
elif all: # pragma: no cover
packages = Resources(platform).packages
packages = Profile().packages
_uninstall(packages, platform)
elif list:
Resources(platform).list_packages(installed=True, notinstalled=False)
Expand Down
14 changes: 8 additions & 6 deletions apio/commands/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@
help='Set the FTDI id.')
@click.option('-s', '--sram', is_flag=True,
help='Perform SRAM programming.')
@click.option('-f', '--flash', is_flag=True,
help='Perform FLASH programming.')
@click.option('-p', '--project-dir', type=unicode, metavar='path',
help='Set the target directory for the project.')
@click.option('-v', '--verbose', is_flag=True,
help='Show the entire output of the command.')
@click.option('--verbose-yosys', is_flag=True,
help='Show the yosys output of the command.')
@click.option('--verbose-arachne', is_flag=True,
help='Show the arachne output of the command.')
def cli(ctx, board, serial_port, ftdi_id, sram, project_dir,
verbose, verbose_yosys, verbose_arachne):
@click.option('--verbose-pnr', is_flag=True,
help='Show the pnr output of the command.')
def cli(ctx, board, serial_port, ftdi_id, sram, flash, project_dir,
verbose, verbose_yosys, verbose_pnr):
"""Upload the bitstream to the FPGA."""

drivers = Drivers()
Expand All @@ -45,9 +47,9 @@ def cli(ctx, board, serial_port, ftdi_id, sram, project_dir,
'verbose': {
'all': verbose,
'yosys': verbose_yosys,
'arachne': verbose_arachne
'pnr': verbose_pnr
}
}, serial_port, ftdi_id, sram)
}, serial_port, ftdi_id, sram, flash)
drivers.post_upload()
ctx.exit(exit_code)

Expand Down
13 changes: 11 additions & 2 deletions apio/commands/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@
@click.pass_context
@click.option('-p', '--project-dir', type=unicode, metavar='path',
help='Set the target directory for the project.')
def cli(ctx, project_dir):
@click.option('-b', '--board', type=unicode, metavar='board',
help='Set the board.')
@click.option('-v', '--verbose', is_flag=True,
help='Show the entire output of the command.')
def cli(ctx, board, project_dir, verbose):
"""Verify the verilog code."""
exit_code = SCons(project_dir).verify()
exit_code = SCons(project_dir).verify({
'board': board,
'verbose': {
'all': verbose
}
})
ctx.exit(exit_code)
57 changes: 48 additions & 9 deletions apio/managers/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,36 @@

def process_arguments(args, resources): # noqa
# -- Check arguments
var_board = args.get('board')
var_fpga = args.get('fpga')
var_size = args.get('size')
var_type = args.get('type')
var_pack = args.get('pack')
var_verbose = args.get('verbose')
if args is not None:
var_board = args.get('board')
var_arch = args.get('arch')
var_fpga = args.get('fpga')
var_size = args.get('size')
var_type = args.get('type')
var_pack = args.get('pack')
var_idcode = args.get('idcode')
var_verbose = args.get('verbose')
else:
var_board = None
var_arch = None
var_fpga = None
var_size = None
var_type = None
var_pack = None
var_idcode = None
var_verbose = {}

if var_board:
if isfile('apio.ini'):
click.secho('Info: ignore apio.ini board', fg='yellow')
if var_board in resources.boards:
fpga = resources.boards.get(var_board).get('fpga')
if fpga in resources.fpgas:
fpga_arch = resources.fpgas.get(fpga).get('arch')
fpga_size = resources.fpgas.get(fpga).get('size')
fpga_type = resources.fpgas.get(fpga).get('type')
fpga_pack = resources.fpgas.get(fpga).get('pack')
fpga_idcode = resources.fpgas.get(fpga).get('idcode')

redundant_arguments = []
contradictory_arguments = []
Expand Down Expand Up @@ -69,6 +83,14 @@ def process_arguments(args, resources): # noqa
# Contradictory argument
contradictory_arguments += ['pack']

if var_idcode:
if var_idcode == fpga_idcode:
# Redundant argument
redundant_arguments += ['idcode']
else:
# Contradictory argument
contradictory_arguments += ['idcode']

if redundant_arguments:
# Redundant argument
click.secho(
Expand All @@ -90,9 +112,11 @@ def process_arguments(args, resources): # noqa
if isfile('apio.ini'):
click.secho('Info: ignore apio.ini board', fg='yellow')
if var_fpga in resources.fpgas:
fpga_arch = resources.fpgas.get(var_fpga).get('arch')
fpga_size = resources.fpgas.get(var_fpga).get('size')
fpga_type = resources.fpgas.get(var_fpga).get('type')
fpga_pack = resources.fpgas.get(var_fpga).get('pack')
fpga_idcode = resources.fpgas.get(var_fpga).get('idcode')

redundant_arguments = []
contradictory_arguments = []
Expand Down Expand Up @@ -121,6 +145,14 @@ def process_arguments(args, resources): # noqa
# Contradictory argument
contradictory_arguments += ['pack']

if var_idcode:
if var_idcode == fpga_idcode:
# Redundant argument
redundant_arguments += ['idcode']
else:
# Contradictory argument
contradictory_arguments += ['idcode']

if redundant_arguments:
# Redundant argument
click.secho(
Expand All @@ -135,12 +167,14 @@ def process_arguments(args, resources): # noqa
# Unknown FPGA
raise Exception('unknown FPGA: {0}'.format(var_fpga))
else:
if var_size and var_type and var_pack:
if var_size and var_type and var_pack and var_arch:
if isfile('apio.ini'):
click.secho('Info: ignore apio.ini board', fg='yellow')
fpga_arch = var_arch
fpga_size = var_size
fpga_type = var_type
fpga_pack = var_pack
fpga_idcode = var_idcode
else:
if not var_size and not var_type and not var_pack:
# No arguments: use apio.ini board
Expand All @@ -150,9 +184,12 @@ def process_arguments(args, resources): # noqa
var_board = p.board
if var_board in resources.boards:
fpga = resources.boards.get(var_board).get('fpga')
fpga_arch = resources.fpgas.get(fpga).get('arch')
fpga_size = resources.fpgas.get(fpga).get('size')
fpga_type = resources.fpgas.get(fpga).get('type')
fpga_pack = resources.fpgas.get(fpga).get('pack')
fpga_idcode = resources.fpgas.get(fpga).get(
'idcode')
else:
# Unknown board
raise Exception('unknown board: {0}'.format(
Expand Down Expand Up @@ -187,15 +224,17 @@ def process_arguments(args, resources): # noqa

# -- Build Scons variables list
variables = format_vars({
'fpga_arch': fpga_arch,
'fpga_size': fpga_size,
'fpga_type': fpga_type,
'fpga_pack': fpga_pack,
'fpga_idcode': fpga_idcode,
'verbose_all': var_verbose.get('all'),
'verbose_yosys': var_verbose.get('yosys'),
'verbose_arachne': var_verbose.get('arachne')
'verbose_pnr': var_verbose.get('pnr')
})

return variables, var_board
return variables, var_board, fpga_arch


def format_vars(args):
Expand Down
11 changes: 8 additions & 3 deletions apio/managers/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ def __init__(self, package, platform='', force=False, checkversion=True):

self.resources = Resources(platform)

if self.package in self.resources.packages:
self.profile = Profile()

self.profile = Profile()
dirname = 'packages'

dirname = 'packages'
if self.package in self.resources.packages:
self.packages_dir = util.safe_join(util.get_home_dir(), dirname)

# Get data
Expand Down Expand Up @@ -81,6 +81,11 @@ def __init__(self, package, platform='', force=False, checkversion=True):
'platform': platform_os
}
]
else:
if self.package in self.profile.packages and checkversion is False:
self.packages_dir = util.safe_join(util.get_home_dir(),
dirname)
self.package_name = 'toolchain-' + package

if self.packages_dir == '':
click.secho(
Expand Down
Loading

0 comments on commit d0c3da4

Please sign in to comment.