示例#1
0
def p_signal_decl(p):
    ''' signal_decl    : WIRE VECTOR IDENTIFIER ';'
                       | WIRE IDENTIFIER ';'
    '''
    if len(p)==5:
        p[0]=cc.signal(name=p[3],vector=p[2])
    else:
        p[0]=cc.signal(name=p[2],vector=None)
示例#2
0
def p_signal_decl(p):
    ''' signal_decl    : WIRE VECTOR IDENTIFIER ';'
                       | WIRE IDENTIFIER ';'
    '''
    if len(p) == 5:
        p[0] = cc.signal(name=p[3], vector=p[2])
    else:
        p[0] = cc.signal(name=p[2], vector=None)
示例#3
0
def p_port_decl(p):
    '''port_decl     : INPUT  IDENTIFIER ';'
                     | INPUT  VECTOR IDENTIFIER ';'
                     | OUTPUT IDENTIFIER ';'
                     | OUTPUT VECTOR IDENTIFIER ';'
                     | INOUT  IDENTIFIER ';'
                     | INOUT  VECTOR IDENTIFIER ';'
    '''
    if len(p)==5:
        tmp=cc.signal(s_type=p[1],name=p[3],vector=p[2])
        p[0]=tmp.signal_2_port()

    else:
        tmp=cc.signal(s_type=p[1],name=p[2],vector=None)    
        p[0]=tmp.signal_2_port()
示例#4
0
def p_port_decl(p):
    '''port_decl     : INPUT  IDENTIFIER ';'
                     | INPUT  VECTOR IDENTIFIER ';'
                     | OUTPUT IDENTIFIER ';'
                     | OUTPUT VECTOR IDENTIFIER ';'
                     | INOUT  IDENTIFIER ';'
                     | INOUT  VECTOR IDENTIFIER ';'
    '''
    if len(p) == 5:
        tmp = cc.signal(s_type=p[1], name=p[3], vector=p[2])
        p[0] = tmp.signal_2_port()

    else:
        tmp = cc.signal(s_type=p[1], name=p[2], vector=None)
        p[0] = tmp.signal_2_port()
示例#5
0
def p_signal_element(p):
    '''signal_element : IDENTIFIER BIT
                      | IDENTIFIER VECTOR
                      | IDENTIFIER
    '''
    if len(p)==3:
        p[0]=cc.signal(name=p[1],vector=p[2])
    else:
        # 匹配,使得连在一起的 ID-VEC:ID[\d+]等够将ID VEC分开
        linked_id_vec = re.match("(.+)(\[\d+\])$",p[1])
        if linked_id_vec is not None:
            iden = linked_id_vec.groups()[0]
            vec = linked_id_vec.groups()[1]
            p[0] = cc.signal( name = iden ,vector = vec)
        else:
            p[0]=cc.signal(name=p[1])
示例#6
0
def p_signal_element(p):
    '''signal_element : IDENTIFIER BIT
                      | IDENTIFIER VECTOR
                      | IDENTIFIER
    '''
    if len(p) == 3:
        p[0] = cc.signal(name=p[1], vector=p[2])
    else:
        # 匹配,使得连在一起的 ID-VEC:ID[\d+]等够将ID VEC分开
        linked_id_vec = re.match("(.+)(\[\d+\])$", p[1])
        if linked_id_vec is not None:
            iden = linked_id_vec.groups()[0]
            vec = linked_id_vec.groups()[1]
            p[0] = cc.signal(name=iden, vector=vec)
        else:
            p[0] = cc.signal(name=p[1])
示例#7
0
def p_assign_stm(p):
    ''' assign_stm      : ASSIGN signal_element '=' signal_element ';'
                        | ASSIGN signal_element '=' BIN_NUMBER ';'    
    '''
    if isinstance(p[4],cc.signal):
        p[0]=cc.assign("assign",p[2],p[4])
    else:
        p[0]=cc.assign("assign",p[2],cc.signal(name=p[4]))
示例#8
0
def p_assign_stm(p):
    ''' assign_stm      : ASSIGN signal_element '=' signal_element ';'
                        | ASSIGN signal_element '=' BIN_NUMBER ';'    
    '''
    if isinstance(p[4], cc.signal):
        p[0] = cc.assign("assign", p[2], p[4])
    else:
        p[0] = cc.assign("assign", p[2], cc.signal(name=p[4]))