<commit_before>#! /usr/bin/python

import yaml
import os

class MemMap(object):

    def __init__(self, name_, offset_, range_):
        self.name = name_
        self.offset = offset_
        self.range = range_
        self.display()

    def display(self):
        msg = 'map {} at offset {} and range {}'
        print(msg.format(self.name, self.offset, self.range))

class ProjectConfig(object):
 
    def __init__(self, project):
        self.load(project)

    def load(self, project):
        self.project = project
        config_filename = os.path.join('projects', project, 'main.yml')         
        with open(config_filename) as config_file:
            dic = yaml.load(config_file)

        # List of memory maps
        self.mmaps = []

        # Config and Status registers
        self.cfg = {}
        self.sts = {}
        
        for addr in dic['addresses']:
            self.mmaps.append(MemMap(addr['name'], addr['offset'], addr['range']))

        for i, offset in enumerate(dic['config_offsets']):
            self.cfg[offset] = 4 * i

        for i, offset in enumerate(dic['status_offsets']):
            self.sts[offset] = 4 * (10 + i)

        self.sts['bitstream_id'] = 0
        self.sts['dna'] = 4 * 8
<commit_msg>replace config_offsets with config_registers (#195)<commit_after>#! /usr/bin/python

import yaml
import os

class MemMap(object):

    def __init__(self, name_, offset_, range_):
        self.name = name_
        self.offset = offset_
        self.range = range_
        self.display()

    def display(self):
        msg = 'map {} at offset {} and range {}'
        print(msg.format(self.name, self.offset, self.range))

class ProjectConfig(object):
 
    def __init__(self, project):
        self.load(project)

    def load(self, project):
        self.project = project
        config_filename = os.path.join('projects', project, 'main.yml')         
        with open(config_filename) as config_file:
            dic = yaml.load(config_file)

        # List of memory maps
        self.mmaps = []

        # Config and Status registers
        self.cfg = {}
        self.sts = {}
        
        for addr in dic['addresses']:
            self.mmaps.append(MemMap(addr['name'], addr['offset'], addr['range']))

        for i, name in enumerate(dic['config_registers']):
            self.cfg[name] = 4 * i

        for i, name in enumerate(dic['status_registers']):
            self.sts[name] = 4 * (10 + i)

        self.sts['bitstream_id'] = 0
        self.sts['dna'] = 4 * 8

{'fraction_non_alphanumeric': 0.1308300395256917, 'fraction_numerical': 0.0067193675889328066, 'mean_word_length': 2.151930261519303, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1646483', 'n_tokens_mistral': 800, 'n_tokens_neox': 755, 'n_words': 188}