OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [config/] [config_check.py] - Blame information for rev 3

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
#! /usr/bin/env python2.6
2
# -*- mode: python; coding: utf-8; -*-
3
import os, sys, re
4
 
5
from projpaths import *
6
from lib import *
7
 
8
def get_conts_memory_regions(phys_virt, array_start, array_end):
9
    with open(join(PROJROOT, CONFIG_H), 'r')as file:
10
        for line in file:
11
            begin = line.rfind(" ")
12
            end = len(line)
13
            if re.search("(" + phys_virt + ")([0-9]){1,4}(_START)", line):
14
                array_start.append(int(line[begin : end], 16))
15
            elif re.search("(" + phys_virt + ")([0-9]){1,4}(_END)", line):
16
                array_end.append(int(line[begin : end], 16))
17
 
18
def check_memory_overlap(phys_virt,  array_start, array_end):
19
    length = len(array_start)
20
    # Brute force method
21
    for index, s1 in enumerate(array_start):
22
        e1 = array_end[index]
23
        iter = 0
24
        while iter < length:
25
            if index == iter:
26
                iter = iter + 1
27
                continue
28
            if ((s1 <= array_start[iter]) and \
29
                ((e1 >= array_end[iter]) or (array_start[iter] < e1 <= array_end[iter]))):
30
                print 'Memory overlap between containers!!!'
31
                print 'overlapping ranges: '+ \
32
                    conv_hex(s1) + '-' + conv_hex(e1) + ' and ' + \
33
                    conv_hex(array_start[iter]) + '-' + conv_hex(array_end[iter])
34
                print '\n'
35
                sys.exit()
36
            else:
37
                iter = iter + 1
38
 
39
def phys_region_sanity_check():
40
    phys_start = []
41
    phys_end = []
42
    get_conts_memory_regions('PHYS', phys_start, phys_end)
43
    check_memory_overlap('PHYS', phys_start, phys_end)
44
 
45
def virt_region_sanity_check():
46
    virt_start = []
47
    virt_end = []
48
    get_conts_memory_regions('VIRT', virt_start, virt_end)
49
    check_memory_overlap('VIRT', virt_start, virt_end)
50
 
51
def sanity_check_conts():
52
    phys_region_sanity_check()
53
    virt_region_sanity_check()
54
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.