Skip to content
Open
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
27 changes: 27 additions & 0 deletions ecppll.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/python
from fusesoc.capi2.generator import Generator
import subprocess
import os

class EcppllGenerator(Generator):
def run(self):
name = self.config.get('name', 'pll')
fin = self.config.get('freq_in', 12)
fout = self.config.get('freq_out', 60)
filename = self.config.get('filename', 'pll.v')
use_container = self.config.get('use_container', False)

args = []
if use_container:
args += ['docker', 'run', '--rm', '-v', os.getcwd() + ':/src', '-w', '/src', 'hdlc/prjtrellis']
args += ['ecppll', '-f', filename, '-n', name, '-i', str(fin), '-o', str(fout)]

rc = subprocess.run(args)

if rc.returncode:
exit(1)
self.add_files([{filename : {'file_type' : 'verilogSource'}}])

g = EcppllGenerator()
g.run()
g.write()
18 changes: 17 additions & 1 deletion generators.core
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ generators:
it detects that there are local modifications in the repository

icepll:
interpreter: python
interpreter: python3
command: icepll.py
description: Generate a parameterized verilog wrapper for an iCE40 PLL
usage: |
Expand All @@ -62,6 +62,22 @@ generators:
and the icepll generator will create a list of parameters that
can be included in the parameter list of the user-instantiated
component (default: false)
use_container (bool): Run icepll tool from a container without installing it
locally. Requires Docker (default: false).
ecppll:
interpreter: python3
command: ecppll.py
description: Generate a parameterized verilog wrapper for an ECP5 PLL
usage: |
The ecppll generator is a simple wrapper around the ecppll command

Parameters:
name (str): PLL module name (default: pll)
freq_in (int): PLL Input Frequency (default: 12 MHz)
freq_out (int) PLL Output Frequency (default: 60 MHz)
filename (str): Output filename (default: pll.v)
use_container (bool): Run icepll tool from a container without installing it
locally. Requires Docker (default: false).

template:
interpreter: python
Expand Down
15 changes: 11 additions & 4 deletions icepll.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
#!/usr/bin/python
from fusesoc.capi2.generator import Generator
import subprocess
import os

class IcepllGenerator(Generator):
def run(self):
fin = self.config.get('freq_in', 12)
fout = self.config.get('freq_out', 60)
module = self.config.get('module', False)
filename = self.config.get('filename', 'pll.v' if module else 'pll.vh')
use_container = self.config.get('use_container', False)

args = ['icepll', '-f', filename, '-i', str(fin), '-o', str(fout)]
args = []
if use_container:
args += ['docker', 'run', '--rm', '-v', os.getcwd() + ':/src', '-w', '/src', 'hdlc/icestorm']
args += ['icepll', '-f', filename, '-i', str(fin), '-o', str(fout)]
if module:
args.append('-m')
rc = subprocess.call(args)
if rc:
args += ['-m']

rc = subprocess.run(args)

if rc.returncode:
exit(1)
self.add_files([{filename : {'file_type' : 'verilogSource',
'is_include_file' : not module}}])
Expand Down