Skip to content
Snippets Groups Projects
Commit f83007be authored by Pieter Donker's avatar Pieter Donker
Browse files

Task #893 next step in reformating the yaml configuration files

parent 9664d1a4
Branches
No related tags found
No related merge requests found
Showing
with 766 additions and 616 deletions
---
bf_unit:
protocol_name : args
protocol_version: 1.0
protocol_type : peripheral
library_name : bf
library_description: " This is the description for the bf package "
peripherals:
- peripheral_component_name: bf_unit
parameters:
g_bf.in_weights_w : 16
g_bf.nof_weights : 256
g_bf.nof_signal_paths : 64
g_bf.nof_subbands : 24
g_bf.nof_input_streams : 16
c_nof_signal_paths_per_stream: g_bf.nof_signal_paths / g_bf.nof_input_streams
- { name: g_bf.in_weights_w , value: 16 }
- { name: g_bf.nof_weights , value: 256 }
- { name: g_bf.nof_signal_paths , value: 64 }
- { name: g_bf.nof_subbands , value: 24 }
- { name: g_bf.nof_input_streams , value: 16 }
- { name: c_nof_signal_paths_per_stream, value: g_bf.nof_signal_paths / g_bf.nof_input_streams }
slave_ports:
ram_bf_weights:
-
slave_prefix : BF
slave_name : WEIGHTS # ram_bf_weights
slave_postfix: RAM
number_of_slaves: g_bf.nof_weights
slave_type: RAM
fields:
bf_weights:
-
field_name : bf_weights
width : g_bf.in_weights_w * c_nof_complex
address_length: g_bf.nof_signal_paths
field_description: |
......@@ -22,23 +33,30 @@ bf_unit:
The real and the imaginary parts are concatenated: W_real in Lower part. W_imag in Higher part."
slave_discription: |
" "
ram_ss_ss_wide:
-
slave_prefix : # BF
slave_name : ram_ss_ss_wide # SS_SS_WIDE
slave_postfix: # RAM
number_of_slaves: g_bf.nof_weights
slave_type: RAM
fields:
ss_ss_wide:
-
field_name: ss_ss_wide
width: ceil_log2(g_bf.nof_subbands * c_nof_signal_paths_per_stream)
address_length: g_bf.nof_input_streams * c_nof_signal_paths_per_stream # 16*4=64, nof_input_streams*nof_signal_paths_per_stream
field_description: |
"Contains the addresses to select from the stored subbands."
slave_discription: |
" "
ram_st_sst_bf:
-
slave_prefix : # BF
slave_name : ram_st_sst_bf # ST_SST
slave_postfix: # RAM
number_of_slaves: g_bf.nof_weights
slave_type: RAM
fields:
st_sst_bf:
-
field_name: st_sst_bf
width: 56
address_length: c_nof_complex # 2
access_mode : RO
......@@ -46,12 +64,15 @@ bf_unit:
"Contains the weights.
The real and the imaginary parts are concatenated: W_real in Lower part. W_imag in Higher part."
slave_discription: |
" "
reg_st_sst_bf:
-
slave_prefix : # BF
slave_name : reg_st_sst_bf # ST_SST
slave_postfix: # REG
number_of_slaves: 1
slave_type: REG
fields:
Treshold:
-
field_name: Treshold
address_offset : 0x0
field_description : |
"When the treshold register is set to 0 the statistics will be auto-correlations.
......
---
demo:
protocol_name : args
protocol_version: 1.0
protocol_type : system
library_name : demo
system_description: |
"DEMO system for testing mm tools
Now with extra line ??"
# board_select: unb1: later
# bus_select : qsys: later
# system parameters
parameters:
nof_fringe_stop_units: 4
nof_streams : 12
- { name : nof_fringe_stop_units, value: 4 }
- { name : nof_streams, value: 12 }
peripherals:
mms_rom_system_info:
peripheral_name: mms_rom_system_info
- peripheral_component_name: rom_system_info
peripheral_prefix : ''
mms_reg_system_info:
peripheral_name: mms_reg_system_info
- peripheral_component_name: reg_system_info
peripheral_prefix : ''
fringe_stop_unit:
- peripheral_component_name: fringe_stop_unit
peripheral_prefix : ''
number_of_peripherals : nof_fringe_stop_units
peripheral_name : fringe_stop_unit
mms_diag_block_gen_input:
peripheral_name: mms_diag_block_gen
- peripheral_component_name: diag_block_gen
peripheral_prefix : input
parameters:
g_nof_streams : nof_streams
g_buf_addr_w : 7
- { name : g_nof_streams, value: nof_streams }
- { name : g_buf_addr_w, value: 7 }
mms_diag_block_gen_mesh:
peripheral_name: mms_diag_block_gen
- peripheral_component_name: diag_block_gen
peripheral_prefix : mesh
parameters:
g_nof_streams : 8
g_buf_addr_w : 8
- { name : g_nof_streams, value: 8 }
- { name : g_buf_addr_w, value: 8 }
mms_diag_block_gen_proc:
peripheral_name: mms_diag_block_gen
- peripheral_component_name: diag_block_gen
peripheral_prefix : proc
parameters:
g_nof_streams: nof_streams
g_buf_addr_w : 7
- { name : g_nof_streams, value: nof_streams }
- { name : g_buf_addr_w, value: 7 }
bf_unit:
peripheral_name : bf_unit
- peripheral_component_name: bf_unit
peripheral_prefix : ''
parameters:
g_bf.in_weights_w : 3
g_bf.nof_weights : 128
g_bf.nof_signal_paths : 32
g_bf.nof_subbands : 12
# g_nof_signal_paths_per_stream: 2 # constant in vhdl ??
g_bf.nof_input_streams: 8
mms_diag_block_gen_output:
peripheral_name: mms_diag_block_gen
- { name : g_bf.in_weights_w, value: 3 }
- { name : g_bf.nof_weights, value: 128 }
- { name : g_bf.nof_signal_paths, value: 32 }
- { name : g_bf.nof_subbands, value: 12 }
- { name : g_bf.nof_input_streams, value: 8 }
- peripheral_component_name: diag_block_gen
peripheral_prefix : output
parameters:
g_nof_streams : 2
- { name : g_nof_streams, value: 2 }
mms_diag_data_buffer_input_pre:
peripheral_name : mms_diag_data_buffer
- peripheral_component_name: diag_data_buffer
peripheral_prefix : input_pre
parameters:
g_nof_streams : nof_streams
g_data_w : 16
g_buf_nof_data : 8192
- { name : g_nof_streams, value: nof_streams }
- { name : g_data_w, value: 16 }
- { name : g_buf_nof_data, value: 8192 }
mms_diag_data_buffer_input_post:
peripheral_name : mms_diag_data_buffer
- peripheral_component_name: diag_data_buffer
peripheral_prefix : input_post
parameters:
g_nof_streams : nof_streams
g_data_w : 16
g_buf_nof_data : 8192
- { name : g_nof_streams, value: nof_streams }
- { name : g_data_w, value: 16 }
- { name : g_buf_nof_data, value: 8192 }
mms_diag_data_buffer_mesh:
peripheral_name : mms_diag_data_buffer
- peripheral_component_name: diag_data_buffer
peripheral_prefix : mesh
parameters:
g_nof_streams : 8
g_data_w : 16
g_buf_nof_data : 8
- { name : g_nof_streams, value: 8 }
- { name : g_data_w, value: 16 }
- { name : g_buf_nof_data, value: 8 }
mms_diag_data_buffer_proc:
peripheral_name : mms_diag_data_buffer
- peripheral_component_name: diag_data_buffer
peripheral_prefix : proc
parameters:
g_nof_streams : nof_streams
g_data_w : 16
g_buf_nof_data : 128
- { name : g_nof_streams, value: nof_streams }
- { name : g_data_w, value: 16 }
- { name : g_buf_nof_data, value: 128 }
mms_dp_bsn_align_input:
peripheral_name: mms_dp_bsn_align
- peripheral_component_name: dp_bsn_align
peripheral_prefix : input
parameters:
g_nof_input : 3
- { name : g_nof_input, value: 3 }
mms_dp_fifo_fill:
peripheral_name: mms_dp_fifo_fill
- peripheral_component_name: dp_fifo_fill
peripheral_prefix : ''
parameters:
g_nof_streams : 3
- { name : g_nof_streams, value: 3 }
system_description: |
"DEMO system for testing mm tools
Now with extra line ??"
---
mms_diag_block_gen:
protocol_name : args
protocol_version: 1.0
protocol_type : peripheral
library_name : diag
library_description: " This is the description for the bf package "
peripherals:
-
peripheral_component_name: diag_block_gen
parameters:
g_nof_streams: 1
g_buf_dat_w : 32
g_buf_addr_w : 7
- { name: g_nof_streams, value: 1 }
- { name: g_buf_dat_w , value: 32 }
- { name: g_buf_addr_w , value: 7 }
slave_ports:
reg_diag_bg:
-
slave_prefix : DIAG
slave_name : BG # reg_diag_bg
slave_postfix: REG
slave_type : REG
fields:
Enable:
-
field_name : Enable
width : 2
address_offset: 0x0
field_description: |
"Bit 0: enable the block generator Bit 1: enable the blok generator on PPS"
Samples_per_packet:
-
field_name : Samples_per_packet
width : 16
address_offset: 0x1
default_value : 256
field_description: |
"This REG specifies the number samples in a packet"
Blocks_per_sync:
-
field_name : Blocks_per_sync
width : 16
address_offset: 0x2
default_value : 781250
field_description: |
"This REG specifies the number of packets in a sync period"
Gapsize:
-
field_name : Gapsize
width : 16
address_offset: 0x3
default_value : 80
field_description: |
"This REG specifies the gap in number of clock cycles between two consecutive packets"
Mem_low_address:
-
field_name : Mem_low_address
width : 8
address_offset: 0x4
field_description: |
"This REG specifies the starting address for reading from the waveform memory"
Mem_high_address:
-
field_name : Mem_high_address
width : 8
address_offset: 0x5
field_description: |
"This REG specifies the last address to be read when from the waveform memory"
BSN_init_low:
-
field_name : BSN_init_low
address_offset: 0x6
field_description: |
"This REG specifies the lower(LSB) 32 bits [31:0] of the initialization BSN"
BSN_init_high:
-
field_name : BSN_init_high
address_offset: 0x7
field_description: |
"This REG specifies the higher(MSB) 32 bits [63:32] of the initialization BSN"
ram_diag_bg:
-
slave_prefix : DIAG
slave_name : BG # ram_diag_bg
slave_postfix: RAM
number_of_slaves: g_nof_streams
slave_type : RAM
fields:
diag_bg:
-
field_name: diag_bg
width: g_buf_dat_w
depth: 2**g_buf_addr_w
field_description : |
"Contains the Waveform data for the data-streams to be send"
peripheral_description: |
"Block generator"
---
mms_diag_data_buffer:
-
peripheral_component_name: diag_data_buffer
parameters:
g_nof_streams : 1
g_data_w : 32
g_buf_nof_data: 1024
- { name: g_nof_streams , value: 1 }
- { name: g_data_w , value: 32 }
- { name: g_buf_nof_data, value: 1024 }
slave_ports:
reg_diag_data_buffer:
-
slave_prefix : DIAG
slave_name : DATA_BUFFER # reg_diag_data_buffer
slave_postfix: REG
slave_type : REG
fields:
Sync_cnt:
-
field_name : Sync_cnt
access_mode : RO
address_offset: 0x0
field_description: |
"Sync_cnt contains the nof times the buffer (ST) has received a sync pulse since the last MM read
(cleared when the last data word from the buffer is read)"
Word_cnt:
-
field_name : Word_cnt
access_mode : RO
address_offset: 0x1
field_description: |
"Word_cnt indicates the number of word currently (ST) written in the buffer. Cleared on (ST) re-write of buffer."
Valid_cnt_arm_ena:
-
field_name : Valid_cnt_arm_ena
address_offset: 0x2
field_description: |
"Valid_cnt contains the number of valid cycles since the last sync pulse. Cleared on every sync pulse.
Arm_enable: Write to this REG to arm the system.
After the system is armed the next syn pulse will trigger the acquisition of data."
Reg_sync_delay:
-
field_name : Reg_sync_delay
address_offset: 0x3
field_description: |
"Reg_sync_delay contains the number of valid cycles to delay/wait after an armed-syncpulse,
before the data is written to the databuffer."
Version:
-
field_name : Version
access_mode : RO
address_offset: 0x7
field_description: |
"Version contains the version number of the databuffer peripheral."
slave_description: ""
ram_diag_data_buffer:
-
slave_prefix : DIAG
slave_name : DATA_BUFFER # ram_diag_data_buffer
slave_postfix: RAM
number_of_slaves: g_nof_streams
slave_type : RAM
fields:
ram:
-
field_name : ram
width : g_data_w
address_length: 2**ceil_log2(g_buf_nof_data)
field_description: |
"Contains the data that is being captured."
slave_description: ""
peripheral_description: |
......
---
mms_dp_bsn_align:
protocol_name : args
protocol_version: 1.0
protocol_type : peripheral
library_name : dp
library_description: " This is the description for the dp package "
peripherals:
-
peripheral_component_name: dp_bsn_align
parameters:
g_nof_input: 2
- { name: g_nof_input, value : 2 }
slave_ports:
reg_dp_bsn_align:
-
slave_prefix : DP
slave_name : BSN_ALIGN # reg_dp_bsn_align
slave_postfix: REG
number_of_slaves: g_nof_input
slave_type : REG
fields:
Enable:
-
field_name : Enable
width : 1
address_offset : 0x0
field_description: |
"Input enable register for input 0. If set to 0 the input is discarded from alignment.
If set to 1 the corresopnding input is taken into account."
slave_discription: |
" "
peripheral_description: |
"This is the BSN aligner"
---
mms_dp_fifo_fill:
slave_discription: " "
peripheral_description: "This is the BSN aligner"
-
peripheral_component_name: mms_dp_fifo_fill
parameters:
g_nof_streams: 3
- { name : g_nof_streams, value: 3 }
slave_ports:
reg_dp_fifo_fill:
-
slave_prefix : DP
slave_name : FIFO_FILL # reg_dp_fifo_fill
slave_postfix: REG
number_of_slaves: g_nof_streams
slave_type : REG
fields:
fifo_used_words:
-
field_name : fifo_used_words
access_mode : RO
address_offset : 0x0
field_description: |
"Register reflects the currently used nof words on the fifo."
fifo_status:
field_description: "Register reflects the currently used nof words on the fifo."
-
field_name : fifo_status
width : 2
access_mode : RO
address_offset : 0x1
field_description: |
"Bit 0: fifo_read_empty Bit 1: fifo_wr_full."
max_fifo_used_words:
field_description: "Bit 0: fifo_read_empty Bit 1: fifo_wr_full."
-
field_name : max_fifo_used_words
access_mode : RO
address_offset : 0x2
field_description: |
"Register contains the maximum number of words that have been in the fifo.
Will be cleared after it has been read."
slave_discription: |
""
peripheral_description: |
"This is the MM slave version of the dp_fifo_fill component."
slave_discription: ""
peripheral_description: "This is the MM slave version of the dp_fifo_fill component."
---
mms_eth1g:
protocol_name : args
protocol_version: 1.0
protocol_type : peripheral
library_name : eth
library_description: " This is the description for the eth package "
peripherals:
-
peripheral_component_name: eth1g
parameters:
c_eth_ram_nof_words: 1024
- { name: c_eth_ram_nof_words, value: 1024 }
#g_technology: c_tech_select_default
#g_ETH_PHY : "LVDS"
slave_ports:
reg_tse:
-
slave_prefix : ETH
slave_name : TSE # reg_tse
slave_postfix: REG
slave_type : REG
fields:
status:
-
field_name : status
access_mode : RO
address_offset : 0x0
field_description: |
" reg tse "
slave_description: |
" "
reg:
slave_description: ""
-
slave_prefix : ETH
slave_name : REG # reg
slave_postfix: REG
slave_type : REG
fields:
status:
-
field_name : status
access_mode : RO
address_offset: 0x0
field_description : |
" reg registers "
slave_description: |
" "
ram:
field_description : " reg registers "
slave_description: " "
-
slave_prefix : ETH
slave_name : RAM # ram
slave_postfix: RAM
slave_type : RAM
fields:
ram:
-
field_name: ram
address_length: c_eth_ram_nof_words
field_description: |
"Contains the Waveform data for the data-streams to be send"
slave_description: |
" "
slave_description: " "
peripheral_description: |
"
......
---
fringe_stop_unit:
protocol_name : args
protocol_version: 1.0
protocol_type : peripheral
library_name : fringe_stop
library_description: " This is the description for the finge_stop library "
peripherals:
-
peripheral_component_name: fringe_stop_unit
parameters:
g_nof_channels: 256
g_fs_offset_w : 10
g_fs_step_w : 17
- { name: g_nof_channels, value: 256 }
- { name: g_fs_offset_w , value: 10 }
- { name: g_fs_step_w , value: 17 }
slave_ports:
ram_fringe_stop_step:
-
slave_prefix : FRINGE_STOP
slave_name : STEP # ram_fringe_stop_step
slave_postfix: RAM
slave_type : RAM
fields:
fringe_stop_step:
-
field_name : fringe_stop_step
width: g_fs_step_w
address_length: g_nof_channels
field_description: |
"Contains the step size for all nof_channels channels."
slave_discription: |
" "
slave_discription: " "
ram_fringe_stop_offset:
-
slave_prefix : FRINGE_STOP
slave_name : OFFSET # fringe_stop_offset
slave_postfix: RAM
slave_type : RAM
fields:
fringe_stop_offset:
-
field_name: fringe_stop_offset
width: g_fs_offset_w
address_length: g_nof_channels
field_description: |
"Contains the offset for all nof_channels channels."
slave_discription: |
" "
slave_discription: " "
peripheral_description: |
"The fringe stopping peripheral is based on piecewise linear coefficients. The coefficients are indicated as offset and step.
The offset and step are used to calculate an index that is used to select a certain phase from a look-up table. The look-up
......
protocol_name : args
protocol_version: 1.0
protocol_type : peripheral
---
ppsh:
name: ppsh_mms
library_name : ppsh
library_description: " This is the description for the finppshge_stop library "
peripherals:
-
peripheral_component_name: ppsh
parameters:
g_cross_clock_domain: TRUE
g_st_clk_freq : 200 * 10**6
- { name: g_cross_clock_domain, value: TRUE }
- { name: g_st_clk_freq, value: 200 * 10**6 }
slave_ports:
reg_ppsh:
-
slave_prefix : PPSH
slave_name : PPSH # reg_ppsh
slave_postfix: REG
slave_type : REG
fields:
status:
-
field_name : status
access_mode : RO
address_offset: 0x0
field_description: |
" ppsh status "
control:
field_description: " ppsh status "
-
field_name : control
address_offset: 0x1
field_description: |
" ppsh control "
slave_discription: |
" "
field_description: " ppsh control "
slave_discription: " "
peripheral_description: |
"
......
......@@ -39,11 +39,10 @@ logger = logging.getLogger('main.peripheral')
class BaseObject(object):
def __init__(self, _name):
def __init__(self):
self.success = True
self._base_name = _name
self._name = _name
self._postfix = ""
self._name = ""
self._prefix = ""
self._args = {}
def update_args(self, args):
......@@ -92,10 +91,6 @@ class BaseObject(object):
return self._as_str(key)
return self._args[key]
def base_name(self):
""" get base_name """
return self._base_name
def name(self, val=None):
""" set/get name """
if val is not None:
......@@ -103,19 +98,20 @@ class BaseObject(object):
return
return self._name
def postfix(self, val=None):
""" set/get postfix """
def prefix(self, val=None):
""" set/get prefix """
if val is not None:
self._postfix = val
self._prefix = val
return
return self._postfix
return self._prefix
class Field(BaseObject):
""" A field defines data at certain address or an array of addresses
"""
def __init__(self, name, settings=None):
super().__init__(name)
super().__init__()
self.name(name)
self._valid_keys = ['number_of_fields', 'width', 'bit_offset', 'access_mode', 'side_effect', 'address_offset',
'address_length', 'reset_value', 'software_value', 'radix', 'field_description']
......@@ -253,7 +249,8 @@ class Register(BaseObject):
""" A register consists of Fields
"""
def __init__(self, name, fields=None, settings=None):
super().__init__(name)
super().__init__()
self.name(name)
self.fields = {} if fields is None else fields
......@@ -306,7 +303,8 @@ class RAM(BaseObject):
""" A RAM is a Field that is repeated address_length times
"""
def __init__(self, name, fields=None, settings=None):
super().__init__(name)
super().__init__()
self.name(name)
self.fields = {} if fields is None else fields
......@@ -407,22 +405,27 @@ class Peripheral(BaseObject):
The Peripheral evaluates the nof_inst and parameters to set the
dimensions of the MM slaves.
"""
def __init__(self, peripheral_config):
base_name = list(peripheral_config.keys())[0]
super().__init__(base_name)
def __init__(self, library_config):
super().__init__()
self._config = {} # read config from file
self._parameters = {} # all used parameters
self.registers = {} # all used registers
self.rams = {} # all used rams
self.fifos = {} # all used fifos
self._component_name = library_config['peripheral_component_name']
self.name(self._component_name)
self._valid_keys = ['number_of_peripherals']
self._args.update({'number_of_peripherals' : DEFAULT_NUMBER_OF_PERIPHERALS})
self._config = peripheral_config[self.base_name()]
logger.debug("extract config for %s", self.base_name())
self._config = library_config # [self.component_name()]
logger.debug("extract config for %s", self.component_name())
self.extract_config()
def component_name(self):
""" get component_name """
return self._component_name
def number_of_peripherals(self, val=None):
""" set/get number of peripherals """
if val is not None:
......@@ -477,70 +480,68 @@ class Peripheral(BaseObject):
# keys with '.' in the name indicate the use of a structs
# inside this class it is a dict in a dict
for key2, val2 in _parameters.items():
if '.' in key2:
_struct, _key = key2.split('.')
for parameter_set in _parameters:
#print(parameter_set)
name = parameter_set['name']
value = parameter_set['value']
if '.' in name:
_struct, _name = name.split('.')
if _struct not in self._parameters:
self._parameters[_struct] = {}
# structs available now in self._parameters
remove_list = []
for key2, val2 in _parameters.items():
try:
if '.' in key2: # struct notation with dot
_struct, _key = key2.split('.')
self._parameters[_struct][_key] = int(str(val2), 10)
elif isinstance(val2, dict): # struct notation with dict
for _key, _val in val2.items():
self._parameters[key2][_key] = int(str(_val), 10)
for parameter_set_nr, parameter_set in enumerate(_parameters):
name = parameter_set['name']
value = parameter_set['value']
if '.' in name: # struct notation with dot
_struct, _name = name.split('.')
self._parameters[_struct][_name] = self._eval(str(value))
else:
self._parameters[key2] = int(str(val2), 10)
remove_list.append(key2)
except:
pass
self._parameters[name] = self._eval(str(value))
remove_list.append((parameter_set_nr, name))
for key2 in remove_list:
logger.debug("delete '%s' from parameters", key2)
del _parameters[key2]
remove_list = []
for key2, val2 in _parameters.items():
try:
if '.' in key2:
_struct, _key = key2.split('.')
self._parameters[_struct][_key] = self._eval(str(val2))
else:
self._parameters[key2] = self._eval(str(val2))
remove_list.append(key2)
except:
pass
# print(self.parameters)
for key2 in remove_list:
logger.debug("delete '%s' from parameters", key2)
del _parameters[key2]
for parameter_set_nr, name in sorted(remove_list, reverse=True):
logger.debug("delete '%s' from parameters", name)
del _parameters[parameter_set_nr]
for key2, val in _parameters.items():
logger.debug("eval of key=%s and val=%s not posible", key2, val)
for parameter_set in _parameters:
name = parameter_set['name']
value = parameter_set['value']
logger.debug("eval of name=%s and value=%s not posible", name, value)
if 'slave_ports' in self._config:
slave_ports = deepcopy(self._config['slave_ports'])
if not isinstance(slave_ports, dict):
logger.error("slave_ports not a dict")
if not isinstance(slave_ports, list):
logger.error("slave_ports not a list")
for slave_name, slave_info in slave_ports.items():
for slave_info in slave_ports:
logger.debug("slave_prefix=%s, slave_name=%s, slave_postfix=%s",
slave_info['slave_prefix'], slave_info['slave_name'], slave_info['slave_postfix'])
logger.debug("name=%s, info=%s", type(slave_name), type(slave_info))
logger.debug("name=%s, info=%s", slave_name, str(slave_info))
# make full name, dot sepperated
slave_name = []
for name in ('slave_prefix', 'slave_name', 'slave_postfix'):
if slave_info[name] in (None, ''):
slave_name.append('')
else:
slave_name.append(slave_info[name])
slave_name = '.'.join(slave_name)
if slave_info['slave_type'] in ('REG', 'RAM'):
number_of_slaves = self._eval(slave_info.get('number_of_slaves', DEFAULT_NUMBER_OF_SLAVES))
fields = {}
if 'fields' in slave_info:
for field_name, field_info in slave_info['fields'].items():
logger.debug("field_name=%s, params=%s", field_name, str(field_info))
for field_info in slave_info['fields']:
logger.debug("field_info=%s", str(field_info))
field_name = field_info['field_name']
field = Field(field_name)
for key, val in field_info.items():
if key == 'field_name':
continue
if key == 'width':
field.width(val)
elif key == 'bit_offset':
......@@ -640,23 +641,27 @@ class Peripheral(BaseObject):
field.address_length(val=ceil_pow2(self._eval(field.address_length())))
field.width(val=self._eval(field.width()))
ram_name = []
if self.prefix() not in (None, ''):
ram_name.append(self.prefix().upper())
ram_name.append(ram.name())
ram.name('.'.join(ram_name))
fields_eval = {}
postfix = ['','','']
for peri_nr in range(self.number_of_peripherals()):
postfix[0] = ''
_field_name = ['', '', '', '', '']
if self.number_of_peripherals() > 1:
postfix[0] = ".{}".format(peri_nr)
_field_name[1] = ".{}".format(peri_nr)
for ram_nr in range(ram.number_of_slaves()):
postfix[1] = ''
if ram.number_of_slaves() > 1:
postfix[1] = ".{}".format(ram_nr)
_field_name[2] = ".{}".format(ram_nr)
for field_name, field in ram.fields.items():
_field_name[0] = field_name
for field_nr in range(field.number_of_fields()):
postfix[2] = ''
if field.number_of_fields() > 1:
postfix[2] = ".{}".format(field_nr)
_field_name[3] = ".{}".format(field_nr)
_field = deepcopy(field)
_field.name("{}{}{}{}".format(field_name, *postfix))
_field.name("{}{}{}{}{}".format(*_field_name).strip())
fields_eval[_field.name()] = _field
ram.fields = fields_eval # Update the fields with evaluated fields
......@@ -675,24 +680,28 @@ class Peripheral(BaseObject):
field.address_length(val=ceil_pow2(self._eval(field.address_length())))
field.width(val=self._eval(field.width()))
register_name = []
if self.prefix() not in (None, ''):
register_name.append(self.prefix().upper())
register_name.append(register.name())
register.name('.'.join(register_name))
fields_eval = {}
offset = 0
postfix = ['','','']
for peri_nr in range(self.number_of_peripherals()):
postfix[0] = ''
_field_name = ['', '', '', '', '']
if self.number_of_peripherals() > 1:
postfix[0] = ".{}".format(peri_nr)
_field_name[1] = ".{}".format(peri_nr)
for reg_nr in range(register.number_of_slaves()):
postfix[2] = ''
if register.number_of_slaves() > 1:
postfix[1] = ".{}".format(reg_nr)
_field_name[2] = ".{}".format(reg_nr)
for field_name, field in register.fields.items():
_field_name[0] = field_name
for field_nr in range(field.number_of_fields()):
postfix[2] = ''
if field.number_of_fields() > 1:
postfix[2] = ".{}".format(field_nr)
_field_name[3] = ".{}".format(field_nr)
_field = deepcopy(field)
_field.name("{}{}{}{}".format(field_name, *postfix))
_field.name("{}{}{}{}{}".format(*_field_name).strip())
_field.address_offset(offset)
offset += 1
fields_eval[_field.name()] = _field
......@@ -706,6 +715,7 @@ class Peripheral(BaseObject):
"""Evaluate name, label, nof_inst and the parameters to determine the true size of
the RAMs and the register width and the name of the peripheral, registers and RAMS """
logger.debug(" Evaluating peripheral '%s'", self.name())
self.eval_ram()
self.eval_register()
......@@ -808,9 +818,10 @@ class PeripheralLibrary(object):
if file_path_names is None:
file_path_names = self.file_path_names
for fpn in self.file_path_names:
for peripheral_config in yaml.load_all(open(fpn, 'r')):
library_config = yaml.load(open(fpn, 'r'))
for peripheral_config in library_config['peripherals']:
peripheral = deepcopy(Peripheral(peripheral_config))
peripherals[peripheral._name] = peripheral
peripherals[peripheral.component_name()] = peripheral
return peripherals
def find_peripheral(self, name, peripheral_library=None):
......
......@@ -143,7 +143,7 @@ class RomSystem(object):
n_sets = int(len(data) / 3)
for i in range(n_sets):
name, addr, span = data[i*3:i*3+3]
print(name, addr, span)
#print(name, addr, span)
qsys_reg[name] = [int(addr, 16), int(span, 10)]
except IOError:
logger.error("filename '%s' does not excists", filename)
......@@ -158,14 +158,18 @@ class RomSystem(object):
peripherals = self.system.peripherals
peripheral = peripherals['mms_reg_system_info']
#print("================")
#print(peripherals.keys())
peripheral = peripherals['reg_system_info']
#print(peripheral.registers)
base_address = int(peripheral.parameter('lock_base_address'))
size = int(peripheral.registers['reg_system_info'].fields['field_reg_info'].get_kv('address_length')) # TODO: if not available calculate real size
size = int(peripheral.registers['.REG_SYSTEM_INFO.'].fields['field_reg_info'].get_kv('address_length')) # TODO: if not available calculate real size
memory_mapper.add(name="REG_SYSTEM_INFO", size=size, nof_instances=1, base_address=base_address)
peripheral = peripherals['mms_rom_system_info']
peripheral = peripherals['rom_system_info']
base_address = int(peripheral.parameter('lock_base_address'))
size = int(peripheral.registers['rom_system_info'].fields['field_rom_info'].get_kv('address_length')) # TODO: if not available calculate real size
size = int(peripheral.registers['.ROM_SYSTEM_INFO.'].fields['field_rom_info'].get_kv('address_length')) # TODO: if not available calculate real size
memory_mapper.add(name="ROM_SYSTEM_INFO", size=size, nof_instances=1, base_address=base_address)
size_info = []
......@@ -178,8 +182,8 @@ class RomSystem(object):
n_words = int(ceil(float(fval.width()) / self.word_size))
n_addresses += n_words * fval.address_length()
nof_inst = rval.number_of_slaves() * peripheral.number_of_peripherals()
_name = rval.name() + peripheral.postfix()
print("%s %s" % (str(rkey), str(n_addresses)))
_name = rval.name()
#print("%s %s" % (str(rkey), str(n_addresses)))
size_info.append([n_addresses, nof_inst, _name])
for rkey, rval in peripheral.registers.items():
......@@ -191,19 +195,48 @@ class RomSystem(object):
n_addresses += 1
nof_inst = rval.number_of_slaves() * peripheral.number_of_peripherals()
_name = rval.name() + peripheral.postfix()
print("%s %s" % (str(rkey), str(n_addresses * n_words)))
_name = rval.name()
if _name.upper() in ('.REG_SYSTEM_INFO.', '.ROM_SYSTEM_INFO.', 'REG_SYSTEM_INFO', 'ROM_SYSTEM_INFO'):
continue
#print("%s %s" % (str(rkey), str(n_addresses * n_words)))
size_info.append([(n_addresses * n_words), nof_inst, _name])
size_info.sort(reverse=True)
for size, nof_inst, name in size_info:
if use_qsys_base_address:
base_address, qsys_size = self.qsys_reg.get(name.upper(), [None, None])
_name = name.split('.')
for i in range(len(_name)-1, -1, -1):
if _name[i] == '':
del _name[i]
_qsys_name = []
if len(_name) == 1:
_qsys_name.append(_name[0])
name = _name[0]
elif len(_name) == 2:
_qsys_name.append(_name[1])
_qsys_name.append(_name[0])
elif len(_name) == 3:
_qsys_name.append(_name[2])
_qsys_name.append(_name[0])
_qsys_name.append(_name[1])
elif len(_name) == 4:
_qsys_name.append(_name[3])
_qsys_name.append(_name[1])
_qsys_name.append(_name[2])
_qsys_name.append(_name[0])
else:
logger.error("Unknows size for %s %s", _name, name)
qsys_name = '_'.join(_qsys_name).upper()
#else:
# qsys_name = name.upper()
base_address, qsys_size = self.qsys_reg.get(qsys_name, [None, None])
if base_address is None:
logger.error("%s not known in qsys.reg", name.upper())
logger.error("%s(%s) not known in qsys.reg", qsys_name, name)
else:
base_address = None
print(base_address, qsys_size, size)
#print(name, base_address, qsys_size, size)
memory_mapper.add(name=name, size=size, nof_instances=nof_inst, base_address=base_address)
self.address_list = memory_mapper.get_memory_map()
......@@ -221,8 +254,6 @@ class RomSystem(object):
# [start_address, stop_address, size, name, nof_instances]
for start_address, stop_address, size, name, nof_instances in self.address_list:
if name in ('REG_SYSTEM_INFO', 'ROM_SYSTEM_INFO'):
continue
# logger.debug("i=%s", str(i))
if version is None:
self.rom_system_info.append("{0} {1:x} {2}".format(name.upper(),
......
......@@ -76,8 +76,8 @@ class System(object):
""" Create a system object based on the information in the system_config """
logger.debug("Creating system")
logger.debug("Instantiating the peripherals from the peripheral Library")
self.system_name = list(self.system_config.keys())[0]
config = self.system_config[self.system_name]
self.system_name = self.system_config['library_name']
config = self.system_config
if "system_description" in config:
self.system_description = copy.deepcopy(config['system_description'])
......@@ -87,66 +87,56 @@ class System(object):
# keys with '.' in the name indicate the use of a structs
# inside this class it is a dict in a dict
for key2, val2 in iter(_parameters.items()):
if '.' in key2:
_struct, _key = key2.split('.')
for parameter_set in _parameters:
name = parameter_set['name']
value = parameter_set['value']
if '.' in name:
_struct, _key = name.split('.')
if _struct not in self.parameters:
self.parameters[_struct] = {}
remove_list = []
for key2, val2 in iter(_parameters.items()):
try:
if '.' in key2: # struct notation with dot
_struct, _key = key2.split('.')
self.parameters[_struct][_key] = int(str(val2), 10)
elif isinstance(val2, dict): # struct notation with dict
for _key, _val in val2.items():
self.parameters[key2][_key] = int(str(_val), 10)
for parameter_set_nr, parameter_set in enumerate(_parameters):
name = parameter_set['name']
value = parameter_set['value']
if '.' in name: # struct notation with dot
_struct, _name = name.split('.')
self.parameters[_struct][_name] = self._eval(str(value))
else:
self.parameters[key2] = int(str(val2), 10)
remove_list.append(key2)
except:
pass
for key2 in remove_list:
logger.debug("delete '%s' from parameters", key2)
del _parameters[key2]
remove_list = []
for key2, val2 in iter(_parameters.items()):
try:
if '.' in key2:
_struct, _key = key2.split('.')
self.parameters[_struct][_key] = self._eval(str(val2))
else:
self.parameters[key2] = self._eval(str(val2))
remove_list.append(key2)
except:
pass
# print(self.parameters)
for key2 in remove_list:
logger.debug("delete '%s' from parameters", key2)
del _parameters[key2]
for key2, val2 in iter(_parameters.items()):
logger.debug("eval of key=%s and val=%s not posible", key2, val2)
self.parameters[name] = self._eval(str(value))
remove_list.append((parameter_set_nr, name))
for parameter_set_nr, name in sorted(remove_list, reverse=True):
logger.debug("delete '%s' from parameters", name)
del _parameters[parameter_set_nr]
for parameter_set in _parameters:
name = parameter_set['name']
value = parameter_set['value']
logger.debug("eval of name=%s and value=%s not posible", name, value)
logger.debug("parameters={}".format(self.parameters))
for system_name, peripheral_config in config['peripherals'].items():
for peripheral_config in config['peripherals']:
# (Deep)Copy the peripheral from the library in order to avoid creating a reference
base_name = peripheral_config['peripheral_name']
component_name = peripheral_config['peripheral_component_name']
component_prefix = peripheral_config['peripheral_prefix']
number_of_peripherals = int(self._eval(peripheral_config.get('number_of_peripherals', 1)))
peripheral_from_lib = copy.deepcopy(self.peri_lib.find_peripheral(base_name))
peripheral_from_lib = copy.deepcopy(self.peri_lib.find_peripheral(component_name))
if peripheral_from_lib is None:
logger.warning("component_name '%s' not found in library", base_name)
logger.warning("component_name '%s' not found in library", component_name)
continue
logger.debug(" Finding %s", peripheral_from_lib.name)
if 'parameters' in peripheral_config:
logger.debug("parameters={}".format(peripheral_config['parameters']))
for parameter_key, parameter_val in peripheral_config['parameters'].items():
peripheral_from_lib.parameter(key=parameter_key, val=self._eval(parameter_val))
for parameter_set in peripheral_config['parameters']:
name = parameter_set['name']
value = parameter_set['value']
peripheral_from_lib.parameter(key=name, val=self._eval(value))
#peripheral_from_lib.set_nof_instances(nof_instances)
#for i in range(nof_instances):
......@@ -154,20 +144,20 @@ class System(object):
# if nof_instances > 1:
# _system_name = "{}{}".format(system_name,i)
peripheral_from_lib.number_of_peripherals(number_of_peripherals)
peripheral_from_lib.name(system_name)
if base_name in system_name:
postfix = system_name[len(base_name):]
else:
postfix = "_{}".format(system_name)
peripheral_from_lib.postfix(postfix)
if system_name not in self.peripherals:
self.peripherals[system_name] = copy.deepcopy(peripheral_from_lib)
peripheral_from_lib.prefix(component_prefix)
peripheral_name = []
if component_prefix not in (None, ''):
peripheral_name.append(component_prefix)
peripheral_name.append(component_name)
peripheral_from_lib.name('.'.join(peripheral_name))
if peripheral_from_lib.name() not in self.peripherals:
self.peripherals[peripheral_from_lib.name()] = copy.deepcopy(peripheral_from_lib)
else:
logger.warning(" Duplicate found: use unique labels per instance to distinguish "
"between multiple instances of the same peripheral.\n"
" Cannot add a second instance of peripheral: %s",
peripheral_from_lib.component_name)
peripheral_from_lib.name())
logger.debug("Start evaluating the peripherals")
for peripheral_config in self.peripherals.values():
......
---
mms_rom_system_info:
protocol_name : args
protocol_version: 1.0
protocol_type : peripheral
library_name : system_info
library_description: " This is the description for the system_info library "
peripherals:
-
peripheral_component_name: rom_system_info
parameters:
lock_base_address: 0x1000
- { name: lock_base_address, value: 0x1000 }
slave_ports:
rom_system_info:
-
slave_prefix :
slave_name : ROM_SYSTEM_INFO # rom_system_info
slave_postfix:
slave_type : REG
fields:
field_rom_info:
-
field_name : field_rom_info
access_mode : RO
address_offset: 0x0
address_length: 4096
......@@ -17,17 +29,20 @@ mms_rom_system_info:
peripheral_description: |
" settings for rom_system_info register "
---
mms_reg_system_info:
-
peripheral_component_name: reg_system_info
parameters:
lock_base_address: 0x0
- { name: lock_base_address, value: 0x0 }
slave_ports:
reg_system_info:
-
slave_prefix :
slave_name : REG_SYSTEM_INFO # reg_system_info
slave_postfix:
slave_type : REG
fields:
field_reg_info:
-
field_name : field_reg_info
access_mode : RO
address_offset: 0x0
address_length: 128
......
---
mms_unb1_board_sens:
protocol_name : args
protocol_version: 1.0
protocol_type : peripheral
library_name : work
library_description: " This is the description for the work package "
peripherals:
-
peripheral_component_name: unb1_board_sens
parameters:
g_temp_high: 85
- { name: g_temp_high, value: 85 }
slave_ports:
reg_unb1_sens:
-
slave_prefix : WORK
slave_name : UNB1_SENS # reg_unb1_sens
slave_postfix: REG
slave_type : REG
fields:
sens_data:
-
field_name : sens_data
width : 8
access_mode : R
address_offset: 0x0
......@@ -19,23 +31,22 @@ mms_unb1_board_sens:
0x1 = eth_temp temperature in degrees (two's complement)
0x2 = hot_swap_v_sens
0x3 = hot_swap_v_source"
sens_err:
-
field_name : sens_err
width : 1
access_mode : R
address_offset: 0x4
radix : unsigned
field_description: |
""
temp_high:
-
field_name : temp_high
width : 7
address_offset: 0x5
default_value : g_temp_high
field_description: |
""
slave_description: |
" "
slave_description: " "
peripheral_description: |
"
+-----------------------------------------------------------------------------+
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment