Commit 16c5f208 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

Added per-tool configuration of the hierarchical name parsers,

implemented some parsing of the ISE output
parent adef049e
Loading
Loading
Loading
Loading
+154 −4
Original line number Diff line number Diff line
#!/usr/bin/env python
##/usr/bin/python -u
import sys
import re
patternBit=re.compile("_\d+$")

START_REF="<"
END_REF=">"
#PREFIX_REF="@{"
#SUFFIX_REF="}@"
PREFIX_REF=""
SUFFIX_REF=""
MODE_IMMED=0
MODE_SINGLE=1
MODE_ONCE=2
MODE_POSTPONE=3
tool="EXTERNAL_TOOL"
if len(sys.argv)>1:
    tool=sys.argv[1]
try:
    global_top_module=int(sys.argv[2])
except:
    global_top_module=""
    
try:
    global_mode=int(sys.argv[3])
except:
    global_mode=MODE_POSTPONE # MODE_SINGLE

global_db={}
global_pRef=()        


def isProblem(string):
    if string.startswith("ERROR:") or string.startswith("WARNING:") or string.startswith("INFO:"):
@@ -13,7 +39,97 @@ def hasLine(string):
    if '" Line ' in string:
        return True
    return False
def addTool(string,tool):

def getLineSignalBitISE(string):
#    sys.stdout.write(START_REF)
    if START_REF in string:
        start1 = string.find(START_REF)
        end1 = string.find(END_REF,start1)
        if end1 <0:
            return None
        line=string[:start1]+PREFIX_REF+"%s"+SUFFIX_REF+string[end1+len(END_REF):]
        ref=string[start1+len(START_REF):end1]
        # Assuming <...> in block <...>
        start2= string.find(START_REF,end1)
        if start2>=0 :
            end2 = string.find(END_REF,start2)
            if end2>=0:
                ref=string[start2+len(START_REF):end2]+"/"+ref
            else:
                pass # Use global_top_module ?
        # replace "/" (used in Xilinx ISE) with "." for Verilog
        ref=ref.replace("/",".")
        #Extract bit number - onluy apply to the last segment?
        #pattern.search("outreg_29").start()
        match = patternBit.search(ref)
        if match:
            pos=match.start()
            bit=int(ref[pos+1:])
            ref=ref[:pos]+"[%s]"
        else:
            bit=-1
        return (line,ref,bit)
    else:
        return None

def addRef(pRef):
    global global_db
#TODO: put try on all    
    if pRef:
        if not pRef[0] in global_db:
            global_db[pRef[0]]={}
        line_type=global_db[pRef[0]]
        if not pRef[1] in line_type:
            line_type[pRef[1]]=set()
        line_type[pRef[1]].add(pRef[2])
def getRanges(pRef):
    global global_db
    try:
        s=global_db[pRef[0]][pRef[1]]
    except:
        s=set();
    ranges=[];
    while s:
        l=min(s)
        s.remove(l)
        h=l+1
        while h in s:
            s.remove(h)
            h=h+1
        ranges.append((l,h))
    return ranges        
            
def printLineRef(pRef): # modified from Vivado, no global_top_module
    global global_pRef
    global global_mode
    global global_db
    global global_top_module
    if pRef:
        ranges=getRanges(pRef)
        if ranges:
#            line=pRef[0]
            ref=pRef[1];
#            if global_top_module:
#                ref= global_top_module+"."+ref
            for rng in ranges:
                if (rng[0]<0):
                    sys.stdout.write(pRef[0]%(ref))
                elif (rng[1]<=(rng[0]+1)):
                    sys.stdout.write(pRef[0]%(ref%(rng[0])))
                else:
                    sys.stdout.write(pRef[0]%(ref%("%d:%d"%(rng[1]-1,rng[0]))))
            if (global_mode == MODE_ONCE):
                for rng in ranges:
                    try:
                        global_db[pRef[0]][pRef[1]] -= set(range(rng[0],rng[1]))
                        if not global_db[pRef[0]][pRef[1]]:
                            global_db[pRef[0]].pop(pRef[1])
                            if not global_db[pRef[0]]:
                                global_db.pop(pRef[0])
                    except:
                        pass

def addTool0(string,tool):
    if hasLine(string):
        return string
    else:
@@ -21,16 +137,50 @@ def addTool(string,tool):
        return string[:index]+(" \"%s\" Line 0000:"%tool)+string[index:]
#        return string[:len(string)-1]+(" \"%s\" Line 0000:"%tool)+"\n"

def addToolISE(string,tool):
    global global_pRef
    global global_mode
    if " line " in string:
        string=string.replace (" line "," Line ")
    if hasLine(string):
        if ((global_mode == MODE_SINGLE) or (global_mode == MODE_ONCE))  and global_pRef:
            printLineRef(global_pRef)
            global_pRef=None
        return string
    else:
#        return string[:len(string)-1]+"[%s:0000]"%tool+string[len(string)-1]
        if (string):
            index=string.find(" - ")+3
            string=string[:index]+(" \"%s\" Line 0000:"%tool)+string[index:]
        if global_mode != MODE_IMMED: 
            parseRef=getLineSignalBitISE(string)
        if (global_mode != MODE_IMMED) and parseRef:
            addRef(parseRef)
            if ((global_mode != MODE_POSTPONE) and global_pRef and 
             ((parseRef[0] != global_pRef[0]) or(parseRef[1] != global_pRef[1]))) :
                printLineRef(global_pRef)
            global_pRef=parseRef
            return ""
        else:
            if ((global_mode == MODE_SINGLE) or (global_mode == MODE_ONCE))  and global_pRef:
                printLineRef(global_pRef)
                global_pRef=None
            return string
  
pline=""
for line in iter(sys.stdin.readline,''):
    if isProblem(pline):
        if line.startswith("   ") :
        if line.startswith("   ") and False : #This was taken from Vivado to merge lines, not so in ISE
            pline = pline[:len(pline)-1]+line[2:]
        else:
            sys.stdout.write(addTool(pline,tool))
            sys.stdout.write(addToolISE(pline,tool))
            pline = line
    else:
        pline = line
if isProblem(pline):
    sys.stdout.write(addTool(pline,tool))
    sys.stdout.write(addToolISE(pline,tool))
    addToolISE("",tool)
if global_mode == MODE_POSTPONE:
    for line in global_db:
        for ref in global_db[line]:
            printLineRef((line,ref,0)) # will not add
+24 −13
Original line number Diff line number Diff line
@@ -11,24 +11,26 @@ PREFIX_REF=""
SUFFIX_REF=""
MODE_IMMED=0
MODE_SINGLE=1
MODE_ONCE=1
MODE_ONCE=2
MODE_POSTPONE=3
tool="EXTERNAL_TOOL"
if len(sys.argv)>1:
    tool=sys.argv[1]
try:
    global_top_module=int(sys.argv[2])
except:
    global_top_module=""
    
try:
    global_mode=int(sys.argv[2])
    global_mode=int(sys.argv[3])
except:
    global_mode=MODE_POSTPONE # MODE_SINGLE

global_db={}
global_pRef=()        

try:
    global_top_module=int(sys.argv[3])
except:
    global_top_module="test_ps7"
sys.stdout.write("Running: %s %s %s %s\n" % (sys.argv[0],sys.argv[1],sys.argv[2],sys.argv[3]))


def isProblem(string):
    if string.startswith("ERROR:") or string.startswith("WARNING:") or string.startswith("INFO:"):
@@ -102,10 +104,9 @@ def printLineRef(pRef):
    global global_db
    global global_top_module
    if pRef:
#        add(pRef) # just in case
        ranges=getRanges(pRef)
        if ranges:
            line=pRef[0]
#            line=pRef[0]
            ref=pRef[1];
            if global_top_module:
                ref= global_top_module+"."+ref
@@ -159,6 +160,14 @@ def addTool(string,tool):
            return string


def debugSize():
    l=0
    for line in global_db:
        for ref in global_db[line]:
            l+=len(global_db[line][ref])
    return l


#### Start
pline=""
for line in iter(sys.stdin.readline,''):
@@ -167,6 +176,7 @@ for line in iter(sys.stdin.readline,''):
            pline = pline[:len(pline)-1]+line[2:]
        else:
            pline=addTool(pline,tool)
#            sys.stdout.write("*"+str(debugSize())+pline)
            sys.stdout.write(pline)
            pline = line
    else:
@@ -179,4 +189,5 @@ if global_mode == MODE_POSTPONE:
    for line in global_db:
        for ref in global_db[line]:
            printLineRef((line,ref,0)) # will not add
#            printLineRef((line,ref,0)) # will not add
+2 −1
Original line number Diff line number Diff line
@@ -108,7 +108,8 @@ public class ComboComponent extends GeneralComponent {
            item = param.getDefaultValue(null).get(0); // null for topFormatProcessor

        ParamTypeEnum type = (ParamTypeEnum)param.getType();
        int pos = type.getLabelIndex(item);
//        int pos = type.getLabelIndex(item);
        int pos = type.getValueIndex(item);
        String[] values = type.getValues();
        
        return values[pos];
+17 −0
Original line number Diff line number Diff line
@@ -93,6 +93,23 @@
		<parameter	id="intstyle"/>      <!-- USED Bitgen -->
        <parameter	id="command_files"/> <!-- USED Bitgen-->
        <parameter	id="speed_grade"/>
<!-- parser parameters - will have different values than the base tool -->
        <parameter id="parsers_path"/>
        <parameter id="parser_name"/>
        <parameter id="PatternErrors"/>
        <parameter id="PatternWarnings"/>
        <parameter id="PatternInfo"/>
        <parameter id="InstanceCapture"/>
        <parameter id="InstanceSeparator"/>
        <parameter id="InstanceSuffix"/>
        <parameter id="parser_mode"/>
        <parameter id="NoFileProblem"/>
        <parameter id="OtherProblems"/>
        <parameter id="ShowWarnings"/>
        <parameter id="ShowInfo"/>
        <parameter id="PreGrepW"/>
        <parameter id="PreGrepI"/>
        <parameter id="GrepEWI"/>

<!-- calculated parameters -->        			
   	    <parameter  id="ISEBitgenActionIndex" default="%%ChosenActionIndex"
+8 −0
Original line number Diff line number Diff line
@@ -40,6 +40,14 @@
    	<typedef name = "Cardinal_M1_100">
            <paramtype kind="number" lo="-1" hi="100" format="%d" />
        </typedef>
	    <typedef name="ParserModeType">
      		<paramtype kind= "enum" base="String">
      			<item value="0"   label="Tool output is parsed immediately"/>
      			<item value="1"   label="Tool output is delayed by not more than 1 line when consolidating bits"/>
      			<item value="2"   label="As '1', but do not show same bits again"/>
      			<item value="3"   label="All tool output containg hierarchical output is delayed to the very end"/>
      		</paramtype>
    	</typedef>
    	
	 <syntax name="DashNamePart"    format="-%%ParamName %part" />

Loading