Skip to content

Commit

Permalink
remove ydir and use explicit paths instead
Browse files Browse the repository at this point in the history
  • Loading branch information
gadfort committed Dec 18, 2023
1 parent 20417e6 commit d9e2d8b
Show file tree
Hide file tree
Showing 2 changed files with 240 additions and 12 deletions.
225 changes: 214 additions & 11 deletions lambdalib/lambdalib.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,234 @@
from siliconcompiler import Library


def __iolib_files():
return [f"lambdalib/iolib/rtl/{f}"
for f in (
"la_ioanalog.v",
"la_iobidir.v",
"la_ioclamp.v",
"la_iocorner.v",
"la_iocut.v",
"la_ioinput.v",
"la_iopoc.v",
"la_ioshort.v",
"la_iovdd.v",
"la_iovdda.v",
"la_iovddio.v",
"la_iovss.v",
"la_iovssa.v",
"la_iovssio.v",
"la_ioxtal.v",
"la_pt.v",
)]


def __stdlib_files():
return [f"lambdalib/stdlib/rtl/{f}"
for f in (
"la_and2.v",
"la_and3.v",
"la_and4.v",
"la_antenna.v",
"la_ao21.v",
"la_ao211.v",
"la_ao22.v",
"la_ao221.v",
"la_ao222.v",
"la_ao31.v",
"la_ao311.v",
"la_ao32.v",
"la_ao33.v",
"la_aoi21.v",
"la_aoi211.v",
"la_aoi22.v",
"la_aoi221.v",
"la_aoi222.v",
"la_aoi31.v",
"la_aoi311.v",
"la_aoi32.v",
"la_aoi33.v",
"la_buf.v",
"la_clkand2.v",
"la_clkbuf.v",
"la_clkicgand.v",
"la_clkicgor.v",
"la_clkinv.v",
"la_clkmux2.v",
"la_clkmux4.v",
"la_clknand2.v",
"la_clknor2.v",
"la_clkor2.v",
"la_clkor4.v",
"la_clkxor2.v",
"la_csa32.v",
"la_csa42.v",
"la_decap.v",
"la_delay.v",
"la_dffnq.v",
"la_dffq.v",
"la_dffqn.v",
"la_dffrq.v",
"la_dffrqn.v",
"la_dffsq.v",
"la_dffsqn.v",
"la_dmux2.v",
"la_dmux3.v",
"la_dmux4.v",
"la_dmux5.v",
"la_dmux6.v",
"la_dmux7.v",
"la_dmux8.v",
"la_drsync.v",
"la_dsync.v",
"la_footer.v",
"la_header.v",
"la_iddr.v",
"la_inv.v",
"la_isohi.v",
"la_isolo.v",
"la_keeper.v",
"la_latnq.v",
"la_latq.v",
"la_mux2.v",
"la_mux3.v",
"la_mux4.v",
"la_muxi2.v",
"la_muxi3.v",
"la_muxi4.v",
"la_nand2.v",
"la_nand3.v",
"la_nand4.v",
"la_nor2.v",
"la_nor3.v",
"la_nor4.v",
"la_oa21.v",
"la_oa211.v",
"la_oa22.v",
"la_oa221.v",
"la_oa222.v",
"la_oa31.v",
"la_oa311.v",
"la_oa32.v",
"la_oa33.v",
"la_oai21.v",
"la_oai22.v",
"la_oai221.v",
"la_oai222.v",
"la_oai31.v",
"la_oai311.v",
"la_oai32.v",
"la_oai33.v",
"la_oddr.v",
"la_or2.v",
"la_or3.v",
"la_or4.v",
"la_pwrbuf.v",
"la_rsync.v",
"la_sdffq.v",
"la_sdffqn.v",
"la_sdffrq.v",
"la_sdffrqn.v",
"la_sdffsq.v",
"la_sdffsqn.v",
"la_tbuf.v",
"la_tiehi.v",
"la_tielo.v",
"la_xnor2.v",
"la_xnor3.v",
"la_xnor4.v",
"la_xor2.v",
"la_xor3.v",
"la_xor4.v"
)]


def __ramlib_files():
return [f"lambdalib/ramlib/rtl/{f}"
for f in (
"la_asyncfifo.v",
"la_dpram.v",
"la_spram.v",
"la_spregfile.v",
"la_syncfifo.v"
)]


def __syslib_files():
return [f"lambdalib/syslib/rtl/{f}"
for f in (
"la_eth.v",
"la_gpio.v",
"la_i2c.v",
"la_jtag.v",
"la_qspi.v",
"la_sd.v",
"la_spi.v",
"la_uart.v",
"la_usb.v"
)]


def __padring_files():
return [f"lambdalib/padring/rtl/{f}"
for f in (
"la_iopadring.v",
"la_ioside.v"
)]


def __vectorlib_files():
return [f"lambdalib/vectorlib/rtl/{f}"
for f in (
"la_vbuf.v",
"la_vinv.v",
"la_visohi.v",
"la_visolo.v",
"la_vmux.v",
"la_vmux2.v",
"la_vmux3.v",
"la_vmux4.v",
"la_vmux5.v",
"la_vmux6.v",
"la_vmux7.v",
"la_vmux8.v"
)]


def _dependencies():
return {
'iolib': (['stdlib'], __iolib_files),
'stdlib': ([], __stdlib_files),
'ramlib': (['stdlib'], __ramlib_files),
'padring': (['stdlib'], __padring_files),
'syslib': (['stdlib'],__syslib_files),
'vectorlib': (['stdlib'], __vectorlib_files)
}


########################
# SiliconCompiler Setup
########################
def setup(chip):
'''Lambdalib library setup script'''

dependencies = {
'iolib': ['stdlib'],
'stdlib': [],
'ramlib': ['stdlib'],
'padring': ['stdlib'],
'syslib': ['stdlib'],
'vectorlib': ['stdlib']
}

libs = []
# Iterate over all libs
for name, dep in dependencies.items():
for name, data in _dependencies().items():
dep, _ = data

lib = Library(chip, f'la_{name}', package='lambdalib')
register_data_source(lib)

# Add idirs
for path in [name, *dep]:
lib.add('option', 'ydir', f"lambdalib/{path}/rtl")
lib.add('option', 'idir', f"lambdalib/{path}/rtl")

for path in [name, *dep]:
files = _dependencies()[name][1]
for f in files():
lib.output(f)

libs.append(lib)

return libs
27 changes: 26 additions & 1 deletion tests/test_paths.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
import glob
import os
import pytest
from siliconcompiler import Chip

from lambdalib import lambdalib


def test_pdk_paths():
def test_paths_valid():
chip = Chip('<lib>')
chip.use(lambdalib)
assert chip.check_filepaths()


@pytest.mark.parametrize('lib', lambdalib._dependencies().keys())
def test_extra_files(lib):
'''
Ensure all files are included in the lists
'''
dependencies = lambdalib._dependencies()[lib][0]

fs_base = os.path.dirname(lambdalib.__file__)
rm_base = os.path.dirname(fs_base)

fs_files = []
lib_files = []
for name in [lib, *dependencies]:
lib_files.extend(lambdalib._dependencies()[name][1]())

glob_path = f"{fs_base}/{name}/rtl/*.v"
fs_files.extend([f[len(rm_base)+1:] for f in glob.glob(glob_path)])

assert not set(fs_files).difference(set(lib_files))
assert not set(lib_files).difference(set(fs_files))

0 comments on commit d9e2d8b

Please sign in to comment.