diff --git a/args_demo.py b/args_demo.py index 13bcd231d423dfb4c8e0252b95104a5b19534ee8..1c5a6a28c8ebcaff995b88dd0e568d870463b5cc 100644 --- a/args_demo.py +++ b/args_demo.py @@ -1,24 +1,24 @@ #! /usr/bin/env python3 -############################################################################### -# -# Copyright (C) 2016 +# ########################################################################## +# Copyright 2020 # ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> # P.O.Box 2, 7990 AA Dwingeloo, The Netherlands # -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# 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 # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# 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. +# ########################################################################## + +# ########################################################################## # Author Date # PD mrt 2017 # diff --git a/args_logger.py b/args_logger.py index 6d3e83fcd80e922d4d01d34e6454706dbdd88fae..0e865ab7dbcb35cbf604780b3e02aebd3a425d38 100644 --- a/args_logger.py +++ b/args_logger.py @@ -1,3 +1,25 @@ +# ########################################################################## +# Copyright 2020 +# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +# +# 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. +# ########################################################################## + +# ########################################################################## + + + import os import logging diff --git a/gen_bus.py b/gen_bus.py index 1a01c0e9aa5ea3dbe88459fe8afa994cfef9006a..854d3d396a618e4e3d623d3ed563bc38c61edc55 100755 --- a/gen_bus.py +++ b/gen_bus.py @@ -1,3 +1,21 @@ +# ########################################################################## +# Copyright 2020 +# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +# +# 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. +# ########################################################################## + ################################################################################# # # diff --git a/gen_c_config.py b/gen_c_config.py index 78a0a0de7ce7303394a5b71348c9e3d906618509..e18ed76c861c6952cbb79ae6d175e13cf85d1d65 100755 --- a/gen_c_config.py +++ b/gen_c_config.py @@ -1,23 +1,23 @@ #! /usr/bin/env python3 -############################################################################### -# -# Copyright (C) 2017 -# CSIRO (Commonwealth Scientific and Industrial Research Organization) <http://www.csiro.au/> -# GPO Box 1700, Canberra, ACT 2601, Australia -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# ########################################################################## +# Copyright 2020 +# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# 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 # -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# 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. +# ########################################################################## + +# ########################################################################## # Author Date Version comments # Keith Bengsotn Nov 2018 Original # Pieter Donker Apr 2020 add logging and changed output path diff --git a/gen_doc.py b/gen_doc.py index 0ef11dcc6c28d5c7a548a0e8a8a489f92b0b8396..69c36170830fb57b40900ecab93b12e25d804fde 100755 --- a/gen_doc.py +++ b/gen_doc.py @@ -1,25 +1,26 @@ #! /usr/bin/env python3 -############################################################################### -# -# Copyright (C) 2016 +# ########################################################################## +# Copyright 2020 # ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> # P.O.Box 2, 7990 AA Dwingeloo, The Netherlands # -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# 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 # -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# 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. +# ########################################################################## + +# ########################################################################## # Author Date # PD feb 2017 +# PD sep 2020, update and cleanup # ############################################################################### @@ -222,7 +223,6 @@ class FPGADocumentation(object): fpga_system_table.add_hline() for slave_port, slave_dict in self.fpga.address_map.items(): - #fpga_system_table.add_row(('0x{:08x}'.format(slave_dict['base']), '{}'.format(slave_dict['span']), slave_port, slave_dict['type'], slave_dict['port_index'])) fpga_system_table.add_row(('0x{:08x}'.format(slave_dict['base']), slave_dict['span'], slave_port, slave_dict['type'], slave_dict['port_index'])) fpga_system_table.add_hline() self.doc.append(fpga_system_table) @@ -246,9 +246,9 @@ class FPGADocumentation(object): periph_subsection = Section(periph_name, numbering=True) periph_subsection.append(periph.get_description().replace('""', '')) periph_reg_section = Subsection("{} register slave".format(periph_name), numbering=False) - periph_reg_table = Tabular('|c|c|c|c|') + periph_reg_table = Tabular('|r|r|r|l|c|') periph_reg_table.add_hline() - periph_reg_table.add_row(('Base Address', 'Range', 'Register group', 'Number of Slaves')) + periph_reg_table.add_row(('Base-addr', 'Addr-offset', 'Range', 'Reg-group', 'N-Slaves')) periph_reg_table.add_hline() slave_subsections = Subsection("Slave Ports for peripheral \'{}\'".format(periph_name), numbering=False) for slave in periph.slaves: @@ -264,11 +264,11 @@ class FPGADocumentation(object): slave_subsection.append(NewLine()) if isinstance(slave, Register): # expand registers and fields + periph_reg_table.add_row((slave.base_address(), '', slave.address_length(), slave.name(), slave.number_of_slaves())) + periph_reg_table.add_hline() for ram in slave.rams: - periph_reg_table.add_row((str(ram.base_address()), str(ram.number_of_fields()), ram.name() + ' (RAM)', str(slave.number_of_slaves()))) + periph_reg_table.add_row(('', ram.address_offset(), ram.number_of_fields() * WIDTH_IN_BYTES, '>> {} (RAM)'.format(ram.name()), slave.number_of_slaves())) periph_reg_table.add_hline() - periph_reg_table.add_row((str(slave.base_address()), str(slave.address_length()), slave.name(), str(slave.number_of_slaves()))) - periph_reg_table.add_hline() added_field_groups = [] # generate register table i.e. by word diff --git a/gen_fpgamap_py.py b/gen_fpgamap_py.py index bcf84ac016b804e161106b388560629bbc625bdd..bc6c40dae8a9fcc31396929548708378cafd3941 100755 --- a/gen_fpgamap_py.py +++ b/gen_fpgamap_py.py @@ -1,23 +1,23 @@ #! /usr/bin/env python3 -############################################################################### -# -# Copyright (C) 2017 -# CSIRO (Commonwealth Scientific and Industrial Research Organization) <http://www.csiro.au/> -# GPO Box 1700, Canberra, ACT 2601, Australia -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# ########################################################################## +# Copyright 2020 +# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# 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 # -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# 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. +# ########################################################################## + +# ########################################################################## # Author Date Version comments # John Matthews Dec 2017 Original # Pieter Donker Mrt 2020 add logging diff --git a/gen_hdl.py b/gen_hdl.py index bc063c9a0b7afdfa644e8d186062133cdb8339ad..d36ae02bcf3dd466717ceb247f557f2f69b36b83 100755 --- a/gen_hdl.py +++ b/gen_hdl.py @@ -1,24 +1,24 @@ #! /usr/bin/env python3 -############################################################################### -# -# Copyright (C) 2016 +# ########################################################################## +# Copyright 2020 # ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> # P.O.Box 2, 7990 AA Dwingeloo, The Netherlands # -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# 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 # -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# 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. +# ########################################################################## + +# ########################################################################## # Author Date # PD apr 2020 Original # diff --git a/gen_rom_mmap.py b/gen_rom_mmap.py index 750045f616c7098650a0d6a82346e5266f617ec5..075a5c63729f98ffeb320f208b7c656a70704601 100755 --- a/gen_rom_mmap.py +++ b/gen_rom_mmap.py @@ -1,23 +1,23 @@ #! /usr/bin/env python3 -############################################################################### -# -# Copyright (C) 2017 -# CSIRO (Commonwealth Scientific and Industrial Research Organization) <http://www.csiro.au/> -# GPO Box 1700, Canberra, ACT 2601, Australia +# ########################################################################## +# Copyright 2020 +# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands # -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# 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 # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# 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. +# ########################################################################## + +# ########################################################################## # Author Date Version comments # Pieter Donker June 2020 first version # @@ -36,12 +36,14 @@ from args_logger import MyLogger from py_args_lib import FPGA, RAM, FIFO, Register, PeripheralLibrary, FPGALibrary, ceil_pow2, WIDTH_IN_BYTES import pprint + def make_mask(width, offset=0): _hi_bit = offset + width - 1 _lo_bit = offset _mask_str = 'b[{}:{}]'.format(_hi_bit, _lo_bit) return _mask_str + def gen_fpga_map(fpga, fpga_name): _map_str = [] @@ -49,10 +51,10 @@ def gen_fpga_map(fpga, fpga_name): # pprint.pprint(fpga.address_map) print("Including slave ports for {}:".format(fpga_name)) for slave_port_name, slave_port_info in fpga.address_map.items(): - + if slave_port_info['periph_num'] > 0: continue - + peripheral = slave_port_info['peripheral'] slave = slave_port_info['slave'] base = int(slave_port_info['base']) @@ -60,7 +62,6 @@ def gen_fpga_map(fpga, fpga_name): slavename = slave.name() user_def_name = slave.user_defined_name().upper() - if isinstance(slave, RAM): print(' RAM {:23s} at 0x{:08x}(bytes) 0x{:04x}(words) "{}"'.format(slave_port_name, base, base_word, user_def_name)) if 'data' in slavename: @@ -77,7 +78,7 @@ def gen_fpga_map(fpga, fpga_name): str(slave.number_of_slaves()), user_def_name )) - + elif isinstance(slave, FIFO): print(' FIFO {:23s} at 0x{:08x}(bytes) 0x{:04x}(words) "{}"'.format(slave_port_name, base, base_word, user_def_name)) if 'data' in slavename: @@ -101,7 +102,7 @@ def gen_fpga_map(fpga, fpga_name): number_of_slaves = str(slave.number_of_slaves()) for r in slave.rams: r_base = base_word + int(r.address_offset() / WIDTH_IN_BYTES) - + field_name = r.name().strip('0123456789') if field_name in done: continue @@ -109,7 +110,7 @@ def gen_fpga_map(fpga, fpga_name): if field_name in slavename: slavename = slavename.replace(field_name, '').strip('_') done.append(field_name) - + _map_str.append(' {:12s} {:12s} {:16s} {:7s} 0x{:08x} {:6d} {:>5s} {:>10s} {:>5s} {:20s}'.format( peripheral.name(), slavename, @@ -129,7 +130,7 @@ def gen_fpga_map(fpga, fpga_name): for f in slave.fields: f_base = base_word + int(f.address_offset() / WIDTH_IN_BYTES) name = "{}_{}_{}".format(peripheral.name(), slave.name(), f.name()) - + field_name = f.name().strip('0123456789') if field_name in done: continue @@ -173,8 +174,8 @@ def gen_fpga_map(fpga, fpga_name): eth1g tse status REG 0x00000400 1024 RO b[31:0] AVS_ETH_0_TSE eth1g eth status REG 0x00000020 12 RO b[31:0] AVS_ETH_0_REG eth1g eth data RAM 0x00000800 1024 RW - AVS_ETH_0_RAM - ppsh ppsh status REG 0x000000EC 1 RO b[31:0] PIO_PPS - ppsh ppsh control REG 0x000000ED 1 RW b[31:0] PIO_PPS + ppsh ppsh status REG 0x000000EC 1 RO b[31:0] PIO_PPS + ppsh ppsh control REG 0x000000ED 1 RW b[31:0] PIO_PPS epcs epcs addr REG 0x000000D0 1 WO b[23:0] REG_EPCS epcs epcs rden REG 0x000000D1 1 WO b[0:0] REG_EPCS epcs epcs read_bit REG 0x000000D2 1 WO b[0:0] REG_EPCS @@ -198,7 +199,7 @@ def gen_fpga_map(fpga, fpga_name): _map_info.append('#') _map_info.append('# col1 col2 col3 col4 col5 col6 col7 col8 col9 col10') _map_info.append('# ----------- ----------- --------------- ----- ---------- ----- ---- --------- ---- ----------------') - + out_dir = os.path.join(os.getenv('ARGS_BUILD_DIR'), fpga.board_name.replace('uniboard','unb'), 'args', fpga_name, 'c') try: os.stat(out_dir) @@ -239,5 +240,5 @@ if __name__ == '__main__': # Here we select the FPGA YAML that matches up with the supplied fpga command line argument fpga_lib = FPGALibrary(root_dir=libRootDir, use_avalon_base_addr=use_avalon) fpga = fpga_lib.get_fpga(fpga_name) - + gen_fpga_map(fpga, fpga_name) diff --git a/gen_slave.py b/gen_slave.py index f0fedc0bd46e9b9b5a4663ad19cf30fe593c0883..0fb451da8762a9bfb5ddd74060c42b0d3280a7cd 100755 --- a/gen_slave.py +++ b/gen_slave.py @@ -1,3 +1,21 @@ +# ########################################################################## +# Copyright 2020 +# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +# +# 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. +# ########################################################################## + import os import sys import copy diff --git a/py_args_lib/fpga.py b/py_args_lib/fpga.py index d6db8eb7a5fdbd51900d0dabeddd0d31159f3e23..478b7bf500995222492bf442959ed2692fe5b87c 100644 --- a/py_args_lib/fpga.py +++ b/py_args_lib/fpga.py @@ -1,22 +1,22 @@ -############################################################################### -# -# Copyright (C) 2016 +# ########################################################################## +# Copyright 2020 # ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> # P.O.Box 2, 7990 AA Dwingeloo, The Netherlands # -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# 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 # -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# 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. +# ########################################################################## + +# ########################################################################## # Author Date # HJ jan 2017 Original # EK feb 2017 @@ -299,6 +299,7 @@ class FPGA(object): if slave.user_defined_name(): try: base_addr = avalon_base_addr[slave.user_defined_name()] + slave.base_address(base_addr) except: logger.warn("base address for username '%s' not found", slave.user_defined_name()) diff --git a/py_args_lib/peripheral.py b/py_args_lib/peripheral.py index 3029bfa15132be409818c01e9981ef0f1da8cfd6..8b2e4959d861437af18bd2bc692b8d9f9f7dba97 100644 --- a/py_args_lib/peripheral.py +++ b/py_args_lib/peripheral.py @@ -1,28 +1,29 @@ -############################################################################### -# -# Copyright (C) 2016 +# ########################################################################## +# Copyright 2020 # ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> # P.O.Box 2, 7990 AA Dwingeloo, The Netherlands # -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# 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 # -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# 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. +# ########################################################################## + +# ########################################################################## # Author Date # HJ jan 2017 Original # EK feb 2017 # PD feb 2017 # PD feb 2019 +# PD feb 2020, cleanup and update for only byte adresses # ############################################################################### @@ -77,15 +78,7 @@ class Peripheral(BaseObject): self.extract_config() def get_slave(self, name): - # for reg in self.registers.values(): - # if name == reg.name() or reg.user_defined_name(): - # return reg - # for ram in self.rams.values(): - # if name == ram.name() or ram.user_defined_name(): - # return ram - # for fifo in self.fifos.values(): - # if name == fifo.name() or fifo.user_defined_name(): - # return fifo + for slave in self.slaves: if name == slave.name() or slave.user_defined_name(): return slave @@ -206,12 +199,9 @@ class Peripheral(BaseObject): fields = [] if 'fields' in slave_info: - # for field_info in slave_info['fields']: # list of addresses defaults = {} - # logger.debug("slave_info['fields'] = %s", str(slave_info['fields'])) for field_group in slave_info['fields']: if isinstance(field_group, dict): # labelled field group - # logger.debug('field_group=%s', str(field_group)) (group_label, v) = field_group.popitem() field_group = v elif len(field_group) > 1: # unlabelled field group @@ -223,7 +213,6 @@ class Peripheral(BaseObject): logger.debug('group_label=%s', str(group_label)) for field_info in field_group: - # logger.debug("field_info=%s", str(field_info)) # get defaults dictionary if exists for field group if field_info.get('field_defaults', None) is not None: @@ -237,8 +226,6 @@ class Peripheral(BaseObject): field_name = field_info['field_name'] logger.debug("%s, info= %s", field_name, str(field_info)) try : - # PD print(f'field_name={field_name} _slave_type={_slave_type}') - # field = Field(field_name, _slave_type) field = Field(field_name, field_info) except ARGSNameError: logger.error("Invalid name '%s' for field in *.peripheral.yaml", field_name) @@ -254,8 +241,6 @@ class Peripheral(BaseObject): continue if key.lower() in VALID_FIELD_KEYS: # if valid attribute key, apply value to attribute eval("field.{}(val)".format(key.lower())) - # logger.debug("*.peripheral.yaml: field %s %s is %s", - # field.name(), key, str(eval("field.{}()".format(key.lower())))) else: logger.error("Unknown key %s in *.peripheral.yaml", key) sys.exit() @@ -272,7 +257,6 @@ class Peripheral(BaseObject): field_info['field_name'], str(key), str(val)) if field.success: - # fields[field_name] = deepcopy(field) fields.append(deepcopy(field)) else: logger.error("*.peripheral.yaml: field '%s' not succesfully added to fields", field_name) @@ -309,7 +293,6 @@ class Peripheral(BaseObject): _val = str(val) # first replace all knowns parameter names with its assigned value for key1, val1 in self._parameters.items(): - # logger.debug("key={}, val={}".format(key1, val1)) # if val is a dict, in vhdl it's a struct if isinstance(val1, dict): for key2, val2 in val1.items(): @@ -321,7 +304,6 @@ class Peripheral(BaseObject): if key1 in _val: logger.debug("replace %s with %s", key1, str(val1)) _val = _val.replace(key1, str(val1)) - # logger.debug("_val={}".format(_val)) if val is None: logger.error("key set to invalid value %s in *.peripheral.yaml", _val) sys.exit() @@ -361,9 +343,6 @@ class Peripheral(BaseObject): register.slave_span = slave_span if protocol is not None and protocol.upper() in ['LITE', 'FULL']: register.protocol = protocol.upper() - # else : - # logger.error("*.peripheral.yaml: Invalid user setting {} for slave {}".format(protocol, name)) - # sys.exit() self.registers['slave_{}'.format(slave_nr)] = register self.slaves.append(register) @@ -380,7 +359,6 @@ class Peripheral(BaseObject): def add_fifo(self, slave_nr, name, field, number_of_slaves): """ add FIFO to peripheral """ - # fifo = FIFO(name, field) fifo = deepcopy(self.init_slave('FIFO', name, field)) fifo.number_of_slaves(number_of_slaves) self.fifos['slave_{}'.format(slave_nr)] = fifo @@ -425,8 +403,6 @@ class Peripheral(BaseObject): def eval_fifo(self): """ Evaluate the paramters and the nof_inst of the peripheral """ - # for fifo in self.fifos.values(): - # print(type(fifo)) for slave in self.slaves: if isinstance(slave, FIFO): # Evaluate the fields @@ -446,7 +422,6 @@ class Peripheral(BaseObject): For example: address_length = c_nof_weights*c_nof_signal_paths witdh = c_weights_w*N_COMPLEX """ - # for ram in self.rams.values(): for slave in self.slaves: # Evaluate the fields and see if there are field that have to be repeated. if isinstance(slave, RAM): @@ -462,15 +437,12 @@ class Peripheral(BaseObject): ram.number_of_slaves(val=self._eval(ram.number_of_slaves())) - # for ram in self.rams.values(): for slave in self.slaves: # Evaluate the fields and see if there are field that have to be repeated. if isinstance(slave, RAM): ram = slave else: continue - # ram.number_of_slaves(val=self._eval(ram.nof_inst())) - # for field in ram.fields: logger.debug(" -RAM depth (fields): %s", ram.number_of_fields()) # Here the variables are used to evaluate the true value for the depth # parameter(taking int account the nof_inst as well) @@ -479,13 +451,9 @@ class Peripheral(BaseObject): logger.debug(" -RAM width (bits): %s", ram.width()) # Here the variables are used to evaluate the true value for the width parameter. - # field.width(val=self._eval(field.width())) - # ram.width(val=self._eval(field.width())) - # ram.default(val=self._eval(field.default())) ram.user_depth(val=self._eval(ram.user_depth())) ram.user_width(val=self._eval(ram.user_width())) ram.update_address_length() - # ram.access_mode(val=self._eval(field.access_mode())) logger.debug(" -RAM width eval: %d (bits)", ram.width()) logger.debug(" %s access_mode: %s", ram.name(), ram.access_mode()) logger.debug(" %s depth: %d (bytes)", ram.name(), ram.address_length()) @@ -494,23 +462,15 @@ class Peripheral(BaseObject): def eval_register(self): """Evaluate the register address_length based on the evaluation of the fields, nof registers and the nof_inst.""" - # for parameter in self.parameters: - # Here the parameters of the peripheral are promoted to real python variables - # exec("%s = %d" % (parameter, eval(str(self.parameters[parameter])))) + logger.debug("Number of registers = %d", len(self.registers.items())) - # for i in range(len(self.registers.values())):#register in self.registers.values(): - # try: - # register = self.registers['slave_{}'.format(i)] - # logger.debug(" Register slave %s ", register.name()) - # except KeyError: - # continue + for slave in self.slaves: if isinstance(slave, Register): register = slave else : continue logger.debug("evaluate %s", register.name()) - # register.number_of_slaves(val=self._eval(register.number_of_slaves())) # Evaluate the fields and see if there are field that have to be repeated. fields_eval = [] @@ -536,8 +496,6 @@ class Peripheral(BaseObject): else : fields_eval.append(field) - # fields_eval.append(field) - self.eval_fields(fields_eval) self.eval_fields(register.rams) register.number_of_slaves(val=self._eval(register.number_of_slaves())) @@ -552,8 +510,8 @@ class Peripheral(BaseObject): base_addr = 0 for field in register.rams: base_addr = ceil(base_addr / (ceil_pow2(field.number_of_fields()) * WIDTH_IN_BYTES)) * ceil_pow2(field.number_of_fields()) * WIDTH_IN_BYTES # lowest possible base_addr - field.base_address(base_addr) base_addr = base_addr + ceil_pow2(field.number_of_fields()) * WIDTH_IN_BYTES * register.number_of_slaves() # new base address + field.base_address(base_addr) # ### Assigned Address and bits to register fields # 1st pass for manually set address fields @@ -621,7 +579,6 @@ class Peripheral(BaseObject): break field.bit_offset(free_bit) occupied_bits = occupied_bits + list(range(field.bit_offset(), field.bit_offset() + field.width())) - # logger.warning("*.peripheral.yaml: Final field {} addr {} [{}-{}]".format(field.name(), str(field.address_offset()), str(field.bit_offset()+field.width()-1),str(field.bit_offset()))) # re-sort fields to be ordered by address and bit offsets fields_eval.sort(key=lambda x: x.address_offset()) @@ -636,11 +593,8 @@ class Peripheral(BaseObject): sorted_fields.extend(sorted(dummy_group, key=lambda x: x.bit_offset())) register.fields = sorted_fields # Update the fields with evaluated fields - # self.eval_fields(register.fields) - # self.eval_fields(register.rams) register.update_address_length() # Estimate the new address_length after evaluation of the fields and nof_inst - # logger.info(" %s address_length: %d", register.name(), register.address_length()) - # logger.info("slave %s has base_address %d", register.name(), register.base_address()) + logger.info(" %s address_length: %d", register.name(), register.address_length()) register.base_address(base_addr) base_addr = base_addr + register.address_length() * register.number_of_slaves() @@ -672,7 +626,6 @@ class Peripheral(BaseObject): if self.number_of_peripherals() > 1: logger.debug(" number_of_peripheral_instances=%d", self.number_of_peripherals()) logger.debug(" RAM and REG:") - # for ram in self.rams.values(): for ram in self.slaves: if not isinstance(ram, RAM): continue @@ -682,22 +635,17 @@ class Peripheral(BaseObject): logger.debug(" fields:") # first make list with address_offset as first item to print later fields orderd on address. fields = [] - # for field_val in ram.fields.values(): fields.append([ram.address_offset(), ram.name()]) for _offset, _name in sorted(fields): field = ram logger.debug(" %-20s:", _name) - # if field.number_of_fields() > 1: - # logger.debug(" number_of_fields=%s", str(field.number_of_fields())) logger.debug(" width=%-2s number_of_fields=%s", str(field.width()), str(field.number_of_fields())) - # for reg in self.registers.values(): for reg in self.slaves: if not isinstance(reg, Register): continue - # logger.debug("reg_fields=%s", str(reg.fields)) logger.debug(" %-20s:", reg.name()) if reg.number_of_slaves() > 1: logger.debug(" number_of_slaves=%-3s", str(reg.number_of_slaves())) @@ -707,9 +655,6 @@ class Peripheral(BaseObject): for field in reg.fields: logger.debug(" %-20s", field.name()) - # if field.number_of_fields() > 1: - # logger.debug(" number_of_fields=%s", str(field.number_of_fields())) - logger.debug(" width=%-2s address_offset=0x%02x access_mode=%-4s reset_value=%-4s radix=%s", str(field.width()), field.address_offset(), field.access_mode(), str(field.reset_value()), field.radix()) logger.debug(" bit_offset=%-2s number_of_fields=%-4s side_effect=%-4s software_value=%-4s", @@ -786,9 +731,6 @@ class PeripheralLibrary(object): logger.error("\nConflicting files:\n\t%s\n\t%s", self.library[lib_name]['file_path_name'], os.path.join(root, name)) sys.exit() - # list of peripheral configurations that are read from the available peripheral files - #self.read_peripheral_files() - def get_file_path_name(self, lib_name): """ return peripheral library file_path_name if found else None @@ -803,7 +745,6 @@ class PeripheralLibrary(object): """Read the peripheral information from all peripheral files that were found in the root_dir tree.""" self.peripherals = {} if file_path_names is None: - # file_path_names = self.file_path_names file_path_names = [lib_dict['file_path_name'] for lib_dict in self.library.values()] elif not isinstance(file_path_names, list): file_path_names = [file_path_names] @@ -846,15 +787,12 @@ class PeripheralLibrary(object): sys.exit() return None else : - # TODO.PD: matching_libs = [] # try to find unique instance of peripheral, failing that look for local for lib in self.library: - # periph_names.extend(list(self.library[lib]['peripherals'].keys())) if periph_name in self.library[lib]['peripherals']: matching_libs.append(lib) - # matches = len([name for name in periph_names if name == periph_name]) matches = len(matching_libs) if matches > 1: if fpga_library is not None and fpga_library in matching_libs: @@ -874,9 +812,6 @@ class PeripheralLibrary(object): logger.error("No matching peripherals for '%s' found under %s", periph_name, self.root_dir) sys.exit() - # if peripheral_library is None: - # return self.peripherals.get(name, None) - # return peripheral_library.get(name, None) return None def show_overview(self, header=True): diff --git a/py_args_lib/peripheral_lib/args_errors.py b/py_args_lib/peripheral_lib/args_errors.py index 10e7a852c87ea8c8f88dffcf77c329a58c9c186f..4c3183613222ca8fd6a5211ea424ca450d762688 100644 --- a/py_args_lib/peripheral_lib/args_errors.py +++ b/py_args_lib/peripheral_lib/args_errors.py @@ -1,3 +1,21 @@ +# ########################################################################## +# Copyright 2020 +# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +# +# 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. +# ########################################################################## + import logging diff --git a/py_args_lib/peripheral_lib/base_object.py b/py_args_lib/peripheral_lib/base_object.py index 8a9f331751723535f63879a791a518422f46bd53..b25841111cc4491ddd881170f1ef98b3ed2864ad 100644 --- a/py_args_lib/peripheral_lib/base_object.py +++ b/py_args_lib/peripheral_lib/base_object.py @@ -1,28 +1,29 @@ -############################################################################### -# -# Copyright (C) 2016 +# ########################################################################## +# Copyright 2020 # ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> # P.O.Box 2, 7990 AA Dwingeloo, The Netherlands # -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# 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 # -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# 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. +# ########################################################################## + +# ########################################################################## # Author Date # HJ jan 2017 Original # EK feb 2017 # PD feb 2017 # ############################################################################### + import logging import re import sys diff --git a/py_args_lib/peripheral_lib/common_func.py b/py_args_lib/peripheral_lib/common_func.py index 12bafe574b189c271bd6d63ad2793d6e4141e3d7..fe2f19f7c8842fef12c76d26056b291fbb7e9ddd 100644 --- a/py_args_lib/peripheral_lib/common_func.py +++ b/py_args_lib/peripheral_lib/common_func.py @@ -1,29 +1,26 @@ -############################################################################### -# -# Copyright (C) 2012 +# ########################################################################## +# Copyright 2020 # ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> # P.O.Box 2, 7990 AA Dwingeloo, The Netherlands # -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# 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 # -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# 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. +# ########################################################################## -"""Common definitions +""" +Common definitions """ -################################################################################ # System imports import os @@ -31,10 +28,8 @@ import math # do not use numpy in common, to avoid making common to elaborate import re -################################################################################ # Functions - def ceil_log2(num): """ Return integer ceil value of log2(num) """ return int(math.ceil(math.log(int(num), 2))) diff --git a/py_args_lib/peripheral_lib/constants.py b/py_args_lib/peripheral_lib/constants.py index 579b5e13b239b4aa062b3c8f7004e30debf1c8d1..a6acaf4a44aa7ab8ececcce01bd228372469a6b7 100644 --- a/py_args_lib/peripheral_lib/constants.py +++ b/py_args_lib/peripheral_lib/constants.py @@ -1,5 +1,29 @@ -""" +# ########################################################################## +# Copyright 2020 +# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +# +# 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. +# ########################################################################## + +# ########################################################################## +# Author Date +# PD feb 2017, nov 2019 +# +############################################################################### + +""" Constants used by peripheral.py and fpga.py this constants can be used in the yaml files """ diff --git a/py_args_lib/peripheral_lib/field.py b/py_args_lib/peripheral_lib/field.py index 654ea9ab7b45b8f4c8e6067dac104ed05afffaba..876864ebf166e7337237bcfa73cc51aab2852a4a 100644 --- a/py_args_lib/peripheral_lib/field.py +++ b/py_args_lib/peripheral_lib/field.py @@ -1,22 +1,22 @@ -############################################################################### -# -# Copyright (C) 2016 +# ########################################################################## +# Copyright 2020 # ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> # P.O.Box 2, 7990 AA Dwingeloo, The Netherlands # -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# 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 # -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# 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. +# ########################################################################## + +# ########################################################################## # Author Date # HJ jan 2017 Original # EK feb 2017 diff --git a/py_args_lib/peripheral_lib/fifo.py b/py_args_lib/peripheral_lib/fifo.py index 664b7ad43897f727c9a98033ddbe001dfca50c89..af569f8cd3872609787fe6a38fc79c0f4d458e86 100644 --- a/py_args_lib/peripheral_lib/fifo.py +++ b/py_args_lib/peripheral_lib/fifo.py @@ -1,22 +1,22 @@ -############################################################################### -# -# Copyright (C) 2016 +# ########################################################################## +# Copyright 2020 # ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> # P.O.Box 2, 7990 AA Dwingeloo, The Netherlands # -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# 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 # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# 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. +# ########################################################################## + +# ########################################################################## # Author Date # HJ jan 2017 Original # EK feb 2017 diff --git a/py_args_lib/peripheral_lib/ram.py b/py_args_lib/peripheral_lib/ram.py index 4ccba3529ffa2332eac021a6f625cecf2773419c..b8f25cd6376708a893c3924af1eaa1daa03a3276 100644 --- a/py_args_lib/peripheral_lib/ram.py +++ b/py_args_lib/peripheral_lib/ram.py @@ -1,22 +1,22 @@ -############################################################################### -# -# Copyright (C) 2016 +# ########################################################################## +# Copyright 2020 # ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> # P.O.Box 2, 7990 AA Dwingeloo, The Netherlands # -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# 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 # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# 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. +# ########################################################################## + +# ########################################################################## # Author Date # HJ jan 2017 Original # EK feb 2017 diff --git a/py_args_lib/peripheral_lib/register.py b/py_args_lib/peripheral_lib/register.py index 75d27cb0a763bcf7ffd3f714359a508a6aeac4a2..58422da4829d2930baff6aa8e46a3c8710f516c1 100644 --- a/py_args_lib/peripheral_lib/register.py +++ b/py_args_lib/peripheral_lib/register.py @@ -1,22 +1,22 @@ -############################################################################### -# -# Copyright (C) 2016 +# ########################################################################## +# Copyright 2020 # ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> # P.O.Box 2, 7990 AA Dwingeloo, The Netherlands # -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# 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 # -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# 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. +# ########################################################################## + +# ########################################################################## # Author Date # HJ jan 2017 Original # EK feb 2017 @@ -44,7 +44,7 @@ class Register(BaseObject): self.set_kv('type', 'REG') self.name(name) - self.fields = [] if fields is None else fields + self.fields = [] if fields is None else fields self.rams = [] @@ -81,9 +81,18 @@ class Register(BaseObject): def update_address_length(self): """ update total address_length of Register in bytes """ - if len(self.fields) == 0: + if len(self.fields) == 0 and len(self.rams) == 0: + self.set_kv('address_length', 0) return - n_bytes = max(max([_field.address_offset() for _field in self.fields]) + WIDTH_IN_BYTES, self.slave_span if self.slave_span is not None else 0) + + n_bytes = 0 + if any(self.fields): + n_bytes += max(max([_field.address_offset() for _field in self.fields]) + WIDTH_IN_BYTES, self.slave_span if self.slave_span is not None else 0) + + if any(self.rams): + #n_bytes += max(max([_field.address_offset() for _field in self.rams]) + WIDTH_IN_BYTES, self.slave_span if self.slave_span is not None else 0) + n_bytes += ceil_pow2(self.rams[0].number_of_fields()) * WIDTH_IN_BYTES + self.set_kv('address_length', n_bytes) def address_length(self, val=None): @@ -95,7 +104,7 @@ class Register(BaseObject): logger.error("Invalid address length for register {}, not word aligned".format(self.name())) sys.exit() return self.set_kv('address_length', val) - return self._as_int('address_length', default=WIDTH_IN_BYTES) + return self._as_int('address_length', default=1) def base_address(self, val=None): if val is not None: diff --git a/qsys.reg b/qsys.reg deleted file mode 100644 index 705186b387743ba2bd4fd03b0f6e76e4d285fbd4..0000000000000000000000000000000000000000 Binary files a/qsys.reg and /dev/null differ diff --git a/unb1_minimal_sopc.build.reg b/unb1_minimal_sopc.build.reg deleted file mode 100644 index 74d09a28b3fcf3b487723136d8ff67df485aed07..0000000000000000000000000000000000000000 Binary files a/unb1_minimal_sopc.build.reg and /dev/null differ diff --git a/uniboard_rom_system_info.py b/uniboard_rom_system_info.py index c472cfa8b2691797fb89ccc20f8b674ff710dac2..1ad0f3563e4ca43670b37da829aaba7cbf3de3bf 100755 --- a/uniboard_rom_system_info.py +++ b/uniboard_rom_system_info.py @@ -1,23 +1,23 @@ #! /usr/bin/env python3 -############################################################################### -# -# Copyright (C) 2016 +# ########################################################################## +# Copyright 2020 # ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> # P.O.Box 2, 7990 AA Dwingeloo, The Netherlands # -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# 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 # -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# 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. +# ########################################################################## + +# ########################################################################## # Author Date # PD feb 2017 #