Class: VerilogTools::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/HDLRuby/verilog_parser.rb

Overview

The class of the parser.

Constant Summary collapse

FS_TIME =

The table of time conversion.

{
  "s"  => 1_000_000_000_000_000,
  "ms" => 1_000_000_000_000,
  "us" => 1_000_000_000,
  "ns" => 1_000_000,
  "ps" => 1_000,
  "fs" => 1
}
COMMA_TOK =

Definition of the tokens

","
SEMICOLON_TOK =
";"
COLON_TOK =
":"
OPEN_PAR_TOK =
"("
CLOSE_PAR_TOK =
")"
OPEN_BRA_TOK =
"["
CLOSE_BRA_TOK =
"]"
OPEN_CUR_TOK =
"{"
CLOSE_CUR_TOK =
"}"
SHARP_TOK =
"#"
AT_TOK =
"@"
DOT_TOK =
"."
EE_TOK =
"E"
Ee_TOK =
"e"
SLASH_TOK =
"/"
SLASH_SLASH_TOK =
"//"
SLASH_ASTERISK_TOK =
"/*"
ASTERISK_SLASH_TOK =
"*/"
EOL_TOK =
"\n"
MODULE_TOK =
"module"
MACROMODULE_TOK =
"macromodule"
ENDMODULE_TOK =
"endmodule"
PRIMITIVE_TOK =
"primitive"
ENDPRIMITIVE_TOK =
"endprimitive"
TASK_TOK =
"task"
ENDTASK_TOK =
"endtask"
FUNCTION_TOK =
"function"
ENDFUNCTION_TOK =
"endfunction"
TABLE_TOK =
"table"
ENDTABLE_TOK =
"endtable"
SPECIFY_TOK =
"specify"
ENDSPECIFY_TOK =
"endspecify"
INPUT_TOK =
"input"
OUTPUT_TOK =
"output"
INOUT_TOK =
"inout"
INITIAL_TOK =
"initial"
SPECPARAM_TOK =
"specparam"
IF_TOK =
"if"
ELSE_TOK =
"else"
CASE_TOK =
"case"
CASEZ_TOK =
"casez"
CASEX_TOK =
"casex"
ENDCASE_TOK =
"endcase"
FOREVER_TOK =
"forever"
REPEAT_TOK =
"repeat"
WHILE_TOK =
"while"
FOR_TOK =
"for"
WAIT_TOK =
"wait"
RIGHT_ARROW_TOK =
"->"
DISABLE_TOK =
"disable"
ASSIGN_TOK =
"assign"
DEASSIGN_TOK =
"deassign"
FORCE_TOK =
"force"
RELEASE_TOK =
"release"
ALWAYS_TOK =
"always"
DEFAULT_TOK =
"default"
BEGIN_TOK =
"begin"
END_TOK =
"end"
FORK_TOK =
"fork"
JOIN_TOK =
"join"
SIGNED_TOK =
"signed"
REG_TOK =
"reg"
TIME_TOK =
"time"
INTEGER_TOK =
"integer"
REAL_TOK =
"real"
EVENT_TOK =
"event"
DEFPARAM_TOK =
"defparam"
PARAMETER_TOK =
"parameter"
SCALARED_TOK =
"scalared"
VECTORED_TOK =
"vectored"
SETUP_TOK =
"$setup"
HOLD_TOK =
"$hold"
PERIOD_TOK =
"$period"
WIDTH_TOK =
"$width"
SKEW_TOK =
"$skew"
RECOVERY_TOK =
"$recovery"
SETUPHOLD_TOK =
"$setuphold"
HYPHEN_TOK =
"-"
ZERO_TOK =
"0"
ONE_TOK =
"1"
Xx_TOK =
"x"
XX_TOK =
"X"
Bb_TOK =
"b"
BB_TOK =
"B"
QUESTION_TOK =
"?"
Rr_TOK =
"r"
RR_TOK =
"R"
Ff_TOK =
"f"
FF_TOK =
"F"
Pp_TOK =
"p"
PP_TOK =
"P"
Nn_TOK =
"n"
NN_TOK =
"N"
ASTERISK_TOK =
"*"
Q_b_TOK =
"'b"
Q_B_TOK =
"'B"
Q_o_TOK =
"'o"
Q_O_TOK =
"'O"
Q_d_TOK =
"'d"
Q_D_TOK =
"'D"
Q_h_TOK =
"'h"
Q_H_TOK =
"'H"
ONE_b_ZERO_TOK =
"1'b0"
ONE_b_ONE_TOK =
"1'b1"
ONE_b_x_TOK =
"1'bx"
ONE_b_X_TOK =
"1'bX"
ONE_B_ZERO_TOK =
"1'B0"
ONE_B_ONE_TOK =
"1'B1"
ONE_B_x_TOK =
"1'Bx"
ONE_B_X_TOK =
"1'BX"
Q_b_ZERO_TOK =
"'b0"
Q_b_ONE_TOK =
"'b1"
Q_B_ZERO_TOK =
"'B0"
Q_B_ONE_TOK =
"'B1"
WIRE_TOK =
"wire"
TRI_TOK =
"tri"
TRI1_TOK =
"tri1"
SUPPLY0_TOK =
"supply0"
WAND_TOK =
"wand"
TRIAND_TOK =
"triand"
TRI0_TOK =
"tri0"
SUPPLY1_TOK =
"supply1"
WOR_TOK =
"wor"
TRIOR_TOK =
"trior"
TRIREG_TOK =
"trireg"
SMALL_TOK =
"small"
MEDIUM_TOK =
"medium"
LARGE_TOK =
"large"
STRONG0_TOK =
"strong0"
PULL0_TOK =
"pull0"
WEAK0_TOK =
"weak0"
HIGHZ0_TOK =
"highz0"
STRONG1_TOK =
"strong1"
PULL1_TOK =
"pull1"
WEAK1_TOK =
"weak1"
HIGHZ1_TOK =
"highz1"
GATE_AND_TOK =
"and"
GATE_NAND_TOK =
"nand"
GATE_OR_TOK =
"or"
GATE_NOR_TOK =
"nor"
GATE_XOR_TOK =
"xor"
GATE_XNOR_TOK =
"xnor"
GATE_BUF_TOK =
"buf"
GATE_BUFIF0_TOK =
"bufif0"
GATE_BUFIF1_TOK =
"bufif1"
GATE_NOT_TOK =
"not"
GATE_NOTIF0_TOK =
"notif0"
GATE_NOTIF1_TOK =
"notif1"
GATE_PULLDOWN_TOK =
"pulldown"
GATE_PULLUP_TOK =
"pullup"
GATE_NMOS_TOK =
"nmos"
GATE_RNMOS_TOK =
"rnmos"
GATE_PMOS_TOK =
"pmos"
GATE_RPMOS_TOK =
"rpmos"
GATE_CMOS_TOK =
"cmos"
GATE_RCMOS_TOK =
"rcmos"
GATE_TRAN_TOK =
"tran"
GATE_RTRAN_TOK =
"rtran"
GATE_TRANIF0_TOK =
"tranif0"
GATE_RTRANIF0_TOK =
"rtranif0"
GATE_TRANIF1_TOK =
"tranif1"
GATE_RTRANIF1_TOK =
"rtranif1"
ZERO_ONE_TOK =
"01"
ONE_ZERO_TOK =
"10"
ZERO_X_TOK =
"0x"
X_ONE_TOK =
"x1"
ONE_X_TOK =
"1x"
X_ZERO_TOK =
"x0"
POSEDGE_TOK =
"posedge"
NEGEDGE_TOK =
"negedge"
EVENT_OR_TOK =
"or"
EQUAL_TOK =
"="
ASSIGN_ARROW_TEX =
"<="
EQUAL_EQUAL_TOK =
"=="
EQUAL_EQUAL_EQUAL_TOK =
"==="
NOT_EQUAL_TOK =
"!="
NOT_EQUAL_EQUAL_TOK =
"!=="
INFERIOR_TOK =
"<"
SUPERIOR_TOK =
">"
INFERIOR_EQUAL_TOK =
"<="
SUPERIOR_EQUAL_TOK =
">="
AND_AND_TOK =
"&&"
OR_OR_TOK =
"||"
NOT_TOK =
"!"
AND_AND_AND_TOK =
"&&&"
ADD_TOK =
"+"
SUB_TOK =
"-"
MUL_TOK =
"*"
DIV_TOK =
"/"
MOD_TOK =
"%"
POWER_TOK =
"**"
AND_TOK =
"&"
OR_TOK =
"|"
XOR_TOK =
"^"
XOR_TILDE_TOK =
"^~"
RIGHT_SHIFT_TOK =
">>"
LEFT_SHIFT_TOK =
"<<"
RIGHT_ASHIFT_TOK =
">>>"
LEFT_ASHIFT_TOK =
"<<<"
TILDE_TOK =
"~"
TILDE_AND_TOK =
"~&"
XOR_OR_TOK =
"^|"
TILDE_XOR_TOK =
"~^"
TILDE_OR_TOK =
"~|"
SHORT_COMMENT_REX =
/[^\n]*/
LONG_COMMENT_REX =
/([^\*]\/|\*[^\/]|[^\/\*])*/
COMMENT_SPACE_REX =

Comments and spaces with capture in one regular expression

/((?:(?:\/\/[^\n]*\n)|(?:\/\*(?:[^\*]\/|\*[^\/]|[^\/\*])*\*\/)|\s)*)/
S =

Shortcut for combining with other regex

COMMENT_SPACE_REX.source
COMMA_REX =
/\G#{S}(,)/
SEMICOLON_REX =
/\G#{S}(;)/
COLON_REX =
/\G#{S}(:)/
OPEN_PAR_REX =
/\G#{S}(\()/
CLOSE_PAR_REX =
/\G#{S}(\))/
OPEN_BRA_REX =
/\G#{S}(\[)/
CLOSE_BRA_REX =
/\G#{S}(\])/
OPEN_CUR_REX =
/\G#{S}(\{)/
CLOSE_CUR_REX =
/\G#{S}(\})/
SHARP_REX =
/\G#{S}(#)/
AT_REX =
/\G#{S}(@)/
DOT_REX =
/\G#{S}(\.)/
EE_REX =
/\G#{S}(E)/
Ee_REX =
/\G#{S}(e)/
SLASH_REX =
/\G#{S}(\/)/
SLASH_SLASH_REX =
/\G#{S}(\/\/)/
SLASH_ASTERISK_REX =
/\G#{S}(\/\*)/
ASTERISK_SLASH_REX =
/\G#{S}(\*\/)/
EOL_REX =
/\G#{S}(\n)/
MODULE_REX =
/\G#{S}(module)/
MACROMODULE_REX =
/\G#{S}(macromodule)/
ENDMODULE_REX =
/\G#{S}(endmodule)/
PRIMITIVE_REX =
/\G#{S}(primitive)/
ENDPRIMITIVE_REX =
/\G#{S}(endprimitive)/
TASK_REX =
/\G#{S}(task)/
ENDTASK_REX =
/\G#{S}(endtask)/
FUNCTION_REX =
/\G#{S}(function)/
ENDFUNCTION_REX =
/\G#{S}(endfunction)/
TABLE_REX =
/\G#{S}(table)/
ENDTABLE_REX =
/\G#{S}(endtable)/
SPECIFY_REX =
/\G#{S}(specify)/
ENDSPECIFY_REX =
/\G#{S}(endspecify)/
INPUT_REX =
/\G#{S}(input)/
OUTPUT_REX =
/\G#{S}(output)/
INOUT_REX =
/\G#{S}(inout)/
INITIAL_REX =
/\G#{S}(initial)/
SPECPARAM_REX =
/\G#{S}(specparam)/
IF_REX =
/\G#{S}(if)/
ELSE_REX =
/\G#{S}(else)/
CASE_REX =
/\G#{S}(case)/
CASEZ_REX =
/\G#{S}(casez)/
CASEX_REX =
/\G#{S}(casex)/
ENDCASE_REX =
/\G#{S}(endcase)/
FOREVER_REX =
/\G#{S}(forever)/
REPEAT_REX =
/\G#{S}(repeat)/
WHILE_REX =
/\G#{S}(while)/
FOR_REX =
/\G#{S}(for)/
WAIT_REX =
/\G#{S}(wait)/
RIGHT_ARROW_REX =
/\G#{S}(->)/
DISABLE_REX =
/\G#{S}(disable)/
ASSIGN_REX =
/\G#{S}(assign)/
DEASSIGN_REX =
/\G#{S}(deassign)/
FORCE_REX =
/\G#{S}(force)/
RELEASE_REX =
/\G#{S}(release)/
ALWAYS_REX =
/\G#{S}(always)/
DEFAULT_REX =
/\G#{S}(default)/
BEGIN_REX =
/\G#{S}(begin)/
END_REX =
/\G#{S}(end)/
FORK_REX =
/\G#{S}(fork)/
JOIN_REX =
/\G#{S}(join)/
SIGNED_REX =
/\G#{S}(signed)/
REG_REX =
/\G#{S}(reg)/
TIME_REX =
/\G#{S}(time)/
INTEGER_REX =
/\G#{S}(integer)/
REAL_REX =
/\G#{S}(real)/
EVENT_REX =
/\G#{S}(event)/
DEFPARAM_REX =
/\G#{S}(defparam)/
PARAMETER_REX =
/\G#{S}(parameter)/
SCALARED_REX =
/\G#{S}(scalared)/
VECTORED_REX =
/\G#{S}(vectored)/
SETUP_REX =
/\G#{S}($setup)/
HOLD_REX =
/\G#{S}($hold)/
PERIOD_REX =
/\G#{S}($period)/
WIDTH_REX =
/\G#{S}($width)/
SKEW_REX =
/\G#{S}($skew)/
RECOVERY_REX =
/\G#{S}($recovery)/
SETUPHOLD_REX =
/\G#{S}($setuphold)/
HYPHEN_REX =
/\G#{S}(-)/
ZERO_REX =
/\G#{S}(0)/
ONE_REX =
/\G#{S}(1)/
Xx_REX =
/\G#{S}(x)/
XX_REX =
/\G#{S}(X)/
Bb_REX =
/\G#{S}(b)/
BB_REX =
/\G#{S}(B)/
QUESTION_REX =
/\G#{S}(\?)/
Rr_REX =
/\G#{S}(r)/
RR_REX =
/\G#{S}(R)/
Ff_REX =
/\G#{S}(f)/
FF_REX =
/\G#{S}(F)/
Pp_REX =
/\G#{S}(p)/
PP_REX =
/\G#{S}(P)/
Nn_REX =
/\G#{S}(n)/
NN_REX =
/\G#{S}(N)/
ASTERISK_REX =
/\G#{S}(\*)/
Q_b_REX =
/\G#{S}('b)/
Q_B_REX =
/\G#{S}('B)/
Q_o_REX =
/\G#{S}('o)/
Q_O_REX =
/\G#{S}('O)/
Q_d_REX =
/\G#{S}('d)/
Q_D_REX =
/\G#{S}('D)/
Q_h_REX =
/\G#{S}('h)/
Q_H_REX =
/\G#{S}('H)/
ONE_b_ZERO_REX =
/\G#{S}(1'b0)/
ONE_b_ONE_REX =
/\G#{S}(1'b1)/
ONE_b_x_REX =
/\G#{S}(1'bx)/
ONE_b_X_REX =
/\G#{S}(1'bX)/
ONE_B_ZERO_REX =
/\G#{S}(1'B0)/
ONE_B_ONE_REX =
/\G#{S}(1'B1)/
ONE_B_x_REX =
/\G#{S}(1'Bx)/
ONE_B_X_REX =
/\G#{S}(1'BX)/
Q_b_ZERO_REX =
/\G#{S}('b0)/
Q_b_ONE_REX =
/\G#{S}('b1)/
Q_B_ZERO_REX =
/\G#{S}('B0)/
Q_B_ONE_REX =
/\G#{S}('B1)/
WIRE_REX =
/\G#{S}(wire)/
TRI_REX =
/\G#{S}(tri)/
TRI1_REX =
/\G#{S}(tri1)/
SUPPLY0_REX =
/\G#{S}(supply0)/
WAND_REX =
/\G#{S}(wand)/
TRIAND_REX =
/\G#{S}(triand)/
TRI0_REX =
/\G#{S}(tri0)/
SUPPLY1_REX =
/\G#{S}(supply1)/
WOR_REX =
/\G#{S}(wor)/
TRIOR_REX =
/\G#{S}(trior)/
TRIREG_REX =
/\G#{S}(trireg)/
SMALL_REX =
/\G#{S}(small)/
MEDIUM_REX =
/\G#{S}(medium)/
LARGE_REX =
/\G#{S}(large)/
STRONG0_REX =
/\G#{S}(strong0)/
PULL0_REX =
/\G#{S}(pull0)/
WEAK0_REX =
/\G#{S}(weak0)/
HIGHZ0_REX =
/\G#{S}(highz0)/
STRONG1_REX =
/\G#{S}(strong1)/
PULL1_REX =
/\G#{S}(pull1)/
WEAK1_REX =
/\G#{S}(weak1)/
HIGHZ1_REX =
/\G#{S}(highz1)/
GATE_AND_REX =
/\G#{S}(and)/
GATE_NAND_REX =
/\G#{S}(nand)/
GATE_OR_REX =
/\G#{S}(or)/
GATE_NOR_REX =
/\G#{S}(nor)/
GATE_XOR_REX =
/\G#{S}(xor)/
GATE_XNOR_REX =
/\G#{S}(xnor)/
GATE_BUF_REX =
/\G#{S}(buf)/
GATE_NBUF_REX =
/\G#{S}(nbuf)/
GATE_NOT_REX =
/\G#{S}(not)/
GATE_NOTIF0_REX =
/\G#{S}(notif0)/
GATE_NOTIF1_REX =
/\G#{S}(notif1)/
GATE_PULLDOWN_REX =
/\G#{S}(pulldown)/
GATE_PULLUP_REX =
/\G#{S}(pullup)/
GATE_NMOS_REX =
/\G#{S}(nmos)/
GATE_RNMOS_REX =
/\G#{S}(rnmos)/
GATE_PMOS_REX =
/\G#{S}(pmos)/
GATE_RPMOS_REX =
/\G#{S}(rpmos)/
GATE_CMOS_REX =
/\G#{S}(cmos)/
GATE_RCMOS_REX =
/\G#{S}(rcmos)/
GATE_TRAN_REX =
/\G#{S}(tran)/
GATE_RTRAN_REX =
/\G#{S}(rtran)/
GATE_TRANIF0_REX =
/\G#{S}(tranif0)/
GATE_RTRANIF0_REX =
/\G#{S}(rtranif0)/
GATE_TRANIF1_REX =
/\G#{S}(tranif1)/
GATE_RTRANIF1_REX =
/\G#{S}(rtranif1)/
ZERO_ONE_REX =
/\G#{S}(01)/
ONE_ZERO_REX =
/\G#{S}(10)/
ZERO_X_REX =
/\G#{S}(0x)/
X_ONE_REX =
/\G#{S}(x1)/
ONE_X_REX =
/\G#{S}(1x)/
X_ZERO_REX =
/\G#{S}(x0)/
POSEDGE_REX =
/\G#{S}(posedge)/
NEGEDGE_REX =
/\G#{S}(negedge)/
EVENT_OR_REX =
/\G#{S}(or)/
EQUAL_REX =
/\G#{S}(=)/
ASSIGN_ARROW_REX =
/\G#{S}(<=)/
EQUAL_EQUAL_REX =
/\G#{S}(==)/
EQUAL_EQUAL_EQUAL_REX =
/\G#{S}(===)/
NOT_EQUAL_REX =
/\G#{S}(!=)/
NOT_EQUAL_EQUAL_REX =
/\G#{S}(!==)/
INFERIOR_REX =
/\G#{S}(<)/
SUPERIOR_REX =
/\G#{S}(>)/
INFERIOR_EQUAL_REX =
/\G#{S}(<=)/
SUPERIOR_EQUAL_REX =
/\G#{S}(>=)/
AND_AND_REX =
/\G#{S}(&&)/
OR_OR_REX =
/\G#{S}(\|\|)/
NOT_REX =
/\G#{S}(!)/
AND_AND_AND_REX =
/\G#{S}(&&&)/
ADD_REX =
/\G#{S}(\+)/
SUB_REX =
/\G#{S}(-)/
MUL_REX =
/\G#{S}(\*)/
DIV_REX =
/\G#{S}(\/)/
MOD_REX =
/\G#{S}(%)/
POWER_REX =
/\G#{S}(\*\*)/
AND_REX =
/\G#{S}(&)/
OR_REX =
/\G#{S}(\|)/
XOR_REX =
/\G#{S}(\^)/
XOR_TILDE_REX =
/\G#{S}(\^~)/
TILDE_REX =
/\G#{S}(~)/
TILDE_AND_REX =
/\G#{S}(~&)/
XOR_OR_REX =
/\G#{S}(\^|)/
TILDE_XOR_REX =
/\G#{S}(~\^)/
TILDE_OR_REX =
/\G#{S}(~\|)/
IDENTIFIER_REX =
/\G#{S}([_a-zA-Z][_\$0-9a-zA-Z]*)/
SYSTEM_IDENTIFIER_REX =
/\G#{S}(\$[_a-zA-Z][_\$0-9a-zA-Z]*)/
STRING_REX =
/\G#{S}("[^"\n]*")/
MODULE_MACROMODULE_TOKS =

TIME_UNIT_TOKS = [ SECOND_TOK, MILLISECOND_TOK, MICROSECOND_TOK, NANOSECOND_TOK, PICOSECOND_TOK, FENTOSECOND_TOK ] TIME_UNIT_REX = /\G#S(#TIME_UNIT_TOKS.join("|"))/

[ MODULE_TOK, MACROMODULE_TOK ]
MODULE_MACROMODULE_REX =
/\G#{S}(#{MODULE_MACROMODULE_TOKS.join("|")})/
INIT_VAL_TOKS =
[ ONE_b_ZERO_TOK, ONE_b_ONE_TOK,
ONE_b_x_TOK, ONE_b_X_TOK,
ONE_B_ZERO_TOK, ONE_B_ONE_TOK, 
ONE_B_x_TOK, ONE_B_X_TOK,
ONE_TOK, ZERO_TOK ]
INIT_VAL_REX =
/\G#{S}(#{INIT_VAL_TOKS.join("|")})/
OUTPUT_SYMBOL_TOKS =
[ ZERO_TOK, ONE_TOK, Xx_TOK, XX_TOK ]
OUTPUT_SYMBOL_REX =
/\G#{S}(#{OUTPUT_SYMBOL_TOKS.join("|")})/
LEVEL_SYMBOL_TOKS =
[ ZERO_TOK, ONE_TOK, Xx_TOK, XX_TOK, 
"\\" + QUESTION_TOK, Bb_TOK, BB_TOK ]
LEVEL_SYMBOL_REX =
/\G#{S}(#{LEVEL_SYMBOL_TOKS.join("|")})/
EDGE_SYMBOL_TOKS =
[ Rr_TOK, RR_TOK, Ff_TOK, FF_TOK, 
Pp_TOK, PP_TOK, Nn_TOK, NN_TOK, 
"\\" + ASTERISK_TOK ]
EDGE_SYMBOL_REX =
/\G#{S}(#{EDGE_SYMBOL_TOKS.join("|")})/
INTEGER_REAL_TOKS =
[ INTEGER_TOK, REAL_TOK ]
INTEGER_REAL_REX =
/\G#{S}(#{INTEGER_REAL_TOKS.join("|")})/
NETTYPE_TOKS =
[ WIRE_TOK, TRI_TOK, TRI1_TOK, 
SUPPLY0_TOK, WAND_TOK, TRIAND_TOK, TRI0_TOK, 
SUPPLY1_TOK, WOR_TOK, TRIOR_TOK, TRIREG_TOK ]
NETTYPE_REX =
/\G#{S}(#{NETTYPE_TOKS.join("|")})/
INPUTTYPE_TOKS =
[ WIRE_TOK ]
INPUTTYPE_REX =
/\G#{S}(#{INPUTTYPE_TOKS.join("|")})/
OUTPUTTYPE_TOKS =

Note: the only difference between OUTPUTTYPE and NETTYPE is that the first one has reg, and the second trireg.

[ WIRE_TOK, TRI_TOK, TRI1_TOK, 
SUPPLY0_TOK, WAND_TOK, TRIAND_TOK, TRI0_TOK, 
SUPPLY1_TOK, WOR_TOK, TRIOR_TOK, REG_TOK ]
OUTPUTTYPE_REX =
/\G#{S}(#{OUTPUTTYPE_TOKS.join("|")})/
INOUTTYPE_TOKS =
[ WIRE_TOK ]
INOUTTYPE_REX =
/\G#{S}(#{INOUTTYPE_TOKS.join("|")})/
CHARGE_STRENGTH_TOKS =
[ SMALL_TOK, MEDIUM_TOK, LARGE_TOK ]
CHARGE_STRENGTH_REX =
/\G#{S}(#{CHARGE_STRENGTH_TOKS.join("|")})/
STRENGTH0_TOKS =
[ SUPPLY0_TOK, STRONG0_TOK, PULL0_TOK, 
WEAK0_TOK, HIGHZ0_TOK ]
STRENGTH0_REX =
/\G#{S}(#{STRENGTH0_TOKS.join("|")})/
STRENGTH1_TOKS =
[ SUPPLY1_TOK, STRONG1_TOK, PULL1_TOK, 
WEAK1_TOK, HIGHZ1_TOK ]
STRENGTH1_REX =
/\G#{S}(#{STRENGTH1_TOKS.join("|")})/
GATETYPE_TOKS =
[ GATE_AND_TOK, GATE_NAND_TOK, 
GATE_OR_TOK, GATE_NOR_TOK,
GATE_XOR_TOK, GATE_XNOR_TOK, 
GATE_BUF_TOK, GATE_BUFIF0_TOK, GATE_BUFIF1_TOK,
GATE_NOT_TOK, GATE_NOTIF0_TOK, GATE_NOTIF1_TOK,
GATE_PULLDOWN_TOK, GATE_PULLUP_TOK,
GATE_NMOS_TOK, GATE_RNMOS_TOK, 
GATE_PMOS_TOK, GATE_RPMOS_TOK,
GATE_CMOS_TOK, GATE_RCMOS_TOK,
GATE_TRAN_TOK, GATE_RTRAN_TOK, 
GATE_TRANIF0_TOK, GATE_RTRANIF0_TOK, 
GATE_TRANIF1_TOK, GATE_RTRANIF1_TOK ]
GATETYPE_REX =
/\G#{S}(#{GATETYPE_TOKS.join("|")})[^_a-zA-Z0-9]/
COMMA_CLOSE_PAR_TOKS =
[ COMMA_TOK, "\\" + CLOSE_PAR_TOK ]
COMMA_CLOSE_PAR_REX =
/\G#{S}(#{COMMA_CLOSE_PAR_TOKS.join("|")})/
CLOSE_BRA_COLON_TOKS =
[ "\\" + CLOSE_BRA_TOK, COLON_TOK ]
CLOSE_BRA_COLON_REX =
/\G#{S}(#{CLOSE_BRA_COLON_TOKS.join("|")})/
STATEMENT_TOKS =
[ IF_TOK, CASE_TOK, CASEZ_TOK, CASEX_TOK, 
FOREVER_TOK, REPEAT_TOK, WHILE_TOK, FOR_TOK,
WAIT_TOK, RIGHT_ARROW_TOK, DISABLE_TOK,
ASSIGN_TOK, FORCE_TOK, DEASSIGN_TOK, RELEASE_TOK ]
STATEMENT_REX =
/\G#{S}(#{STATEMENT_TOKS.join("|")})/
SYSTEM_TIMING_TOKS =
[ SETUP_TOK, HOLD_TOK, PERIOD_TOK, WIDTH_TOK,
SKEW_TOK, RECOVERY_TOK, SETUPHOLD_TOK ]
SYSTEM_TIMING_REX =
/\G#{S}(#{SYSTEM_TIMING_TOKS.join("|")})/
POSEDGE_NEGEDGE_TOKS =
[ POSEDGE_TOK, NEGEDGE_TOK ]
POSEDGE_NEGEDGE_REX =
/\G#{S}(#{POSEDGE_NEGEDGE_TOKS.join("|")})/
EDGE_DESCRIPTOR_TOKS =
[ ZERO_ONE_TOK, ONE_ZERO_TOK,
ZERO_X_TOK,   X_ONE_TOK,
ONE_X_TOK,    X_ZERO_TOK ]
EDGE_DESCRIPTOR_REX =
/\G#{S}(#{EDGE_DESCRIPTOR_TOKS.join("|")})/
SCALAR_TIMING_CHECK_CONDITION_TOKS =
[ EQUAL_EQUAL_TOK,
EQUAL_EQUAL_EQUAL_TOK,
NOT_EQUAL_TOK,
NOT_EQUAL_EQUAL_TOK ]
SCALAR_TIMING_REX =
/\G#{S}(#{SCALAR_TIMING_CHECK_CONDITION_TOKS.join("|")})/
SCALAR_CONSTANT_TOKS =
[ ONE_b_ZERO_TOK, ONE_b_ONE_TOK,
ONE_B_ZERO_TOK, ONE_B_ONE_TOK,
Q_b_ZERO_TOK,   Q_b_ONE_TOK,
Q_B_ZERO_TOK,   Q_B_ONE_TOK,
ONE_TOK,        ZERO_TOK ]
SCALAR_CONSTANT_REX =
/\G#{S}(#{SCALAR_CONSTANT_TOKS.join("|")})/
POLARITY_OPERATOR_TOKS =
[ "\\" + ADD_TOK, SUB_TOK ]
POLARITY_OPERATOR_REX =
/\G#{S}(#{POLARITY_OPERATOR_TOKS.join("|")})/
EDGE_IDENTIFIER_TOKS =
[ POSEDGE_TOK, NEGEDGE_TOK ]
EDGE_IDENTIFIER_REX =
/\G#{S}(#{EDGE_IDENTIFIER_TOKS.join("|")})/
OR_OPERATOR_TOKS =
[ "\\" + OR_TOK, TILDE_TOK + "\\" + OR_TOK ]
OR_OPERATOR_REX =
/\G#{S}(#{OR_OPERATOR_TOKS.join("|")})[^\|]/
XOR_OPERATOR_TOKS =
[ "\\" + XOR_TOK, TILDE_TOK + "\\" + XOR_TOK ]
XOR_OPERATOR_REX =
/\G#{S}(#{XOR_OPERATOR_TOKS.join("|")})/
AND_OPERATOR_TOKS =
[ AND_TOK, TILDE_AND_TOK ]
AND_OPERATOR_REX =
/\G#{S}(#{AND_OPERATOR_TOKS.join("|")})[^&]/
EQUAL_OPERATOR_TOKS =

BEFORE_AND_OPERATOR_TOKS = [

[ EQUAL_EQUAL_TOK, NOT_EQUAL_TOK,
EQUAL_EQUAL_EQUAL_TOK, NOT_EQUAL_EQUAL_TOK ]
EQUAL_OPERATOR_REX =
/\G#{S}(#{EQUAL_OPERATOR_TOKS.join("|")})/
COMPARISON_OPERATOR_TOKS =
[ INFERIOR_TOK, SUPERIOR_TOK,
INFERIOR_EQUAL_TOK, SUPERIOR_EQUAL_TOK ]
COMPARISON_OPERATOR_REX =
/\G#{S}(#{COMPARISON_OPERATOR_TOKS.join("|")})/
SHIFT_OPERATOR_TOKS =
[ LEFT_SHIFT_TOK,  RIGHT_SHIFT_TOK, 
LEFT_ASHIFT_TOK, RIGHT_ASHIFT_TOK ]
SHIFT_OPERATOR_REX =
/\G#{S}(#{SHIFT_OPERATOR_TOKS.join("|")})/
ADD_OPERATOR_TOKS =
[ "\\" + ADD_TOK, SUB_TOK ]
ADD_OPERATOR_REX =
/\G#{S}(#{ADD_OPERATOR_TOKS.join("|")})/
MUL_OPERATOR_TOKS =
[ "\\" + MUL_TOK, DIV_TOK, MOD_TOK, 
"\\" + MUL_TOK + "\\" + MUL_TOK ]
MUL_OPERATOR_REX =
/\G#{S}(#{MUL_OPERATOR_TOKS.join("|")})/
UNARY_OPERATOR_TOKS =
[ "\\" + ADD_TOK, SUB_TOK, NOT_TOK, TILDE_TOK,
AND_TOK, TILDE_AND_TOK, 
"\\" + OR_TOK, TILDE_TOK + "\\" + OR_TOK, 
"\\" + XOR_TOK  + "\\" + OR_TOK,
"\\" + XOR_TOK, TILDE_TOK + "\\" + XOR_TOK ]
UNARY_OPERATOR_REX =
/\G#{S}(#{UNARY_OPERATOR_TOKS.join("|")})/
BINARY_OPERATOR_TOKS =
[ "\\" + ADD_TOK, SUB_TOK, "\\" + MUL_TOK, 
"\\" + DIV_TOK, MOD_TOK,
EQUAL_EQUAL_TOK, NOT_EQUAL_TOK,
EQUAL_EQUAL_EQUAL_TOK, NOT_EQUAL_EQUAL_TOK,
AND_AND_TOK, "\\" + OR_TOK + "\\" + OR_TOK,
INFERIOR_TOK, INFERIOR_EQUAL_TOK,
SUPERIOR_TOK, SUPERIOR_EQUAL_TOK,
AND_TOK, "\\" + OR_TOK, "\\" + XOR_TOK, 
"\\" + XOR_TILDE_TOK,
RIGHT_SHIFT_TOK, LEFT_SHIFT_TOK ]
BINARY_OPERATOR_REX =
/\G#{S}(#{BINARY_OPERATOR_TOKS.join("|")})/
EVENT_OR_COMMA_TOKS =
[ EVENT_OR_TOK, COMMA_TOK ]
EVENT_OR_COMMA_REX =
/\G#{S}(#{EVENT_OR_COMMA_TOKS.join("|")})/
E_TOKS =
[ EE_TOK, Ee_TOK ]
E_REX =
/\G#{S}(#{E_TOKS.join("|")})/
DECIMAL_NUMBER_REX =
/\G#{S}([+-]?[0-9][_0-9]*)/
UNSIGNED_NUMBER_REX =
/\G#{S}([_0-9][0-9]*)/
NUMBER_REX =
/\G#{S}([0-9a-fA-FzZxX\?][_0-9a-fA-FzZxX\?]*)/
BASE_TOKS =
[ Q_b_TOK, Q_B_TOK, Q_o_TOK, Q_O_TOK,
Q_d_TOK, Q_D_TOK, Q_h_TOK, Q_H_TOK ]
BASE_REX =
/\G#{S}(#{BASE_TOKS.join("|")})/
KEYWORD_SET =

The set of keywords.

RULES =

The parsing rules: obtained directly from the BNF description of Verilog Each rule is paired with a hook (that returns an AST node by default) that can be redefined.

{}
ORIGIN_RULES =

The origin rules (from https://www.verilog.com/VerilogBNF.html) that differs from the ones used in this parser.

{}

Instance Method Summary collapse

Constructor Details

#initializeParser

Create a new parser.



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/HDLRuby/verilog_parser.rb', line 128

def initialize
  # Create the parse state.
  # It includes:
  # +compress+: is the compressed version of the AST to generate.
  # +text+: the text to parse
  # +filename+: the origin file name (if any)
  # +lprop+: the properties of each line.
  @state = Struct.new(:compress, 
                      :text, :filename, :path,
                      :lprop,
                      :index, :lpos, :cpos).new(false,"","",[],0,0)
  # Create the list of known module names.
  @module_names = []
  # Create the list of known UDP names.
  @udp_names = []
end

Instance Method Details

#_BASE_hook(tok) ⇒ Object



6702
6703
6704
# File 'lib/HDLRuby/verilog_parser.rb', line 6702

def _BASE_hook(tok)
  return AST[:BASE, tok, self.property_hook]
end

#_BASE_parseObject



6694
6695
6696
6697
6698
6699
6700
# File 'lib/HDLRuby/verilog_parser.rb', line 6694

def _BASE_parse
  tok = self.get_token(BASE_REX)
  if tok then
    return _BASE_hook(tok)
  end
  return nil
end

#_BINARY_OPERATOR_hook(tok) ⇒ Object



6420
6421
6422
# File 'lib/HDLRuby/verilog_parser.rb', line 6420

def _BINARY_OPERATOR_hook(tok)
  return AST[:BINARY_OPERATOR, tok, self.property_hook ]
end

#_BINARY_OPERATOR_parseObject



6412
6413
6414
6415
6416
6417
6418
# File 'lib/HDLRuby/verilog_parser.rb', line 6412

def _BINARY_OPERATOR_parse
  tok = self.get_token(BINARY_OPERATOR_REX)
  if tok then
    return self._BINARY_OPERATOR_hook(tok)
  end
  return nil
end

#_DECIMAL_NUMBER_hook(tok) ⇒ Object



6606
6607
6608
# File 'lib/HDLRuby/verilog_parser.rb', line 6606

def _DECIMAL_NUMBER_hook(tok)
  return AST[:DECIMAL_NUMBER, tok, self.property_hook ]
end

#_DECIMAL_NUMBER_parseObject



6598
6599
6600
6601
6602
6603
6604
# File 'lib/HDLRuby/verilog_parser.rb', line 6598

def _DECIMAL_NUMBER_parse
  tok = self.get_token(DECIMAL_NUMBER_REX)
  if tok then
    return self._DECIMAL_NUMBER_hook(tok)
  end
  return nil
end

#_EDGE_SYMBOL_hook(symbol) ⇒ Object



2351
2352
2353
# File 'lib/HDLRuby/verilog_parser.rb', line 2351

def _EDGE_SYMBOL_hook(symbol)
  return AST[:EDGE_SYMBOL, symbol, self.property_hook ]
end

#_EDGE_SYMBOL_parseObject



2345
2346
2347
2348
2349
# File 'lib/HDLRuby/verilog_parser.rb', line 2345

def _EDGE_SYMBOL_parse
  symbol = self.get_token(EDGE_SYMBOL_REX)
  return nil unless symbol
  return self._EDGE_SYMBOL_hook(symbol)
end

#_GATETYPE_hook(type) ⇒ Object



3343
3344
3345
# File 'lib/HDLRuby/verilog_parser.rb', line 3343

def _GATETYPE_hook(type)
  return AST[:GATETYPE, type, self.property_hook ]
end

#_GATETYPE_parseObject



3335
3336
3337
3338
3339
3340
3341
# File 'lib/HDLRuby/verilog_parser.rb', line 3335

def _GATETYPE_parse
  type = self.get_token(GATETYPE_REX)
  unless type
    return nil
  end
  return _GATETYPE_hook(type)
end

#_IDENTIFIER_hook(tok) ⇒ Object



7047
7048
7049
# File 'lib/HDLRuby/verilog_parser.rb', line 7047

def _IDENTIFIER_hook(tok)
  return AST[:_IDENTIFIER, tok, self.property_hook ]
end

#_IDENTIFIER_parseObject



7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
# File 'lib/HDLRuby/verilog_parser.rb', line 7034

def _IDENTIFIER_parse
  parse_state = self.state
  tok = self.get_token(IDENTIFIER_REX)
  # puts "tok=#{tok}"
  return nil unless tok
  if KEYWORD_SET.include?(tok) then
    # An identifier cannot be a keyword!
    self.state = parse_state
    return nil
  end
  return self._IDENTIFIER_hook(tok)
end

#_LEVEL_SYMBOL_hook(symbol) ⇒ Object



2335
2336
2337
# File 'lib/HDLRuby/verilog_parser.rb', line 2335

def _LEVEL_SYMBOL_hook(symbol)
  return AST[:LEVEL_SYMBOL, symbol, self.property_hook ]
end

#_LEVEL_SYMBOL_parseObject



2329
2330
2331
2332
2333
# File 'lib/HDLRuby/verilog_parser.rb', line 2329

def _LEVEL_SYMBOL_parse
  symbol = self.get_token(LEVEL_SYMBOL_REX)
  return nil unless symbol
  return self._LEVEL_SYMBOL_hook(symbol)
end

#_NETTYPE_hook(type) ⇒ Object



2793
2794
2795
# File 'lib/HDLRuby/verilog_parser.rb', line 2793

def _NETTYPE_hook(type)
  return AST[:NETTYPE, type, self.property_hook ]
end

#_NETTYPE_parseObject



2786
2787
2788
2789
2790
2791
# File 'lib/HDLRuby/verilog_parser.rb', line 2786

def _NETTYPE_parse
  type = self.get_token(NETTYPE_REX)
  return nil unless type
  # self.parse_error("one of [#{NETTYPE_TOKS.join(",")}] expected") unless type
  return self._NETTYPE_hook(type)
end

#_NULL_hookObject

Auth: No parse of NULL, since it is literally nothing.



3784
3785
3786
# File 'lib/HDLRuby/verilog_parser.rb', line 3784

def _NULL_hook
  return AST[:NULL, self.property_hook ]
end

#_NUMBER_hook(tok) ⇒ Object



6684
6685
6686
# File 'lib/HDLRuby/verilog_parser.rb', line 6684

def _NUMBER_hook(tok)
  return AST[:NUMBER, tok, self.property_hook ]
end

#_NUMBER_parse(base) ⇒ Object



6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
# File 'lib/HDLRuby/verilog_parser.rb', line 6653

def _NUMBER_parse(base)
  tok = self.get_token(NUMBER_REX)
  case(base)
  when Q_b_TOK, Q_B_TOK
    # Binary case.
    if tok =~ /^[0-1xXzZ\?][_0-1xXzZ\?]*$/ then
      return self._NUMBER_hook(tok)
    end
    self.parse_error("malformed number")
  when Q_o_TOK, Q_O_TOK
    # Octal case.
    if tok =~ /^[0-7xXzZ\?][_0-7xXzZ\?]*$/ then
      return self._NUMBER_hook(tok)
    end
    self.parse_error("malformed number")
  when Q_d_TOK, Q_D_TOK
    # Decimal case.
    if tok =~ /^[0-9xXzZ\?][_0-9xXzZ\?]*$/ then
      return self._NUMBER_hook(tok)
    end
    self.parse_error("malformed number")
  when Q_h_TOK, Q_H_TOK
    # hexecimal case.
    if tok =~ /^[0-9a-fA-FxXzZ\?][_0-9a-fA-FxXzZ\?]*$/ then
      return self._NUMBER_hook(tok)
    end
    self.parse_error("malformed number")
  end
  raise "Internal error: should not be there!"
end

#_OUTPUT_SYMBOL_hook(symbol) ⇒ Object



2319
2320
2321
# File 'lib/HDLRuby/verilog_parser.rb', line 2319

def _OUTPUT_SYMBOL_hook(symbol)
  return AST[:OUTPUT_SYMBOL, symbol, self.property_hook ]
end

#_OUTPUT_SYMBOL_parseObject



2313
2314
2315
2316
2317
# File 'lib/HDLRuby/verilog_parser.rb', line 2313

def _OUTPUT_SYMBOL_parse
  symbol = self.get_token(OUTPUT_SYMBOL_REX)
  return nil unless symbol
  return self._OUTPUT_SYMBOL_hook(symbol)
end

#_QUESTION_MARK_hook(tok) ⇒ Object



6436
6437
6438
# File 'lib/HDLRuby/verilog_parser.rb', line 6436

def _QUESTION_MARK_hook(tok)
  return AST[:QUESTION_MARK, tok, self.property_hook ]
end

#_QUESTION_MARK_parseObject



6429
6430
6431
6432
6433
6434
# File 'lib/HDLRuby/verilog_parser.rb', line 6429

def _QUESTION_MARK_parse
  if self.get_token(QUESTION_REX) then
    return _QUESTION_MARK_hook(QUESTION_TOK)
  end
  return nil
end

#_STRENGTH0_hook(strength0) ⇒ Object



3222
3223
3224
# File 'lib/HDLRuby/verilog_parser.rb', line 3222

def _STRENGTH0_hook(strength0)
  return AST[:STRENGTH0, strength0, self.property_hook ]
end

#_STRENGTH0_parseObject



3214
3215
3216
3217
3218
3219
3220
# File 'lib/HDLRuby/verilog_parser.rb', line 3214

def _STRENGTH0_parse
  strength0 = self.get_token(STRENGTH0_REX)
  unless strength0
    return nil
  end
  return _STRENGTH0_hook(strength0)
end

#_STRENGTH1_hook(strength1) ⇒ Object



3240
3241
3242
# File 'lib/HDLRuby/verilog_parser.rb', line 3240

def _STRENGTH1_hook(strength1)
  return AST[:STRENGTH1, strength1, self.property_hook ]
end

#_STRENGTH1_parseObject



3232
3233
3234
3235
3236
3237
3238
# File 'lib/HDLRuby/verilog_parser.rb', line 3232

def _STRENGTH1_parse
  strength1 = self.get_token(STRENGTH1_REX)
  unless strength1
    return nil
  end
  return _STRENGTH1_hook(strength1)
end

#_STRING_hook(string) ⇒ Object



6453
6454
6455
# File 'lib/HDLRuby/verilog_parser.rb', line 6453

def _STRING_hook(string)
  return AST[:STRING, string, self.property_hook ]
end

#_STRING_parseObject



6445
6446
6447
6448
6449
6450
6451
# File 'lib/HDLRuby/verilog_parser.rb', line 6445

def _STRING_parse
  string = self.get_token(STRING_REX)
  if string then
    return _STRING_hook(string)
  end
  return nil
end

#_UNARY_OPERATOR_hook(tok) ⇒ Object



6402
6403
6404
# File 'lib/HDLRuby/verilog_parser.rb', line 6402

def _UNARY_OPERATOR_hook(tok)
  return AST[:UNARY_OPERATOR, tok, self.property_hook ]
end

#_UNARY_OPERATOR_parseObject



6394
6395
6396
6397
6398
6399
6400
# File 'lib/HDLRuby/verilog_parser.rb', line 6394

def _UNARY_OPERATOR_parse
  tok = self.get_token(UNARY_OPERATOR_REX)
  if tok then
    return self._UNARY_OPERATOR_hook(tok)
  end
  return nil
end

#_UNSIGNED_NUMBER_hook(tok) ⇒ Object



6625
6626
6627
# File 'lib/HDLRuby/verilog_parser.rb', line 6625

def _UNSIGNED_NUMBER_hook(tok)
  return AST[:UNSIGNED_NUMBER, tok, self.property_hook ]
end

#_UNSIGNED_NUMBER_parseObject



6617
6618
6619
6620
6621
6622
6623
# File 'lib/HDLRuby/verilog_parser.rb', line 6617

def _UNSIGNED_NUMBER_parse
  tok = self.get_token(UNSIGNED_NUMBER_REX)
  if tok then
    return self._UNSIGNED_NUMBER_hook(tok)
  end
  return nil
end

#add_module_name(name) ⇒ Object

Add a known module name.



609
610
611
# File 'lib/HDLRuby/verilog_parser.rb', line 609

def add_module_name(name)
  @module_names << name.to_s
end

#add_term_hook(mul_terms) ⇒ Object



6348
6349
6350
6351
6352
6353
6354
# File 'lib/HDLRuby/verilog_parser.rb', line 6348

def add_term_hook(mul_terms)
  if self.state.compress and mul_terms.size == 1 then
    return mul_terms[0]
  else
    return AST[:and_term, mul_terms, self.property_hook ]
  end
end

#add_term_parseObject



6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
# File 'lib/HDLRuby/verilog_parser.rb', line 6331

def add_term_parse
  # puts "add_term_parse"
  cur_mul_term = self.mul_term_parse
  return nil unless cur_mul_term
  mul_terms = [ cur_mul_term ]
  tok = nil
  loop do
    tok = self.get_token(MUL_OPERATOR_REX)
    break unless tok
    mul_terms << tok
    cur_mul_term = self.mul_term_parse
    self.parse_error("expression expected") unless cur_mul_term
    mul_terms << cur_mul_term
  end
  return add_term_hook(mul_terms)
end

#add_udp_name(name) ⇒ Object

Add a known UDP name.



614
615
616
# File 'lib/HDLRuby/verilog_parser.rb', line 614

def add_udp_name(name)
  @udp_names << name.to_s
end

#always_statement_hook(statement) ⇒ Object



3846
3847
3848
# File 'lib/HDLRuby/verilog_parser.rb', line 3846

def always_statement_hook(statement)
  return AST[:always_statement, statement, self.property_hook ]
end

#always_statement_parseObject



3839
3840
3841
3842
3843
3844
# File 'lib/HDLRuby/verilog_parser.rb', line 3839

def always_statement_parse
  return nil unless self.get_token(ALWAYS_REX)
  statement = self.statement_parse
  self.parse_error("statement expected") unless statement
  return self.always_statement_hook(statement)
end

#assignment_hook(lvalue, expression) ⇒ Object



4058
4059
4060
# File 'lib/HDLRuby/verilog_parser.rb', line 4058

def assignment_hook(lvalue,expression)
  return AST[:assignment, lvalue,expression, self.property_hook ]
end

#assignment_parseObject



4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
# File 'lib/HDLRuby/verilog_parser.rb', line 4042

def assignment_parse
  parse_state = self.state
  lvalue = self.lvalue_parse
  unless lvalue then
    self.state = parse_state
    return nil
  end
  unless self.get_token(EQUAL_REX) then
    self.state = parse_state
    return nil
  end
  expression = self.expression_parse
  self.parse_error("expression expected") unless expression
  return self.assignment_hook(lvalue,expression)
end

#bit_and_term_hook(equal_terms) ⇒ Object



6216
6217
6218
6219
6220
6221
6222
# File 'lib/HDLRuby/verilog_parser.rb', line 6216

def bit_and_term_hook(equal_terms)
  if self.state.compress and equal_terms.size == 1 then
    return equal_terms[0]
  else
    return AST[:bit_and_term, equal_terms, self.property_hook ]
  end
end

#bit_and_term_parseObject



6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
# File 'lib/HDLRuby/verilog_parser.rb', line 6199

def bit_and_term_parse
  # puts "bit_and_term_parse"
  cur_equal_term = self.equal_term_parse
  return nil unless cur_equal_term
  equal_terms = [ cur_equal_term ]
  tok = nil
  loop do
    tok = self.get_token(EQUAL_OPERATOR_REX)
    break unless tok
    equal_terms << tok
    cur_equal_term = self.equal_term_parse
    self.parse_error("expression expected") unless cur_equal_term
    equal_terms << cur_equal_term
  end
  return bit_and_term_hook(equal_terms)
end

#bit_or_term_hook(bit_xor_terms) ⇒ Object



6149
6150
6151
6152
6153
6154
6155
# File 'lib/HDLRuby/verilog_parser.rb', line 6149

def bit_or_term_hook(bit_xor_terms)
  if self.state.compress and bit_xor_terms.size == 1 then
    return bit_xor_terms[0]
  else
    return AST[:bit_or_term, bit_xor_terms, self.property_hook ]
  end
end

#bit_or_term_parseObject



6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
# File 'lib/HDLRuby/verilog_parser.rb', line 6132

def bit_or_term_parse
  # puts "bit_or_term_parse"
  cur_bit_xor_term = self.bit_xor_term_parse
  return nil unless cur_bit_xor_term
  bit_xor_terms = [ cur_bit_xor_term ]
  tok = nil
  loop do
    tok = self.get_token(XOR_OPERATOR_REX)
    break unless tok
    bit_xor_terms << tok
    cur_bit_xor_term = self.bit_xor_term_parse
    self.parse_error("expression expected") unless cur_bit_xor_term
    bit_xor_terms << cur_bit_xor_term
  end
  return bit_or_term_hook(bit_xor_terms)
end

#bit_xor_term_hook(bit_and_terms) ⇒ Object



6183
6184
6185
6186
6187
6188
6189
# File 'lib/HDLRuby/verilog_parser.rb', line 6183

def bit_xor_term_hook(bit_and_terms)
  if self.state.compress and bit_and_terms.size == 1 then
    return bit_and_terms[0]
  else
    return AST[:bit_xor_term, bit_and_terms, self.property_hook ]
  end
end

#bit_xor_term_parseObject



6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
# File 'lib/HDLRuby/verilog_parser.rb', line 6165

def bit_xor_term_parse
  # puts "bit_xor_term_parse"
  parse_state = self.state
  cur_bit_and_term = self.bit_and_term_parse
  return nil unless cur_bit_and_term
  bit_and_terms = [ cur_bit_and_term ]
  tok = nil
  loop do
    tok = self.get_token(AND_OPERATOR_REX)
    break unless tok
    bit_and_terms << tok
    cur_bit_and_term = self.bit_and_term_parse
    self.parse_error("expression expected") unless cur_bit_and_term
    bit_and_terms << cur_bit_and_term
  end
  return bit_xor_term_hook(bit_and_terms)
end

#block_declaration_hook(declaration) ⇒ Object



4359
4360
4361
4362
4363
4364
4365
# File 'lib/HDLRuby/verilog_parser.rb', line 4359

def block_declaration_hook(declaration)
  if self.state.compress then
    return declaration
  else
    return AST[:block_declaration, declaration, self.property_hook ]
  end
end

#block_declaration_parseObject



4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
# File 'lib/HDLRuby/verilog_parser.rb', line 4331

def block_declaration_parse
  parameter_declaration = self.parameter_declaration_parse
  if parameter_declaration then
    return self.block_declaration_hook(parameter_declaration)
  end
  reg_declaration = self.reg_declaration_parse
  if reg_declaration then
    return self.block_declaration_hook(reg_declaration)
  end
  integer_declaration = self.integer_declaration_parse
  if integer_declaration then
    return self.block_declaration_hook(integer_declaration)
  end
  real_declaration = self.real_declaration_parse
  if real_declaration then
    return self.block_declaration_hook(real_declaration)
  end
  time_declaration = self.time_declaration_parse
  if time_declaration then
    return self.block_declaration_hook(time_declaration)
  end
  event_declaration = self.event_declaration_parse
  if event_declaration then
    return self.block_declaration_hook(event_declaration)
  end
  return nil
end

#blocking_assignment_hook(lvalue, delay_or_event_control, expression) ⇒ Object



4087
4088
4089
4090
4091
# File 'lib/HDLRuby/verilog_parser.rb', line 4087

def blocking_assignment_hook(lvalue, delay_or_event_control,
                             expression)
  return AST[:blocking_assignment,
             lvalue,delay_or_event_control,expression, self.property_hook ]
end

#blocking_assignment_parseObject



4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
# File 'lib/HDLRuby/verilog_parser.rb', line 4069

def blocking_assignment_parse
  parse_state = self.state
  lvalue = self.lvalue_parse
  return nil unless lvalue
  unless self.get_token(EQUAL_REX) then
    self.state = parse_state
    return nil
  end
  delay_or_event_control = self.delay_or_event_control_parse
  expression = self.expression_parse
  unless expression then
    self.state = parse_state
    return nil
  end
  return self.blocking_assignment_hook(lvalue,delay_or_event_control,
                                      expression)
end

#case_item_hook(cas, statement_or_null) ⇒ Object



4200
4201
4202
# File 'lib/HDLRuby/verilog_parser.rb', line 4200

def case_item_hook(cas, statement_or_null)
  return AST[:case_item, cas,statement_or_null, self.property_hook ]
end

#case_item_parseObject



4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
# File 'lib/HDLRuby/verilog_parser.rb', line 4167

def case_item_parse
  parse_state = self.state
  if self.get_token(DEFAULT_REX) then
    self.get_token(COLON_REX)
    statement_or_null = self.statement_or_null_parse
    self.parse_error("statement or nothing expected") unless statement_or_null
    return self.case_item_hook(DEFAULT_TOK,statement_or_null)
  end
  cur_expression = self.expression_parse
  # self.parse_error("expression expected") unless cur_expression
  unless cur_expression then
    self.state = parse_state
    return nil
  end
  expressions = [ cur_expression ]
  loop do
    unless self.get_token(COMMA_REX) then
      break
    end
    cur_expression = self.expression_parse
    self.parse_error("expression expected") unless cur_expression
    expressions << cur_expression
  end
  unless self.get_token(COLON_REX) then
    # It was not an item
    self.state = parse_state
    return nil
  end
  statement_or_null = self.statement_or_null_parse
  self.parse_error("statement or nothing expected") unless statement_or_null
  return self.case_item_hook(expressions,statement_or_null)
end

#charge_strength_hook(type) ⇒ Object



3167
3168
3169
# File 'lib/HDLRuby/verilog_parser.rb', line 3167

def charge_strength_hook(type)
  return AST[:char_strength, type, self.property_hook ]
end

#charge_strength_parseObject



3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
# File 'lib/HDLRuby/verilog_parser.rb', line 3151

def charge_strength_parse
  parse_state = self.state
  tok0 = self.get_token(OPEN_PAR_REX)
  tok1 = self.get_token(CHAR_STRENGH_REX)
  tok2 = self.get_token(CLOSE_PAR_REX)
  if !tok0 or !tok2 then
    self.state = parse_state
    return nil
  end
  unless tok1 
    self.state = parse_state
    return nil
  end
  return charget_strength_hook(tok1)
end

#combinational_entry_hook(level_input_list, output_symbol) ⇒ Object



2134
2135
2136
# File 'lib/HDLRuby/verilog_parser.rb', line 2134

def combinational_entry_hook(level_input_list, output_symbol)
  return AST[:combinational_entry, level_input_list,output_symbol, self.property_hook ]
end

#combinational_entry_parseObject



2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
# File 'lib/HDLRuby/verilog_parser.rb', line 2119

def combinational_entry_parse
  parse_state = self.state
  level_input_list = self.level_input_list_parse
  if !level_input_list or !self.get_token(COLON_REX) then
    self.state = parse_state
    return nil
  end
  output_symbol = self._OUTPUT_SYMBOL_parse
  if !output_symbol or !self.get_token(SEMICOLON_REX) then
    self.state = parse_state
    return nil
  end
  return self.combinational_entry_hook(level_input_list,output_symbol)
end

#comment_hook(comment) ⇒ Object



6896
6897
6898
# File 'lib/HDLRuby/verilog_parser.rb', line 6896

def comment_hook(comment)
  return AST[:comment, comment, self.property_hook ]
end

#comment_parseObject



6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
# File 'lib/HDLRuby/verilog_parser.rb', line 6884

def comment_parse
  short_comment = self.short_comment_parse
  if short_comment then
    return self.comment_hook(short_comment)
  end
  long_comment = self.long_comment_parse
  if long_comment then
    return self.comment_hook(long_comment)
  end
  return nil
end

#comment_text_hook(tok) ⇒ Object



6992
6993
6994
# File 'lib/HDLRuby/verilog_parser.rb', line 6992

def comment_text_hook(tok)
  return AST[:comment_text, tok, self.property_hook ]
end

#comparison_term_hook(shift_terms) ⇒ Object



6282
6283
6284
6285
6286
6287
6288
# File 'lib/HDLRuby/verilog_parser.rb', line 6282

def comparison_term_hook(shift_terms)
  if self.state.compress and shift_terms.size == 1 then
    return shift_terms[0]
  else
    return AST[:comparison_term, shift_terms, self.property_hook ]
  end
end

#comparison_term_parseObject



6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
# File 'lib/HDLRuby/verilog_parser.rb', line 6265

def comparison_term_parse
  # puts "comparison_parse"
  cur_shift_term = self.shift_term_parse
  return nil unless cur_shift_term
  shift_terms = [ cur_shift_term ]
  tok = nil
  loop do
    tok = self.get_token(SHIFT_OPERATOR_REX)
    break unless tok
    shift_terms << tok
    cur_shift_term = self.shift_term_parse
    self.parse_error("expression expected") unless cur_shift_term
    shift_terms << cur_shift_term
  end
  return comparison_term_hook(shift_terms)
end

#concatenation_hook(expressions) ⇒ Object



6737
6738
6739
# File 'lib/HDLRuby/verilog_parser.rb', line 6737

def concatenation_hook(expressions)
  return AST[:concatenation, expressions, self.property_hook ]
end

#concatenation_parseObject



6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
# File 'lib/HDLRuby/verilog_parser.rb', line 6712

def concatenation_parse
  parse_state = self.state
  unless self.get_token(OPEN_CUR_REX) then
    self.state = parse_state
    return nil
  end
  cur_expression = self.expression_parse
  self.parse_error("expression expected") unless cur_expression
  expressions = [ cur_expression ]
  loop do
    unless self.get_token(COMMA_REX) then
      break
    end
    cur_expression = self.expression_parse
    self.parse_error("expression expected") unless cur_expression
    expressions << cur_expression
  end
  unless self.get_token(CLOSE_CUR_REX) then
    # Maybe it was a multiple concatenation, rewind and cancel.
    self.state = parse_state
    return nil
  end
  return self.concatenation_hook(expressions)
end

#condition_term_hook(logic_or_terms) ⇒ Object



6052
6053
6054
6055
6056
6057
6058
# File 'lib/HDLRuby/verilog_parser.rb', line 6052

def condition_term_hook(logic_or_terms)
  if self.state.compress and logic_or_terms.size == 1 then
    return logic_or_terms[0]
  else
    return AST[:condition_term, logic_or_terms, self.property_hook ]
  end
end

#condition_term_parseObject



6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
# File 'lib/HDLRuby/verilog_parser.rb', line 6037

def condition_term_parse
  # puts "condition_term_parse"
  cur_logic_or_term = self.logic_or_term_parse
  return nil unless cur_logic_or_term
  logic_or_terms = [ cur_logic_or_term ]
  loop do
    break unless self.get_token(OR_OR_REX)
    logic_or_terms << OR_OR_TOK
    cur_logic_or_term = self.logic_or_term_parse
    self.parse_error("expression expected") unless cur_logic_or_term
    logic_or_terms << cur_logic_or_term
  end
  return condition_term_hook(logic_or_terms)
end

#conditional_port_expression_hook(port_reference__unary_operator, binary_operator, port_reference) ⇒ Object



5578
5579
5580
5581
5582
5583
5584
5585
# File 'lib/HDLRuby/verilog_parser.rb', line 5578

def conditional_port_expression_hook(port_reference__unary_operator,
                                     binary_operator,
                                     port_reference)
  return AST[:conditional_port_expression,
             port_reference__unary_operator,
             binary_operator,
             port_reference, self.property_hook ]
end

#conditional_port_expression_parseObject



5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
# File 'lib/HDLRuby/verilog_parser.rb', line 5554

def conditional_port_expression_parse
  unary_operator = self.unary_operator_parse
  port_reference0 = self.port_reference_parse
  if !port_reference0 then
    self.parse_error("there should be any of [#{UNARY_OPERATOR_TOKS.join(",")}] here") if unary_operator
    return nil
  end
  if unary_operator then
    return self.conditional_port_expression_hook(unary_operator,
                                                 port_reference0,nil)
  end
  binary_operator = self.binary_operator_parse
  if binary_operator then
    port_reference1 = self.port_reference_parse
    self.parse_error("port reference expected here") unless port_reference1
    return self.conditional_port_expression_hook(port_reference0,
                                                 binary_operator,
                                                 port_reference1)
  else
    return self.conditional_port_expression_hook(port_reference0,
                                                 nil,nil)
  end
end

#constant_expression_hook(expression) ⇒ Object



5860
5861
5862
# File 'lib/HDLRuby/verilog_parser.rb', line 5860

def constant_expression_hook(expression)
  return AST[:constant_expression, expression, self.property_hook ]
end

#constant_expression_parseObject



5854
5855
5856
5857
5858
# File 'lib/HDLRuby/verilog_parser.rb', line 5854

def constant_expression_parse
  expression = self.expression_parse
  return nil unless expression
  return self.constant_expression_hook(expression)
end

#continuous_assignment_hook(nettype, drive_strength, expandrange, delay, list_of_assignments) ⇒ Object



2973
2974
2975
2976
2977
2978
# File 'lib/HDLRuby/verilog_parser.rb', line 2973

def continuous_assignment_hook(nettype, drive_strength, expandrange,
                               delay, list_of_assignments)
  return AST[:continuous_assignment, 
             nettype,drive_strength,expandrange,delay,
             list_of_assignments, self.property_hook ]
end

#continuous_assignment_parseObject



2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
# File 'lib/HDLRuby/verilog_parser.rb', line 2950

def continuous_assignment_parse
  if self.get_token(ASSIGN_REX) then
    drive_strength = self.drive_strength_parse
    delay = self.delay_parse
    list_of_assignments = self.list_of_assignments_parse
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    return continuous_assignment_hook(ASSIGN_TOK,
                                      drive_strength,nil,
                                      delay,list_of_assignments)
  else
    nettype = self._NETTYPE_parse
    return nil unless nettype
    drive_strength = self.drive_strength_parse
    expandrange = self.expandrange_parse
    delay = self.delay_parse
    list_of_assignments = self.list_of_assignments_parse
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    return continuous_assignment_hook(nettype,
                                      drive_strength,expandrange,
                                      delay,list_of_assignments)
  end
end

#controlled_timing_check_event_hook(timing_check_event_control, specify_terminal_descriptor, timing_check_condition) ⇒ Object



5239
5240
5241
5242
5243
5244
5245
5246
5247
# File 'lib/HDLRuby/verilog_parser.rb', line 5239

def controlled_timing_check_event_hook(
    timing_check_event_control,
    specify_terminal_descriptor,
    timing_check_condition)
  return AST[:controlled_timing_check_event,
             timing_check_event_control,
             specify_terminal_descriptor,
             timing_check_condition, self.property_hook ]
end

#controlled_timing_check_event_parseObject



5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
# File 'lib/HDLRuby/verilog_parser.rb', line 5216

def controlled_timing_check_event_parse
  parse_state = self.state
  timing_check_event_control = self.timing_check_event_control_parse
  return nil unless timing_check_event_control
  specify_terminal_descriptor = self.specify_terminal_descriptor_parse
  unless specify_terminal_descriptor then
    self.state = parse_state
    return nil
  end
  unless self.get_token(AND_AND_AND_REX) then
    return self.controlled_timing_check_event_hook(
      timing_check_event_control,
      specify_terminal_descriptor,
      nil)
  end
  timing_check_condition = self.timing_check_condition_parse
  self.parse_error("timing check condition expected") unless timing_check_condition
  return self.controlled_timing_check_event_hook(
    timing_check_event_control,
    specify_terminal_descriptor,
    timing_check_condition)
end

#data_source_hook(expression) ⇒ Object



5705
5706
5707
# File 'lib/HDLRuby/verilog_parser.rb', line 5705

def data_source_hook(expression)
  return AST[:data_source, expression, self.property_hook ]
end

#data_source_parseObject



5697
5698
5699
5700
5701
5702
5703
# File 'lib/HDLRuby/verilog_parser.rb', line 5697

def data_source_parse
  # *Auth*: the check are assumed to be done at the AST level.
  #  If required, please redefine data_source_hook
  expression = self.expression_parse
  return nil unless expression
  return self.data_source_hook(expression)
end

#delay_control_hook(number__identifier__mintypmax_expression) ⇒ Object



7132
7133
7134
# File 'lib/HDLRuby/verilog_parser.rb', line 7132

def delay_control_hook(number__identifier__mintypmax_expression)
  return AST[:delay_control, number__identifier__mintypmax_expression, self.property_hook ]
end

#delay_control_parseObject



7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
# File 'lib/HDLRuby/verilog_parser.rb', line 7113

def delay_control_parse
  unless self.get_token(SHARP_REX) then
    return nil
  end
  number = self.number_parse
  if number then
    return self.delay_control_hook(number)
  end
  identifier = self.identifier_parse
  if identifier then
    return self.delay_control_hook(identifier)
  end
  self.parse_error("opening parenthesis expected") unless self.get_token(OPEN_PAR_REX)
  mintypmax_expression = self.mintypmax_expression_parse
  self.parse_error("min:typical:max expression expected") unless mintypmax_expression
  self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
  return self.delay_control_hook(mintypmax_expression)
end

#delay_hook(number__identifier__mintypmax_expression, mintypmax_expression1, mintypmax_expression2) ⇒ Object



3397
3398
3399
3400
3401
# File 'lib/HDLRuby/verilog_parser.rb', line 3397

def delay_hook(mintypmax_expression__number,
               mintypmax_expression1, mintypexpression2)
  return AST[:delay, mintypmax_expression__number,
             mintypmax_expression1,mintypexpression2, self.property_hook ]
end

#delay_or_event_control_hook(base, arg0, arg1) ⇒ Object



4155
4156
4157
# File 'lib/HDLRuby/verilog_parser.rb', line 4155

def delay_or_event_control_hook(base,arg0,arg1)
  return AST[:delay_or_event_control, base,arg0,arg1, self.property_hook ]
end

#delay_or_event_control_parseObject



4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
# File 'lib/HDLRuby/verilog_parser.rb', line 4133

def delay_or_event_control_parse
  if self.get_token(REPEAT_REX) then
    self.parse_error("opening parenthesis expected") unless self.get_token(OPEN_PAR_REX)
    expression = self.expression_parse
    self.parse_error("expression expected") unless expression
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    event_control = self.event_control_parse
    self.parse_error("event control expected") unless event_control
    return self.delay_or_event_control_hook(REPEAT_TOK,
                                       expression,event_control)
  end
  delay_control = self.delay_control_parse
  if delay_control then
    return self.delay_or_event_control_hook(delay_control,nil,nil)
  end
  event_control = self.event_control_parse
  if event_control then
    return self.delay_or_event_control_hook(event_control,nil,nil)
  end
  return nil
end

#delay_parseObject



3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
# File 'lib/HDLRuby/verilog_parser.rb', line 3355

def delay_parse
  unless self.get_token(SHARP_REX) then
    return nil
  end
  if self.get_token(OPEN_PAR_REX) then
    mintypmax_expression0 = self.mintypmax_expression_parse
    self.parse_error("min:typical:max delay expression expected") unless mintypmax_expression0
    tok = self.get_token(COMMA_CLOSE_PAR_REX)
    if tok == COMMA_TOK then
      mintypmax_expression1 = self.mintypmax_expression_parse
      self.parse_error("min:typical:max delay expression expected") unless mintypmax_expression1
      tok = self.get_token(COMMA_CLOSE_PAR_REX)
      if tok == COMMA_TOK then
        mintypmax_expression2 = self.mintypmax_expression_parse
        self.parse_error("min:typical:max delay expression expected") unless mintypmax_expression2
        self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
        return self.delay_hook(mintypmax_expression0,
                               mintypmax_expression1,
                               mintypmax_expression2)
      elsif tok == CLOSE_PAR_TOK then
        return self.delay_hook(mintypmax_expression0,
                               mintypmax_expression1,nil)
      else
        self.parse_error("comma or closing parenthesis expected")
      end
    elsif tok == CLOSE_PAR_TOK then
      return self.delay_hook(mintypmax_expression0,nil,nil)
    else
      self.parse_error("closing parenthesis expected")
    end
  end
  number = self.number_parse
  if number then
    return self.delay_hook(number,nil,nil)
  end
  identifier = self.identifier_parse
  if identifier then
    return self.delay_hook(identifier)
  end
  self.parse_error("identifier expected")
end

#description_hook(elem) ⇒ Object



1433
1434
1435
1436
1437
1438
1439
# File 'lib/HDLRuby/verilog_parser.rb', line 1433

def description_hook(elem)
  if self.state.compress then
    return elem
  else
    return AST[:description, elem, self.property_hook ]
  end
end

#description_parseObject



1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
# File 'lib/HDLRuby/verilog_parser.rb', line 1421

def description_parse
  elem = self.module_parse
  if !elem then
    elem = self.udp_parse
  end
  if !elem then
    return nil if self.eof?
    self.parse_error("this is probably not a Verilog HDL file")
  end
  return self.description_hook(elem)
end

#drive_strength_hook(strengthL, strengthR) ⇒ Object



3204
3205
3206
# File 'lib/HDLRuby/verilog_parser.rb', line 3204

def drive_strength_hook(strengthL, strengthR)
  return AST[:drive_strength, strengthL,strengthR, self.property_hook ]
end

#drive_strength_parseObject



3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
# File 'lib/HDLRuby/verilog_parser.rb', line 3178

def drive_strength_parse
  parse_state = self.state
  unless self.get_token(OPEN_PAR_REX) then
    return nil
  end
  strength0 = self._STRENGTH0_parse
  if !strength0 then
    strength1 = self._STRENGTH1_parse
    unless strength1 then
      self.state = parse_state
      return nil
    end
    self.parse_error("comma expected") unless self.get_token(COMMA_REX)
    strength0 = self._STRENGTH0_parse
    self.parse_error("one of [#{STRENGTH0_TOKS.join(",")}] expected") unless strength0
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    return drive_strength_hook(strength1, strength0)
  else
    self.parse_error("comma expected") unless self.get_token(COMMA_REX)
    strength1 = self._STRENGTH1_parse
    self.parse_error("one of [#{STRENGTH1_TOKS.join(",")}] expected") unless strength1
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    return drive_strength_hook(strength0, strength1)
  end
end

#each_origin_rule(&ruby_block) ⇒ Object

Access each origin rule.



1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
# File 'lib/HDLRuby/verilog_parser.rb', line 1374

def each_origin_rule(&ruby_block)
  # No ruby block? Return an enumerator.
  return to_enum(:each_origin_rule) unless ruby_block
  # A ruby block? Apply it on each rule value.
  orig = nil
  RULES.each do |k,v|
    orig = ORIGIN_RULES[k]
    orig ? ruby_block.(orig) : ruby_block.(v)
  end
end

#each_rule(&ruby_block) ⇒ Object

Access each rule.



1366
1367
1368
1369
1370
1371
# File 'lib/HDLRuby/verilog_parser.rb', line 1366

def each_rule(&ruby_block)
  # No ruby block? Return an enumerator.
  return to_enum(:each_rule) unless ruby_block
  # A ruby block? Apply it on each rule value.
  RULES.each_value(&ruby_block)
end

#edge_control_specifier_hook(edge_descriptors) ⇒ Object



5297
5298
5299
# File 'lib/HDLRuby/verilog_parser.rb', line 5297

def edge_control_specifier_hook(edge_descriptors)
  return AST[:edge_control_specifier, edge_descriptors, self.property_hook ]
end

#edge_control_specifier_parseObject



5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
# File 'lib/HDLRuby/verilog_parser.rb', line 5277

def edge_control_specifier_parse
  unless self.get_token(EDGE_REX) then
    return nil
  end
  self.parse_error("opening bracket expected") unless self.get_token(OPEN_BRA_REX)
  cur_edge_descriptor = self.edge_descriptor_parse
  self.parse_error("edge descriptor expected") unless cur_edge_descriptor
  edge_descriptors = [ cur_edge_descriptor ]
  loop do
    if self.get_token(COMMA_REX) then
      break
    end
    cur_edge_descriptor = self.edge_descriptor_parse
    self.parse_error("edge descriptor expected") unless cur_edge_descriptor
    edge_descriptors << cur_edge_descriptor
  end
  self.parse_error("closing bracket expected") unless self.get_token(CLOSE_BRA_REX)
  return self.edge_control_specifier_hook(edge_descriptors)
end

#edge_descriptor_hook(tok) ⇒ Object



5320
5321
5322
# File 'lib/HDLRuby/verilog_parser.rb', line 5320

def edge_descriptor_hook(tok)
  return AST[:edge_descriptor, tok, self.property_hook ]
end

#edge_descriptor_parseObject



5312
5313
5314
5315
5316
5317
5318
# File 'lib/HDLRuby/verilog_parser.rb', line 5312

def edge_descriptor_parse
  tok = self.get_token(EDGE_DESCRIPTOR_REX)
  if tok then
    return self.edge_descriptor_hook(tok)
  end
  return nil
end

#edge_hook(edge) ⇒ Object



2267
2268
2269
# File 'lib/HDLRuby/verilog_parser.rb', line 2267

def edge_hook(edge)
  return AST[:edge, edge, self.property_hook ]
end

#edge_identifier_hook(tok) ⇒ Object



5725
5726
5727
# File 'lib/HDLRuby/verilog_parser.rb', line 5725

def edge_identifier_hook(tok)
  return AST[:edge_identifier, tok, self.property_hook ]
end

#edge_identifier_parseObject



5716
5717
5718
5719
5720
5721
5722
5723
# File 'lib/HDLRuby/verilog_parser.rb', line 5716

def edge_identifier_parse
  tok = self.get_token(EDGE_IDENTIFIER_REX)
  if tok then
    return self.edge_identifier_hook(tok)
  else
    return nil
  end
end

#edge_input_list_hook(level_symbols0, edge, level_symbols1) ⇒ Object



2244
2245
2246
# File 'lib/HDLRuby/verilog_parser.rb', line 2244

def edge_input_list_hook(level_symbols0, edge, level_symbols1)
  return AST[:edge_input_list, level_symbols0,edge,level_symbols1, self.property_hook ]
end

#edge_input_list_parseObject



2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
# File 'lib/HDLRuby/verilog_parser.rb', line 2221

def edge_input_list_parse
  parse_state = self.state
  level_symbols0 = []
  cur_level_symbol = nil
  loop do
    cur_level_symbol = self._LEVEL_SYMBOL_parse
    break unless cur_level_symbol
    level_symbols0 << cur_level_symbol
  end
  edge = self.edge_parse
  if !edge then
    self.state = parse_state
    return nil
  end
  level_symbols1 = []
  loop do
    cur_level_symbol = self._LEVEL_SYMBOL_parse
    break unless cur_level_symbol
    level_symbols1 << cur_level_symbol
  end
  return self.edge_input_list_hook(level_symbols0,edge,level_symbols1)
end

#edge_parseObject



2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
# File 'lib/HDLRuby/verilog_parser.rb', line 2255

def edge_parse
  if self.get_token(OPEN_PAR_REX) then
    level_symbol0 = self._LEVEL_SYMBOL_parse
    level_symbol1 = self._LEVEL_SYMBOL_parse
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    edge = [ level_symbol0,level_symbol1 ]
  else
    edge = self._EDGE_SYMBOL_parse
  end
  return self.edge_hook(edge)
end

#edge_sensitive_path_declaration_hook(expression, edge_identifier, specify_input_terminal_descriptor, tok, specify_output_terminal_descriptor__list_of_path_outputs, polarity_operator, data_source_expression, path_delay_value) ⇒ Object



5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
# File 'lib/HDLRuby/verilog_parser.rb', line 5678

def edge_sensitive_path_declaration_hook(
  expression, edge_identifier, specify_input_terminal_descriptor, tok,
  specify_output_terminal_descriptor__list_of_path_outputs,
  polarity_operator, data_source_expression, path_delay_value)
  return AST[:edge_sensitive_path_declaration,
             expression,edge_identifier,
             specify_input_terminal_descriptor,tok,
             spcify_output_terminal_descriptor__list_of_path_outputs,
             polarity_operator,data_source_expression,path_delay_value, self.property_hook ]
end

#edge_sensitive_path_declaration_parseObject



5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
# File 'lib/HDLRuby/verilog_parser.rb', line 5620

def edge_sensitive_path_declaration_parse
  parse_state = self.state
  unless self.get_token(IF_REX) then
    self.state = parse_state
    return nil
  end
  self.parse_error("opening parenthesis expected") unless self.get_token(OPEN_PAR_REX)
  expression = self.expression_parse
  edge_identifier = self.edge_identifier_parse
  specify_input_terminal_descriptor = 
    self.specify_input_terminal_descriptor_parse
  if !specify_input_terminal_descriptor then
    self.state = parse_state
    return nil
  end
  if self.get_token(SEND_ARROW_REX) then
    self.parse_error("opening parenthesis expected") unless self.get_token(OPEN_PAR_REX)
    specify_output_terminal_descriptor =
      self.specify_output_terminal_Descriptor_parse
    self.parse_error("output terminal descriptor expected") unless specify_output_terminal_descriptor
    polarity_operator = self.polarity_operator_parse
    self.parse_error("colon expected") unless self.get_token(COLON_REX)
    data_source_expression = self.data_source_expression_parse
    self.parse_error("data source expression expected") unless data_source_expression
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    self.parse_error("equal expected") unless self.get_token(EQUAL_REX)
    path_delay_value = self.path_delay_value_parse
    self.parse_error("path delay value expected") unless path_delay_value
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    return self.edge_sensitive_path_declaration_hook(
      expression,edge_identifier,specify_input_terminal_descriptor,
      tok,specify_output_terminal_descriptor,polarity_operator,
      data_source_expression,path_delay_value)
  elsif tok == ASTERISK_ARROW_TOK then
    self.parse_error("opening parenthesis expected") unless self.get_token(OPEN_PAR_REX)
    list_of_path_outputs = self.list_of_path_outputs_parse
    self.parse_error("list of path outputs expected") unless list_of_path_outputs
    polarity_operator = self.polarity_operator_parse
    self.parse_error("colon expected") unless self.get_token(COLON_REX)
    data_source_expression = self.data_source_expression_parse
    self.parse_error("data source expression expected") unless data_source_expression
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    self.parse_error("equal expected") unless self.get_token(EQUAL_REX)
    path_delay_value = self.path_delay_value_parse
    self.parse_error("path delay value expected") unless path_delay_value
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    return self.edge_sensitive_path_declaration_hook(
      expression,edge_identifier,specify_input_terminal_descriptor,
      tok,list_of_path_outputs,polarity_operator,
      data_source_expression,path_delay_value)
  else
    self.state = parse_state
    return nil
  end
end

#eof?Boolean

Tells if the end of file/string is reached (ignores the spaces and comments for this check)

Returns:

  • (Boolean)


604
605
606
# File 'lib/HDLRuby/verilog_parser.rb', line 604

def eof?
  return (@state.text.match(/\G#{S}\z/,@state.index) != nil)
end

#equal_term_hook(comparison_terms) ⇒ Object



6249
6250
6251
6252
6253
6254
6255
# File 'lib/HDLRuby/verilog_parser.rb', line 6249

def equal_term_hook(comparison_terms)
  if self.state.compress and comparison_terms.size == 1 then
    return comparison_terms[0]
  else
    return AST[:equal_term, comparison_terms, self.property_hook ]
  end
end

#equal_term_parseObject



6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
# File 'lib/HDLRuby/verilog_parser.rb', line 6232

def equal_term_parse
  # puts "equal_term_parse"
  cur_comparison_term = self.comparison_term_parse
  return nil unless cur_comparison_term
  comparison_terms = [ cur_comparison_term ]
  tok = nil
  loop do
    tok = self.get_token(COMPARISON_OPERATOR_REX)
    break unless tok
    comparison_terms << tok
    cur_comparison_term = self.comparison_term_parse
    self.parse_error("expression expected") unless cur_comparison_term
    comparison_terms << cur_comparison_term
  end
  return equal_term_hook(comparison_terms)
end

#event_control_hook(identifier__event_control) ⇒ Object



7158
7159
7160
# File 'lib/HDLRuby/verilog_parser.rb', line 7158

def event_control_hook(identifier__event_control)
  return AST[:event_control, identifier__event_control, self.property_hook ]
end

#event_control_parseObject



7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
# File 'lib/HDLRuby/verilog_parser.rb', line 7143

def event_control_parse
  unless self.get_token(AT_REX) then
    return nil
  end
  identifier = self.identifier_parse
  if identifier then
    return self.event_control_hook(identifier)
  end
  self.parse_error("opening parenthesis expected") unless self.get_token(OPEN_PAR_REX)
  event_expression = self.event_expression_parse
  self.parse_error("event expression expected") unless event_expression
  self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
  return self.event_control_hook(event_expression)
end

#event_declaration_hook(name_of_events) ⇒ Object



2939
2940
2941
# File 'lib/HDLRuby/verilog_parser.rb', line 2939

def event_declaration_hook(name_of_events)
  return AST[:event_declaration, name_of_events, self.property_hook ]
end

#event_declaration_parseObject



2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
# File 'lib/HDLRuby/verilog_parser.rb', line 2921

def event_declaration_parse
  # puts "event_declaration_parse"
  unless self.get_token(EVENT_REX) then
    return nil
  end
  cur_name_of_event = self.name_of_event_parse
  name_of_events = [ cur_name_of_event ]
  loop do
    unless self.get_token(COMMA_REX) then
      break
    end
    cur_name_of_event = self.name_of_event_parse
    name_of_events << cur_name_of_event
  end
  self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
  return event_declaration_hook(name_of_events)
end

#event_expression_hook(event_primaries) ⇒ Object



7234
7235
7236
# File 'lib/HDLRuby/verilog_parser.rb', line 7234

def event_expression_hook(event_primaries)
  return AST[:event_expression, event_primaries, self.property_hook ]
end

#event_expression_parseObject



7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
# File 'lib/HDLRuby/verilog_parser.rb', line 7221

def event_expression_parse
  cur_event_primary = self.event_primary_parse
  return nil unless cur_event_primary
  event_primaries = [ cur_event_primary ]
  loop do
    break unless self.get_token(EVENT_OR_COMMA_REX)
    cur_event_primary = self.event_primary_parse
    self.parse_error("event expression expected") unless cur_event_primary
    event_primaries << cur_event_primary
  end
  return event_expression_hook(event_primaries)
end

#event_primary_hook(tok__expression, event_expression) ⇒ Object



7264
7265
7266
7267
# File 'lib/HDLRuby/verilog_parser.rb', line 7264

def event_primary_hook(tok__expression, event_expression)
  return AST[:event_primary,
             tok__expression, event_expression, self.property_hook ]
end

#event_primary_parseObject



7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
# File 'lib/HDLRuby/verilog_parser.rb', line 7249

def event_primary_parse
  if self.get_token(MUL_REX) then
    return event_primary_hook(MUL_TOK,nil)
  end
  tok = self.get_token(EDGE_IDENTIFIER_REX)
  if tok then
    scalar_event_expression = self.scalar_event_expression_parse
    self.parse_error("scalar event expression expected") unless scalar_event_expression
    return self.event_primary_hook(tok,scalar_event_expression)
  end
  expression = self.expression_parse
  return nil unless expression
  return self.event_primary_hook(expression,nil)
end

#expandrange_hook(type, range) ⇒ Object



2821
2822
2823
# File 'lib/HDLRuby/verilog_parser.rb', line 2821

def expandrange_hook(type, range)
  return AST[:expandrange, type,range, self.property_hook ]
end

#expandrange_parseObject



2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
# File 'lib/HDLRuby/verilog_parser.rb', line 2805

def expandrange_parse
  if self.get_token(SCALARED_REX) then
    range = self.range_parse
    self.parse_error("range expected") unless range
    return expandrange_hook(SCALARED_TOK.to_sym, range)
  end
  if self.get_token(VECTORED_REX) then
    range = self.range_parse
    self.parse_error("range expected") unless range
    return expandrange_hook(VECTORED_TOK.to_sym, range)
  end
  range = self.range_parse
  return nil unless range
  return expandrange_hook(:"", range)
end

#expression_hook(string__condition_terms) ⇒ Object



6020
6021
6022
6023
6024
6025
6026
6027
# File 'lib/HDLRuby/verilog_parser.rb', line 6020

def expression_hook(string__condition_terms)
  if self.state.compress and string__condition_terms.is_a?(Array) and 
      string__condition_terms.size == 1 then
    return AST[:expression, string__condition_terms[0] ]
  else
    return AST[:expression, string__condition_terms, self.property_hook ]
  end
end

#expression_parseObject



5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
# File 'lib/HDLRuby/verilog_parser.rb', line 5996

def expression_parse
  # puts "expression_parse"
  string = self._STRING_parse
  if string then
    return self.expression_hook(string)
  end
  cur_condition_term = self.condition_term_parse
  return nil unless cur_condition_term
  condition_terms = [ cur_condition_term ]
  loop do
    break unless self.get_token(QUESTION_REX)
    condition_terms << QUESTION_TOK
    cur_condition_term = self.condition_term_parse
    self.parse_error("expression expected") unless cur_condition_term
    condition_terms << cur_condition_term
    self.parse_error("colon expected") unless self.get_token(COLON_REX)
    condition_terms << COLON_TOK
    cur_condition_term = self.condition_term_parse
    self.parse_error("expression expected") unless cur_condition_term
    condition_terms << cur_condition_term
  end
  return expression_hook(condition_terms)
end

#file_error(error, lpos = @state.lpos) ⇒ Object

Generate a file error with origin indicated in +error+

Raises:



629
630
631
# File 'lib/HDLRuby/verilog_parser.rb', line 629

def file_error(error, lpos=@state.lpos)
  raise FileError.new(error,lpos)
end

#function_call_hook(name_of_function__name_of_system_function, expressions) ⇒ Object



6831
6832
6833
6834
6835
6836
# File 'lib/HDLRuby/verilog_parser.rb', line 6831

def function_call_hook(name_of_function__name_of_system_function,
                       expressions)
  return AST[:function_call,
             name_of_function__name_of_system_function,
             expressions, self.property_hook ]
end

#function_call_parseObject



6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
# File 'lib/HDLRuby/verilog_parser.rb', line 6788

def function_call_parse
  parse_state = self.state
  name_of_function = self.name_of_function_parse
  if name_of_function then
    unless self.get_token(OPEN_PAR_REX) then
      self.state = parse_state
      return nil
    end
    cur_expression = self.expression_parse
    self.parse_error("expression expected") unless cur_expression
    expressions = [ cur_expression ]
    loop do
      unless self.get_token(COMMA_REX) then
        break
      end
      cur_expression = self.expression_parse
      self.parse_error("expression expected") unless cur_expression
      expressions << cur_expression
    end
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    return self.function_call_hook(name_of_function,expressions)
  end
  name_of_system_function = self.name_of_system_function_parse
  return nil unless name_of_system_function
  if self.get_token(OPEN_PAR_REX) then
    cur_expression = self.expression_parse
    self.parse_error("expression expected") unless cur_expression
    expressions = [ cur_expression ]
    loop do
      unless self.get_token(COMMA_REX) then
        break
      end
      cur_expression = self.expression_parse
      self.parse_error("expression expected") unless cur_expression
      expressions << expression
    end
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    return self.function_call_hook(name_of_system_function,expressions)
  else
    return self.function_call_hook(name_of_system_function,nil)
  end
end

#function_hook(range_or_type, name_of_function, tf_declarations, statement) ⇒ Object



2435
2436
2437
2438
2439
# File 'lib/HDLRuby/verilog_parser.rb', line 2435

def function_hook(range_or_type, name_of_function,
                  tf_declarations, statement)
  return AST[:function, 
             range_or_type,name_of_function,tf_declarations,statement, self.property_hook ]
end

#function_parseObject



2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
# File 'lib/HDLRuby/verilog_parser.rb', line 2413

def function_parse
  unless self.get_token(FUNCTION_REX) then
    return nil
  else
    range_or_type = self.range_or_type_parse
    name_of_function = self.name_of_function_parse
    self.parse_error("name of function expected") unless self.get_token(SEMICOLON_REX)
    cur_tf_declaration = self.tf_declaration_parse
    self.parse_error("tf declaration expected") unless cur_tf_declaration
    tf_declarations = [ cur_tf_declaration ]
    loop do
      cur_tf_declaration = self.tf_declaration_parse
      break unless cur_tf_declaration
      tf_declarations << cur_tf_declaration
    end
    statement = self.statement_parse
    self.parse_error("'endfunction' expected") unless self.get_token(ENDFUNCTION_REX)
    return self.function_hook(range_or_type,name_of_function,
                              tf_declarations,statement)
  end
end

#gate_declaration_hook(gatetype, drive_strength, delay, gate_instances) ⇒ Object



3322
3323
3324
3325
3326
# File 'lib/HDLRuby/verilog_parser.rb', line 3322

def gate_declaration_hook(gatetype, drive_strength, delay,
                          gate_instances)
  return AST[:gate_declaration,
             gatetype,drive_strength,delay,gate_instances, self.property_hook ]
end

#gate_declaration_parseObject



3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
# File 'lib/HDLRuby/verilog_parser.rb', line 3302

def gate_declaration_parse
  # puts "gate_declaration_parse"
  gatetype = self._GATETYPE_parse
  return nil unless gatetype
  drive_strength = self.drive_strength_parse
  delay = self.delay_parse
  cur_gate_instance = self.gate_instance_parse
  self.parse_error("gate instance expected") unless cur_gate_instance
  gate_instances = [ cur_gate_instance ]
  loop do
    break unless self.get_token(COMMA_REX)
    cur_gate_instance = self.gate_instance_parse
    self.parse_error("gate instance expected") unless cur_gate_instance
    gate_instances << cur_gate_instance
  end
  self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
  return gate_declaration_hook(gatetype,drive_strength,delay,
                               gate_instances)
end

#gate_instance_hook(name_of_gate_instance, terminals) ⇒ Object



3431
3432
3433
# File 'lib/HDLRuby/verilog_parser.rb', line 3431

def gate_instance_hook(name_of_gate_instance, terminals)
  return AST[:gate_instance, name_of_gate_instance,terminals, self.property_hook ]
end

#gate_instance_parseObject



3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
# File 'lib/HDLRuby/verilog_parser.rb', line 3409

def gate_instance_parse
  parse_state = self.state
  name_of_gate_instance = self.name_of_gate_instance_parse
  unless self.get_token(OPEN_PAR_REX) then
    self.state = parse_state
    return nil
  end
  cur_terminal = self.terminal_parse
  unless cur_terminal then
    self.parse_error("terminal expected")
  end
  terminals = [ cur_terminal ]
  loop do
    break unless self.get_token(COMMA_REX)
    cur_terminal = self.terminal_parse
    self.parse_error("terminal expected") unless cur_terminal
    terminals << cur_terminal
  end
  self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
  return gate_instance_hook(name_of_gate_instance,terminals)
end

#get_token(rex) ⇒ Object

Get the token matching regexp +rex+ if any from current position. NOTE: it is assumed that rex starts with \G so that the maching really starts from current position of the parser and has a single capture for the token. Also assumes spaces are taken into account in the regexp.



575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
# File 'lib/HDLRuby/verilog_parser.rb', line 575

def get_token(rex)
  # puts "get_token at index=#{@state.index} and lpos=#{@state.lpos} with rex=#{rex} and char is #{@state.text[@state.index]}"
  # puts "text line is #{@state.text[(@[email protected])[email protected]]}"
  begin
    match = @state.text.match(rex,@state.index)
  rescue => error
    self.file_error(error)
  end
  if match then
    # There is a match, get the blanks and the token
    bls = match.captures[0]
    tok = match.captures[1]
    @state.index = match.end(0)
    @state.lpos += bls.scan(/\n/).size
    # spcs = bls.match(/[ \t]*\z/)
    # @state.cpos = spcs.end(0) - spcs.begin(0)+tok.length
    @state.cpos = 0
    while @state.index > @state.cpos and
        !(@state.text[@state.index-@state.cpos] =~ /\n/) do
      @state.cpos += 1
    end
    return tok
  else
    return nil
  end
end

#identifier_hook(identifiers) ⇒ Object



7016
7017
7018
# File 'lib/HDLRuby/verilog_parser.rb', line 7016

def identifier_hook(identifiers)
  return AST[:identifier, *identifiers, self.property_hook ]
end

#identifier_parseObject



7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
# File 'lib/HDLRuby/verilog_parser.rb', line 7003

def identifier_parse
  cur_identifier = self._IDENTIFIER_parse
  return nil unless cur_identifier
  identifiers = [ cur_identifier ]
  loop do
    break unless self.get_token(DOT_REX)
    cur_identifier = self._IDENTIFIER_parse
    self.parse_error("identifier expected") unless cur_identifier
    identifiers << identifier
  end
  return self.identifier_hook(identifiers)
end

#init_val_hook(val) ⇒ Object



2036
2037
2038
# File 'lib/HDLRuby/verilog_parser.rb', line 2036

def init_val_hook(val)
  return AST[:init_val, val, self.property_hook ]
end

#init_val_parseObject



2030
2031
2032
2033
2034
# File 'lib/HDLRuby/verilog_parser.rb', line 2030

def init_val_parse
  val = self.get_token(INIT_VAL_REX)
  self.parse_error("One of [#{INIT_VAL_TOKS.join(",")}] expected") unless val
  return self.init_val_hook(val)
end

#initial_statement_hook(statement) ⇒ Object



3829
3830
3831
# File 'lib/HDLRuby/verilog_parser.rb', line 3829

def initial_statement_hook(statement)
  return AST[:initial_statement, statement, self.property_hook ]
end

#initial_statement_parseObject



3820
3821
3822
3823
3824
3825
3826
3827
# File 'lib/HDLRuby/verilog_parser.rb', line 3820

def initial_statement_parse
  unless self.get_token(INITIAL_REX) then
    return nil
  end
  statement = self.statement_parse
  self.parse_error("statement expected") unless statement
  return self.initial_statement_hook(statement)
end

#inout_declaration_hook(type, sign, range, list_of_variables) ⇒ Object



2683
2684
2685
# File 'lib/HDLRuby/verilog_parser.rb', line 2683

def inout_declaration_hook(type, sign, range, list_of_variables)
  return AST[:inout_declaration, type,sign,range,list_of_variables, self.property_hook ]
end

#inout_declaration_parseObject



2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
# File 'lib/HDLRuby/verilog_parser.rb', line 2670

def inout_declaration_parse
  # puts "inout_declaration_parse"
  unless self.get_token(INOUT_REX) then
    return nil
  end
  type = self.get_token(INOUTTYPE_REX)
  sign = self.get_token(SIGNED_REX)
  range = self.range_parse
  list_of_variables = self.list_of_variables_parse
  self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
  return self.inout_declaration_hook(type,sign,range,list_of_variables)
end

#inout_port_declaration_hook(type, sign, range, name_of_variable) ⇒ Object



1752
1753
1754
# File 'lib/HDLRuby/verilog_parser.rb', line 1752

def inout_port_declaration_hook(type, sign, range, name_of_variable)
  return AST[:inout_port_declaration, type,sign,range,name_of_variable, self.property_hook ]
end

#inout_port_declaration_parseObject



1742
1743
1744
1745
1746
1747
1748
1749
1750
# File 'lib/HDLRuby/verilog_parser.rb', line 1742

def inout_port_declaration_parse
  return nil unless self.get_token(INOUT_REX)
  type = self.get_token(INOUTTYPE_REX)
  sign = self.get_token(SIGNED_REX)
  range = self.range_parse
  name_of_variable = self.name_of_variable_parse
  self.parse_error("identifier expected") unless name_of_variable
  return inout_port_declaration_hook(type,sign,range,name_of_variable)
end

#input_declaration_hook(type, sign, range, list_of_variables) ⇒ Object



2617
2618
2619
# File 'lib/HDLRuby/verilog_parser.rb', line 2617

def input_declaration_hook(type, sign, range, list_of_variables)
  return AST[:input_declaration, type,sign,range,list_of_variables, self.property_hook ]
end

#input_declaration_parseObject



2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
# File 'lib/HDLRuby/verilog_parser.rb', line 2603

def input_declaration_parse
  # puts "input_declaration_parse"
  unless self.get_token(INPUT_REX) then
    return nil
  end
  type = self.get_token(INPUTTYPE_REX) 
  sign = self.get_token(SIGNED_REX)
  range = self.range_parse
  list_of_variables = self.list_of_variables_parse
  self.parse_error("identifier expected") unless list_of_variables
  self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
  return self.input_declaration_hook(type,sign,range,list_of_variables)
end

#input_identifier_hook(identifier) ⇒ Object



4855
4856
4857
# File 'lib/HDLRuby/verilog_parser.rb', line 4855

def input_identifier_hook(identifier)
  return AST[:input_identifier, identifier, self.property_hook ]
end

#input_identifier_parseObject



4848
4849
4850
4851
4852
4853
# File 'lib/HDLRuby/verilog_parser.rb', line 4848

def input_identifier_parse
  # *Auth*: it should be checked that the identifier comes from
  # an input module. Left the the AST processing.
  identifier = self._IDENTIFIER_parse
  return self.input_identifier_hook(identifier)
end

#input_list_hook(input_list) ⇒ Object



2185
2186
2187
2188
2189
2190
2191
# File 'lib/HDLRuby/verilog_parser.rb', line 2185

def input_list_hook(input_list)
  if self.state.compress then
    return input_list
  else
    return AST[:input_list, input_list, self.property_hook ]
  end
end

#input_list_parseObject



2176
2177
2178
2179
2180
2181
2182
2183
# File 'lib/HDLRuby/verilog_parser.rb', line 2176

def input_list_parse
  input_list = self.edge_input_list_parse
  if !input_list then
    input_list = self.level_input_list_parse
    return nil unless input_list
  end
  return self.input_list_hook(input_list)
end

#input_port_declaration_hook(type, sign, range, name_of_variable) ⇒ Object



1709
1710
1711
# File 'lib/HDLRuby/verilog_parser.rb', line 1709

def input_port_declaration_hook(type, sign, range, name_of_variable)
  return AST[:input_port_declaration, type,sign,range,name_of_variable, self.property_hook ]
end

#input_port_declaration_parseObject



1699
1700
1701
1702
1703
1704
1705
1706
1707
# File 'lib/HDLRuby/verilog_parser.rb', line 1699

def input_port_declaration_parse
  return nil unless self.get_token(INPUT_REX)
  type = self.get_token(INPUTTYPE_REX)
  sign = self.get_token(SIGNED_REX)
  range = self.range_parse
  name_of_variable = self.name_of_variable_parse
  self.parse_error("identifier expected") unless name_of_variable
  return input_port_declaration_hook(type,sign,range,name_of_variable)
end

#integer_declaration_hook(list_of_register_variables) ⇒ Object



2891
2892
2893
# File 'lib/HDLRuby/verilog_parser.rb', line 2891

def integer_declaration_hook(list_of_register_variables)
  return AST[:integer_declaration, list_of_register_variables, self.property_hook ]
end

#integer_declaration_parseObject



2881
2882
2883
2884
2885
2886
2887
2888
2889
# File 'lib/HDLRuby/verilog_parser.rb', line 2881

def integer_declaration_parse
  # puts "integer_declaration_parse"
  unless self.get_token(INTEGER_REX) then
    return nil
  end
  list_of_register_variables = self.list_of_register_variables_parse
  self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
  return integer_declaration_hook(list_of_register_variables)
end

#level_input_list_hook(level_symbols) ⇒ Object



2211
2212
2213
# File 'lib/HDLRuby/verilog_parser.rb', line 2211

def level_input_list_hook(level_symbols)
  return AST[:level_input_list, level_symbols, self.property_hook ]
end

#level_input_list_parseObject



2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
# File 'lib/HDLRuby/verilog_parser.rb', line 2199

def level_input_list_parse
  cur_level_symbol = self._LEVEL_SYMBOL_parse
  return nil unless cur_level_symbol
  level_symbols = [ cur_level_symbol ]
  loop do
    cur_level_symbol = self._LEVEL_SYMBOL_parse
    break unless cur_level_symbol
    level_symbols << cur_level_symbol
  end
  return self.level_input_list_hook(level_symbols)
end

#level_sensitive_path_declaration_hook(conditional_port_expression, input, polarity_operator, tok, output, path_delay_value) ⇒ Object



5539
5540
5541
5542
5543
5544
# File 'lib/HDLRuby/verilog_parser.rb', line 5539

def level_sensitive_path_declaration_hook(
  conditional_port_expression,
  input, polarity_operator, tok, output, path_delay_value)
  return AST[:level_sensitive_path_declaration,
             input, polarity_operator, tok, output, path_delay_value, self.property_hook ]
end

#level_sensitive_path_declaration_parseObject



5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
# File 'lib/HDLRuby/verilog_parser.rb', line 5490

def level_sensitive_path_declaration_parse
  unless self.get_token(IF_REX) then
    return nil
  end
  self.parse_error("opening parenthesis expected") unless self.get_tokeen(OPEN_PAR_REX)
  conditional_port_expression = self.conditional_port_expression_parse
  self.parse_error("conditional port expression expected") unless conditional_port_expression
  self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
  self.parse_error("openning parenthesis expected") unless self.get_token(OPEN_PAR_REX)
  parse_state = self.state
  specify_input_terminal_descriptor = 
    self.specify_input_terminal_descriptor_parse
  self.parse_error("input terminal descriptor expected") unless specify_input_terminal_descriptor
  polarity_operator = self.polarity_operator_parse
  if self.get_token(SEND_ARROW_REX) then
    # This is the right rule, go no
    specify_output_terminal_descriptor = 
      self.specify_output_terminal_descriptor_parse
    self.parse_error("output terminal descriptor expected") unless specify_output_terminal_descriptor
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    self.parse_error("equal expected") unless self.get_token(EQUAL_REX)
    path_delay_value = self.path_delay_value_parse
    self.parse_error("path delay value expected") unless path_delay_value
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    return self.level_sensitive_path_declaration_hook(
      conditional_port_expression,
      specify_input_terminal_descriptor, polarity_operator, tok,
      specify_output_terminal_descriptor, path_delay_value)
  else
    # This is maybe the other rule, rewind.
    self.state = parse_state
    list_of_path_inputs = self.list_of_path_inputs_parse
    self.parse_error("list of path inputs expected") unless list_of_path_inputs
    polarity_operator = self.polarity_operator_parse
    self.parse_error("'*>' expected") unless self.get_token(ASTERISK_ARROW_REX)
    list_of_path_outputs = self.list_of_path_outputs_parse
    self.parse_error("list of path outputs expected") unless list_of_path_outputs
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    self.parse_error("equal expected") unless self.get_token(EQUAL_TOK_REX)
    path_delay_value = self.path_delay_value_parse
    self.parse_error("path delay value expected") unless path_delay_value
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    return self.level_sensitive_path_declaration_hook(
      conditional_port_expression,
      list_of_path_inputs, polarity_operator, tok,
      list_of_path_outputs, path_delay_value)
  end
end

#list_of_assignments_hook(assignments) ⇒ Object



3289
3290
3291
# File 'lib/HDLRuby/verilog_parser.rb', line 3289

def list_of_assignments_hook(assignments)
  return AST[:list_of_assigments, assignments, self.property_hook ]
end

#list_of_assignments_parseObject



3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
# File 'lib/HDLRuby/verilog_parser.rb', line 3274

def list_of_assignments_parse
  cur_assignment = self.assignment_parse
  self.parse_error("assignment expected") unless cur_assignment
  assignments = [ cur_assignment ]
  loop do
    unless self.get_token(COMMA_REX) then
      break
    end
    cur_assignment = self.assignment_parse
    self.parse_error("assignment expected") unless cur_assignment
    assignments << cur_assignment
  end
  return list_of_assignments_hook(assignments)
end

#list_of_module_connections_hook(connections) ⇒ Object



3752
3753
3754
# File 'lib/HDLRuby/verilog_parser.rb', line 3752

def list_of_module_connections_hook(connections)
  return AST[:list_of_module_connections, connections, self.property_hook ]
end

#list_of_module_connections_parseObject



3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
# File 'lib/HDLRuby/verilog_parser.rb', line 3723

def list_of_module_connections_parse
  cur_named_port_connection = self.named_port_connection_parse
  if cur_named_port_connection then
    named_port_connections = [ cur_named_port_connection ]
    loop do
      unless self.get_token(COMMA_REX) then
        break
      end
      cur_named_port_connection = self.named_port_connection_parse
      self.parse_error("named port connection expected") unless cur_named_port_connection
      named_port_connections << cur_named_port_connection
    end
    return list_of_module_connections_hook(named_port_connections)
  else
    cur_module_port_connection = self.module_port_connection_parse
    return nil unless cur_module_port_connection
    module_port_connections = [ cur_module_port_connection ]
    loop do
      unless self.get_token(COMMA_REX) then
        break
      end
      cur_module_port_connection = self.module_port_connection_parse
      self.parse_error("module port connection expected") unless cur_module_port_connection
      module_port_connections << cur_module_port_connection
    end
    return list_of_module_connections_hook(module_port_connections)
  end
end

#list_of_param_assignments_hook(param_assignments) ⇒ Object



2567
2568
2569
# File 'lib/HDLRuby/verilog_parser.rb', line 2567

def list_of_param_assignments_hook(param_assignments)
  return AST[:list_of_param_assignments, param_assignments, self.property_hook ]
end

#list_of_param_assignments_parseObject



2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
# File 'lib/HDLRuby/verilog_parser.rb', line 2554

def list_of_param_assignments_parse
  cur_param_assignment = self.param_assignment_parse
  param_assignments = [ cur_param_assignment ]
  loop do
    unless self.get_token(COMMA_REX) then
      break
    end
    cur_param_assignment = self.param_assignment_parse
    param_assignments << cur_param_assignment
  end
  return self.list_of_param_assignments_hook(param_assignments)
end

#list_of_path_inputs_hook(specify_input_terminal_descriptors) ⇒ Object



4728
4729
4730
4731
# File 'lib/HDLRuby/verilog_parser.rb', line 4728

def list_of_path_inputs_hook(specify_input_terminal_descriptors)
  return AST[:list_of_path_inputs,
             specify_input_terminal_descriptors, self.property_hook ]
end

#list_of_path_inputs_parseObject



4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
# File 'lib/HDLRuby/verilog_parser.rb', line 4710

def list_of_path_inputs_parse
  cur_specify_input_terminal_descriptor = 
    self.specify_input_terminal_descriptor_parse
  return nil unless cur_specify_input_terminal_descriptor
  specify_input_terminal_descriptors = 
    [ cur_specify_input_terminal_descriptor ]
  loop do
    unless self.get_token(COMMA_REX) then
      break
    end
    cur_specify_input_terminal_descriptor = 
      self.specify_input_terminal_descriptor_parse
    self.parse_error("input terminal descriptor expected") unless cur_specify_input_terminal_descriptor
    specify_input_terminal_descriptors << cur_specify_input_terminal_descriptor
  end
  return self.list_of_path_inputs_hook(specify_input_terminal_descriptors)
end

#list_of_path_outputs_hook(specify_output_terminal_descriptors) ⇒ Object



4757
4758
4759
4760
# File 'lib/HDLRuby/verilog_parser.rb', line 4757

def list_of_path_outputs_hook(specify_output_terminal_descriptors)
  return AST[:list_of_path_outputs,
             specify_output_terminal_descriptors, self.property_hook ]
end

#list_of_path_outputs_parseObject



4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
# File 'lib/HDLRuby/verilog_parser.rb', line 4739

def list_of_path_outputs_parse
  cur_specify_output_terminal_descriptor = 
    self.specify_output_terminal_descriptor_parse
  return nil unless cur_specify_output_terminal_descriptor
  specify_output_terminal_descriptors = 
    [ cur_specify_output_terminal_descriptor ]
  loop do
    unless self.get_token(COMMA_REX) then
      break
    end
    cur_specify_output_terminal_descriptor = 
      self.specify_output_terminal_descriptor_parse
    self.parse_erro("output terminal descriptor expected") unless cur_specify_output_terminal_descriptor
    specify_output_terminal_descriptors << cur_specify_output_terminal_descriptor
  end
  return self.list_of_path_outputs_hook(specify_output_terminal_descriptors)
end

#list_of_ports_hook(ports) ⇒ Object



1573
1574
1575
# File 'lib/HDLRuby/verilog_parser.rb', line 1573

def list_of_ports_hook(ports)
  return AST[:list_of_ports, ports, self.property_hook ]
end

#list_of_ports_parseObject



1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
# File 'lib/HDLRuby/verilog_parser.rb', line 1550

def list_of_ports_parse
  if self.get_token(OPEN_PAR_REX) then
    cur_port = self.port_parse
    ports = [ cur_port ]
    loop do
      if self.get_token(COMMA_REX) then
        cur_port = self.port_parse
      else
        if self.get_token(CLOSE_PAR_REX) then
          cur_port = nil
        else
          self.parse_error("comma of closing parenthesis expected")
        end
      end
      break unless cur_port
      ports << cur_port
    end
    return list_of_ports_hook(ports)
  else
    return nil
  end
end

#list_of_register_variables_hook(register_variables) ⇒ Object



3057
3058
3059
# File 'lib/HDLRuby/verilog_parser.rb', line 3057

def list_of_register_variables_hook(register_variables)
  return AST[:list_of_register_variables, register_variables, self.property_hook ]
end

#list_of_register_variables_parseObject



3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
# File 'lib/HDLRuby/verilog_parser.rb', line 3044

def list_of_register_variables_parse
  cur_register_variable = self.register_variable_parse
  register_variables = [ cur_register_variable ]
  loop do
    unless self.get_token(COMMA_REX)
      break
    end
    cur_register_variable = self.register_variable_parse
    register_variables << cur_register_variable
  end
  return list_of_register_variables_hook(register_variables)
end

#list_of_variables_hook(name_of_variables) ⇒ Object



3018
3019
3020
# File 'lib/HDLRuby/verilog_parser.rb', line 3018

def list_of_variables_hook(name_of_variables)
  return AST[:list_of_variables, name_of_variables, self.property_hook ]
end

#list_of_variables_parseObject



3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
# File 'lib/HDLRuby/verilog_parser.rb', line 3005

def list_of_variables_parse
  cur_name_of_variable = self.name_of_variable_parse
  name_of_variables = [ cur_name_of_variable ]
  loop do
    unless self.get_token(COMMA_REX)
      break
    end
    cur_name_of_variable = self.name_of_variable_parse
    name_of_variables << cur_name_of_variable
  end
  return list_of_variables_hook(name_of_variables)
end

#logic_and_term_hook(bit_or_terms) ⇒ Object



6116
6117
6118
6119
6120
6121
6122
# File 'lib/HDLRuby/verilog_parser.rb', line 6116

def logic_and_term_hook(bit_or_terms)
  if self.state.compress and bit_or_terms.size == 1 then
    return bit_or_terms[0]
  else
    return AST[:logic_and_term, bit_or_terms, self.property_hook ]
  end
end

#logic_and_term_parseObject



6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
# File 'lib/HDLRuby/verilog_parser.rb', line 6099

def logic_and_term_parse
  # puts "logic_and_term_parse"
  cur_bit_or_term = self.bit_or_term_parse
  return nil unless cur_bit_or_term
  bit_or_terms = [ cur_bit_or_term ]
  tok = nil
  loop do
    tok = self.get_token(OR_OPERATOR_REX)
    break unless tok
    bit_or_terms << tok
    cur_bit_or_term = self.bit_or_term_parse
    self.parse_error("expression expected") unless cur_bit_or_term
    bit_or_terms << cur_bit_or_term
  end
  return logic_and_term_hook(bit_or_terms)
end

#logic_or_term_hook(logic_and_terms) ⇒ Object



6083
6084
6085
6086
6087
6088
6089
# File 'lib/HDLRuby/verilog_parser.rb', line 6083

def logic_or_term_hook(logic_and_terms)
  if self.state.compress and logic_and_terms.size == 1 then
    return logic_and_terms[0]
  else
    return AST[:logic_or_term, logic_and_terms, self.property_hook ]
  end
end

#logic_or_term_parseObject



6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
# File 'lib/HDLRuby/verilog_parser.rb', line 6068

def logic_or_term_parse
  # puts "logic_or_term_parse"
  cur_logic_and_term = self.logic_and_term_parse
  return nil unless cur_logic_and_term
  logic_and_terms = [ cur_logic_and_term ]
  loop do
    break unless self.get_token(AND_AND_REX)
    logic_and_terms << AND_AND_TOK
    cur_logic_and_term = self.logic_and_term_parse
    self.parse_error("expression expected") unless cur_logic_and_term
    logic_and_terms << cur_logic_and_term
  end
  return logic_or_term_hook(logic_and_terms)
end

#long_comment_hook(comment_text) ⇒ Object



6955
6956
6957
# File 'lib/HDLRuby/verilog_parser.rb', line 6955

def long_comment_hook(comment_text)
  return AST[:long_comment, comment_text, self.property_hook ]
end

#long_comment_parseObject



6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
# File 'lib/HDLRuby/verilog_parser.rb', line 6942

def long_comment_parse
  unless self.get_token(SLASH_ASTERISK_REX) then
    return nil
  end
  # comment_text = self.comment_text_parse
  # *Auth*: long and short comment are separated while in the
  # BNF the are the same rule.
  comment_text = self.long_comment_text_parse
  self.parse_error("comment text expected") unless comment_text
  self.parse_error("'*/' expected") unless self.get_token(ASTERISK_SLASH_REX)
  return self.long_comment_hook(comment_text)
end

#long_comment_text_parseObject



6986
6987
6988
6989
6990
# File 'lib/HDLRuby/verilog_parser.rb', line 6986

def long_comment_text_parse
  # *Auth*: long and short comment are separated while in the
  # BNF the are the same rule.
  return comment_text_hook(self.get_token(LONG_COMMENT_TEXT_REX))
end

#lvalue_hook(identifier__concatenation, expression__constant_expression, constant_expression) ⇒ Object



5841
5842
5843
5844
5845
5846
# File 'lib/HDLRuby/verilog_parser.rb', line 5841

def lvalue_hook(identifier__concatenation,
                expression__constant_expression, constant_expression)
  return AST[:lvalue, 
             identifier__concatenation,
             expression__constant_expression,constant_expression, self.property_hook ]
end

#lvalue_parseObject



5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
# File 'lib/HDLRuby/verilog_parser.rb', line 5813

def lvalue_parse
  concatenation = self.concatenation_parse
  if concatenation then
    return self.lvalue_hook(concatenation,nil,nil)
  end
  identifier = self.identifier_parse
  return nil unless identifier
  unless self.get_token(OPEN_BRA_REX) then
    return self.lvalue_hook(identifier,nil,nil)
  end
  parse_state = self.state
  constant_expression0 = self.constant_expression_parse
  if !constant_expression0 or !self.get_token(COLON_REX) then
    # Not constant_expression : constant_expression, rewind.
    self.state = parse_state
    expression = self.expression_parse
    self.parse_error("expression expected") unless expression
    self.parse_error("closing bracket expected") unless self.get_token(CLOSE_BRA_REX)
    return self.lvalue_hook(identifier,expression,nil)
  end
  self.parse_error("constant expression expected") unless constant_expression0
  constant_expression1 = self.constant_expression_parse
  self.parse_error("constant expression expected") unless constant_expression1
  self.parse_error("closing bracket expected") unless self.get_token(CLOSE_BRA_REX)
  return self.lvalue_hook(identifier,
                          constant_expression0, constant_expression1)
end

#mintypmax_expression_hook(expression0, expression1, expression2) ⇒ Object



5886
5887
5888
5889
# File 'lib/HDLRuby/verilog_parser.rb', line 5886

def mintypmax_expression_hook(expression0, expression1, expression2)
  return AST[:mintypmax_expression,
             expression0,expression1,expression2, self.property_hook ]
end

#mintypmax_expression_parseObject



5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
# File 'lib/HDLRuby/verilog_parser.rb', line 5871

def mintypmax_expression_parse
  expression0 = self.expression_parse
  return nil unless expression0
  unless self.get_token(COLON_REX) then
    return self.mintypmax_expression_hook(expression0,nil,nil)
  end
  expression1 = self.expression_parse
  self.parse_error("expression expected") unless expression1
  self.parse_error("colon expected") unless self.get_token(COLON_REX)
  expression2 = self.expression_parse
  self.parse_error("expression expected") unless expression2
  return self.mintypmax_expression_hook(expression0,expression1,
                                        expression2)
end

#module_hook(name, pre_parameter_declaration, ports, elems) ⇒ Object

,



1500
1501
1502
1503
1504
# File 'lib/HDLRuby/verilog_parser.rb', line 1500

def module_hook(name, pre_parameter_declaration, ports, elems) #,
                # timescale, celldefine)
  return AST[:module, name,pre_parameter_declaration,ports,elems, self.property_hook ]#,
                      # timescale,celldefine]
end

#module_instance_hook(name_of_instance, list_of_module_connections) ⇒ Object



3694
3695
3696
3697
# File 'lib/HDLRuby/verilog_parser.rb', line 3694

def module_instance_hook(name_of_instance, list_of_module_connections)
  return AST[:module_instance, 
             name_of_instance,list_of_module_connections, self.property_hook ]
end

#module_instance_parseObject



3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
# File 'lib/HDLRuby/verilog_parser.rb', line 3680

def module_instance_parse
  parse_state = self.state
  name_of_instance = self.name_of_instance_parse
  return nil unless name_of_instance
  unless self.get_token(OPEN_PAR_REX) then
    self.state = parse_state
    return nil
  end
  list_of_module_connections = self.list_of_module_connections_parse
  self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
  return module_instance_hook(name_of_instance,
                              list_of_module_connections)
end

#module_instantiation_hook(name_of_module, parameter_value_assignment, module_instances) ⇒ Object



3614
3615
3616
3617
3618
3619
3620
# File 'lib/HDLRuby/verilog_parser.rb', line 3614

def module_instantiation_hook(name_of_module,
                              parameter_value_assignment,
                              module_instances)
  return AST[:module_instantiation, 
             name_of_module,parameter_value_assignment,
             module_instances, self.property_hook ]
end

#module_instantiation_parseObject



3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
# File 'lib/HDLRuby/verilog_parser.rb', line 3588

def module_instantiation_parse
  # puts "module_instantiation_parse"
  parse_state = self.state
  name_of_module = self.name_of_module_parse
  return nil unless name_of_module
  parameter_value_assignment = self.parameter_value_assignment_parse
  cur_module_instance = self.module_instance_parse
  unless cur_module_instance then
    self.state = parse_state
    return nil
  end
  module_instances = [ cur_module_instance ]
  loop do
    unless self.get_token(COMMA_REX) then
      break
    end
    cur_module_instance = self.module_instance_parse
    self.parse_error("module instance expected") unless cur_module_instance
    module_instances << cur_module_instance
  end
  self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
  return module_instantiation_hook(name_of_module,
                                   parameter_value_assignment,
                                   module_instances)
end

#module_item_hook(item) ⇒ Object



1885
1886
1887
1888
1889
1890
1891
# File 'lib/HDLRuby/verilog_parser.rb', line 1885

def module_item_hook(item)
  if self.state.compress then
    return item
  else
    return AST[:module_item, item, self.property_hook ]
  end
end

#module_item_parseObject



1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
# File 'lib/HDLRuby/verilog_parser.rb', line 1841

def module_item_parse
  item = self.parameter_declaration_parse
  return self.module_item_hook(item) if item
  item = self.input_declaration_parse
  return self.module_item_hook(item) if item
  item = self.output_declaration_parse
  return self.module_item_hook(item) if item
  item = self.inout_declaration_parse
  return self.module_item_hook(item) if item
  item = self.net_declaration_parse
  return self.module_item_hook(item) if item
  item = self.reg_declaration_parse
  return self.module_item_hook(item) if item
  item = self.time_declaration_parse
  return self.module_item_hook(item) if item
  item = self.integer_declaration_parse
  return self.module_item_hook(item) if item
  item = self.real_declaration_parse
  return self.module_item_hook(item) if item
  item = self.event_declaration_parse
  return self.module_item_hook(item) if item
  item = self.gate_declaration_parse
  return self.module_item_hook(item) if item
  item = self.module_instantiation_parse
  return self.module_item_hook(item) if item
  item = self.udp_instantiation_parse
  return self.module_item_hook(item) if item
  item = self.parameter_override_parse
  return self.module_item_hook(item) if item
  item = self.continuous_assignment_parse
  return self.module_item_hook(item) if item
  item = self.specify_block_parse
  return self.module_item_hook(item) if item
  item = self.initial_statement_parse
  return self.module_item_hook(item) if item
  item = self.always_statement_parse
  return self.module_item_hook(item) if item
  item = self.task_parse
  return self.module_item_hook(item) if item
  item = self.function_parse
  return self.module_item_hook(item) if item
  return nil
end

#module_name?(name) ⇒ Boolean

Tells if a name is a known module name.

Returns:

  • (Boolean)


619
620
621
# File 'lib/HDLRuby/verilog_parser.rb', line 619

def module_name?(name)
  return @module_names.include?(name)
end

#module_parseObject



1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
# File 'lib/HDLRuby/verilog_parser.rb', line 1469

def module_parse
  if self.get_token(MODULE_MACROMODULE_REX) then
    # # Before parsing the module, get the timescale and celldefine 
    # # properties from current position.
    # timescale = @state.lprop[@state.lpos][:timescale]
    # timescale = nil if timescale == ""
    # celldefine = @state.lprop[@state.lpos][:celldefine]
    # celldefine = nil if celldefine == ""
    # No parse
    name = self.name_of_module_parse
    pre_parameter_declaration = self.pre_parameter_declaration_parse
    ports = self.list_of_ports_parse
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    elems = []
    cur_elem = nil
    loop do
      cur_elem = self.module_item_parse
      break unless cur_elem
      elems << cur_elem
    end
    self.parse_error("'endmodule' expected") unless self.get_token(ENDMODULE_REX)
    # Add a know module name.
    self.add_module_name(name)
    # And return the AST.
    return module_hook(name,pre_parameter_declaration,ports,elems) #,
                       # timescale,celldefine)
  else
    return nil
  end
end

#module_port_connection_hook(expression) ⇒ Object



3772
3773
3774
# File 'lib/HDLRuby/verilog_parser.rb', line 3772

def module_port_connection_hook(expression)
  return AST[:module_port_connection, expression, self.property_hook ]
end

#module_port_connection_parseObject



3763
3764
3765
3766
3767
3768
3769
3770
# File 'lib/HDLRuby/verilog_parser.rb', line 3763

def module_port_connection_parse
  expression = self.expression_parse
  if expression then
    return module_port_connection_hook(expression)
  else
    return module_port_connection_hook(_NULL_hook)
  end
end

#mul_term_hook(unary_terms) ⇒ Object



6380
6381
6382
6383
6384
6385
6386
# File 'lib/HDLRuby/verilog_parser.rb', line 6380

def mul_term_hook(unary_terms)
  if self.state.compress and unary_terms.size == 1 then
    return unary_terms[0]
  else
    return AST[:mul_term, unary_terms, self.property_hook ]
  end
end

#mul_term_parseObject



6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
# File 'lib/HDLRuby/verilog_parser.rb', line 6365

def mul_term_parse
  # puts "mul_term_parse"
  parse_state = self.state
  tok = self.get_token(UNARY_OPERATOR_REX)
  if tok then
    primary = self.primary_parse
    self.parse_error("expression expected") unless primary
    return mul_term_hook([tok,primary])
  else
    primary = self.primary_parse
    return nil unless primary
    return mul_term_hook([primary])
  end
end

#multiple_concatenation_hook(expression, expressions) ⇒ Object



6776
6777
6778
# File 'lib/HDLRuby/verilog_parser.rb', line 6776

def multiple_concatenation_hook(expression, expressions)
  return AST[:multiple_concatenation, expression,expressions, self.property_hook ]
end

#multiple_concatenation_parseObject



6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
# File 'lib/HDLRuby/verilog_parser.rb', line 6747

def multiple_concatenation_parse
  parse_state = self.state
  unless self.get_token(OPEN_CUR_REX) then
    return nil
  end
  expression = self.expression_parse
  self.parse_error("expression expected") unless expression
  unless self.get_token(OPEN_CUR_REX) then
    # It is not a multiple concatenation, maybe it is a simple one.
    # Rewind and cancel.
    self.state = parse_state
    return nil
  end
  cur_expression = self.expression_parse
  self.parse_error("expression expected") unless cur_expression
  expressions = [ cur_expression ]
  loop do
    unless self.get_token(COMMA_REX) then
      break
    end
    cur_expression = self.expression_parse
    self.parse_error("expression expected") unless cur_expression
    expressions << expression
  end
  self.parse_error("closing curly bracket expected") unless self.get_token(CLOSE_CUR_REX)
  self.parse_error("closing curly bracket expected") unless self.get_token(CLOSE_CUR_REX)
  return self.multiple_concatenation_hook(expression,expressions)
end

#name_of_block_hook(identifier) ⇒ Object



4316
4317
4318
# File 'lib/HDLRuby/verilog_parser.rb', line 4316

def name_of_block_hook(identifier)
  return AST[:name_of_block, identifier, self.property_hook ]
end

#name_of_block_parseObject



4310
4311
4312
4313
4314
# File 'lib/HDLRuby/verilog_parser.rb', line 4310

def name_of_block_parse
  identifier = self._IDENTIFIER_parse
  return nil unless identifier
  return self.name_of_block_hook(identifier)
end

#name_of_event_hook(identifier) ⇒ Object



3139
3140
3141
# File 'lib/HDLRuby/verilog_parser.rb', line 3139

def name_of_event_hook(identifier)
  return AST[:name_of_event, identifier, self.property_hook ]
end

#name_of_event_parseObject



3133
3134
3135
3136
3137
# File 'lib/HDLRuby/verilog_parser.rb', line 3133

def name_of_event_parse
  identifier = self._IDENTIFIER_parse
  return nill unless identifier
  return name_of_event_hook(identifier)
end

#name_of_function_hook(identifier) ⇒ Object



2480
2481
2482
# File 'lib/HDLRuby/verilog_parser.rb', line 2480

def name_of_function_hook(name_of_function)
  return AST[:name_of_function, name_of_function, self.property_hook ]
end

#name_of_function_parseObject



2474
2475
2476
2477
2478
# File 'lib/HDLRuby/verilog_parser.rb', line 2474

def name_of_function_parse
  identifier = self._IDENTIFIER_parse
  return nil unless identifier
  return self.name_of_function_hook(identifier)
end

#name_of_gate_instance_hook(identifier, range) ⇒ Object



3448
3449
3450
# File 'lib/HDLRuby/verilog_parser.rb', line 3448

def name_of_gate_instance_hook(identifier, range)
  return AST[:name_of_gate_instance, identifier,range, self.property_hook ]
end

#name_of_gate_instance_parseObject



3441
3442
3443
3444
3445
3446
# File 'lib/HDLRuby/verilog_parser.rb', line 3441

def name_of_gate_instance_parse
  identifier = self._IDENTIFIER_parse
  return nil unless identifier
  range = self.range_parse
  return name_of_gate_instance_hook(identifier,range)
end

#name_of_instance_hook(identifier, range) ⇒ Object



3712
3713
3714
# File 'lib/HDLRuby/verilog_parser.rb', line 3712

def name_of_instance_hook(identifier, range)
  return AST[:name_of_instance, identifier,range, self.property_hook ]
end

#name_of_instance_parseObject



3705
3706
3707
3708
3709
3710
# File 'lib/HDLRuby/verilog_parser.rb', line 3705

def name_of_instance_parse
  identifier = self._IDENTIFIER_parse
  return nil unless identifier
  range = self.range_parse
  return name_of_instance_hook(identifier,range)
end

#name_of_memory_hook(identifier) ⇒ Object



3123
3124
3125
# File 'lib/HDLRuby/verilog_parser.rb', line 3123

def name_of_memory_hook(identifier)
  return AST[:name_of_memory, identifier, self.property_hook ]
end

#name_of_memory_parseObject



3117
3118
3119
3120
3121
# File 'lib/HDLRuby/verilog_parser.rb', line 3117

def name_of_memory_parse
  identifier = self._IDENTIFIER_parse
  return nil unless identifier
  return name_of_memory_hook(identifier)
end

#name_of_module_hook(identifier) ⇒ Object



1540
1541
1542
# File 'lib/HDLRuby/verilog_parser.rb', line 1540

def name_of_module_hook(name)
  return AST[:name_of_module, name, self.property_hook ]
end

#name_of_module_parseObject



1534
1535
1536
1537
1538
# File 'lib/HDLRuby/verilog_parser.rb', line 1534

def name_of_module_parse
  name = self._IDENTIFIER_parse
  self.parse_error("module name identifier expected") if !name
  return self.name_of_module_hook(name)
end

#name_of_port_hook(name) ⇒ Object



1796
1797
1798
# File 'lib/HDLRuby/verilog_parser.rb', line 1796

def name_of_port_hook(name)
  return AST[:name_of_port, name, self.property_hook ]
end

#name_of_port_parseObject



1790
1791
1792
1793
1794
# File 'lib/HDLRuby/verilog_parser.rb', line 1790

def name_of_port_parse
  name = self._IDENTIFIER_parse
  self.parse_error("port name identifier expected") if !name
  return self.name_of_port_hook(name)
end

#name_of_register_hook(identifier) ⇒ Object



3107
3108
3109
# File 'lib/HDLRuby/verilog_parser.rb', line 3107

def name_of_register_hook(identifier)
  return AST[:name_of_register, identifier, self.property_hook ]
end

#name_of_register_parseObject



3101
3102
3103
3104
3105
# File 'lib/HDLRuby/verilog_parser.rb', line 3101

def name_of_register_parse
  identifier = self._IDENTIFIER_parse
  return nil unless identifier
  return name_of_register_hook(identifier)
end

#name_of_system_function_hook(identifier) ⇒ Object



6870
6871
6872
# File 'lib/HDLRuby/verilog_parser.rb', line 6870

def name_of_system_function_hook(identifier)
  return AST[:name_of_system_function, identifier, self.property_hook ]
end

#name_of_system_function_parseObject



6861
6862
6863
6864
6865
6866
6867
6868
# File 'lib/HDLRuby/verilog_parser.rb', line 6861

def name_of_system_function_parse
  # *Auth*: the $ is integrated into the system_identifier!!
  tok = self.get_token(SYSTEM_IDENTIFIER_REX)
  if tok then
    return self.name_of_system_function_hook(tok)
  end
  return nil
end

#name_of_system_task_hook(identifier) ⇒ Object



4477
4478
4479
# File 'lib/HDLRuby/verilog_parser.rb', line 4477

def name_of_system_task_hook(identifier)
  return AST[:name_of_system_task, identifier, self.property_hook ]
end

#name_of_system_task_parseObject



4470
4471
4472
4473
4474
4475
# File 'lib/HDLRuby/verilog_parser.rb', line 4470

def name_of_system_task_parse
  # *Auth*: the $ is integrated into the system_identifier!!
  identifier = self.system_identifier_parse
  return nil unless identifier
  return self.name_of_system_task_hook(identifier)
end

#name_of_task_hook(name_of_task) ⇒ Object



2400
2401
2402
# File 'lib/HDLRuby/verilog_parser.rb', line 2400

def name_of_task_hook(name_of_task)
  return AST[:name_of_task, name_of_task, self.property_hook ]
end

#name_of_task_parseObject



2394
2395
2396
2397
2398
# File 'lib/HDLRuby/verilog_parser.rb', line 2394

def name_of_task_parse
  identifier = self._IDENTIFIER_parse
  return nil unless identifier
  return self.name_of_task_hook(identifier)
end

#name_of_udp_hook(identifier) ⇒ Object



1966
1967
1968
# File 'lib/HDLRuby/verilog_parser.rb', line 1966

def name_of_udp_hook(name)
  return AST[:name_of_UDP, name, self.property_hook ]
end

#name_of_udp_instance_hook(identifier, range) ⇒ Object



3553
3554
3555
# File 'lib/HDLRuby/verilog_parser.rb', line 3553

def name_of_udp_instance_hook(identifier,range)
  return AST[:name_of_UDP_instance, identifier,range, self.property_hook ]
end

#name_of_udp_instance_parseObject



3546
3547
3548
3549
3550
3551
# File 'lib/HDLRuby/verilog_parser.rb', line 3546

def name_of_udp_instance_parse
  identifier = self.identifier_parse
  return nil unless identifier
  range = self.range_parse
  return name_of_udp_instance_hook(identifier,range)
end

#name_of_udp_parseObject



1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
# File 'lib/HDLRuby/verilog_parser.rb', line 1954

def name_of_udp_parse
  name = self._IDENTIFIER_parse
  # self.parse_error("name of UDP identifier expected") if !name
  return nil unless name
  if self.module_name?(identifier) then
    # This is a module name, not an UDP one.
    self.state = parse_state
    return nil
  end
  return name_of_udp_hook(name)
end

#name_of_variable_hook(identifier) ⇒ Object



1812
1813
1814
# File 'lib/HDLRuby/verilog_parser.rb', line 1812

def name_of_variable_hook(name)
  return AST[:name_of_variable, name, self.property_hook ]
end

#name_of_variable_parseObject



1806
1807
1808
1809
1810
# File 'lib/HDLRuby/verilog_parser.rb', line 1806

def name_of_variable_parse
  name = self._IDENTIFIER_parse
  self.parse_error("variable name identifier expected") if !name
  return self.name_of_variable_hook(name)
end

#named_port_connection_hook(identifier, expression) ⇒ Object



3807
3808
3809
# File 'lib/HDLRuby/verilog_parser.rb', line 3807

def named_port_connection_hook(identifier, expression)
  return AST[:named_port_connection, identifier,expression, self.property_hook ]
end

#named_port_connection_parseObject



3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
# File 'lib/HDLRuby/verilog_parser.rb', line 3794

def named_port_connection_parse
  unless self.get_token(DOT_REX) then
    return nil
  end
  identifier = self._IDENTIFIER_parse
  self.parse_error("identifier expected") unless identifier
  self.parse_error("opening parenthesis expected") unless self.get_token(OPEN_PAR_REX)
  expression = self.expression_parse
  self.parse_error("expression expected") unless expression
  self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
  return named_port_connection_hook(identifier,expression)
end

#net_declaration_hook(nettype_or_charge_strength, sign, expandrange, delay, list_of_variables_or_list_of_assignments) ⇒ Object



2741
2742
2743
2744
2745
2746
2747
# File 'lib/HDLRuby/verilog_parser.rb', line 2741

def net_declaration_hook(nettype_or_charge_strength, 
                         sign, expandrange, delay,
                         list_of_variables_or_list_of_assignments)
  return AST[:net_declaration, 
             nettype_or_charge_strength,sign,expandrange,delay,
             list_of_variables_or_list_of_assignments, self.property_hook ]
end

#net_declaration_parseObject



2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
# File 'lib/HDLRuby/verilog_parser.rb', line 2704

def net_declaration_parse
  # puts "net_declaration_parse"
  nettype = self._NETTYPE_parse
  if nettype then
    drive_strength = self.drive_strength_parse
    if !drive_strength then
      sign = self.get_token(SIGNED_REX)
      expandrange = self.expandrange_parse
      delay = self.delay_parse
      list_of_variables = self.list_of_variables_parse
      self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
      return net_declaration_hook(nettype,sign,expandrange,delay,
                                  list_of_variables)
    else
      sign = self.get_token(SIGNED_REX)
      expandrange = self.expandrange_parse
      delay = self.delay_parse
      list_of_assignments = self.list_of_assignments_parse
      self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
      return net_declaration_hook(nettype,sign,expandrange,delay,
                                  list_of_assignments)
    end
  else
    unless self.get_token(TRIREG_REX) then
      return nil
    end
    charge_strength = self.charge_strength_parse
    sign = self.get_token(SIGNED_REX)
    expandrange = self.expandrange_parse
    delay = self.delay_parse
    list_of_variables = self.list_of_variables_parse
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    return net_declaration_hook(charge_strength,sign,expandrange,delay,
                                list_of_variables)
  end
end

#next_state_hook(symbol) ⇒ Object



2303
2304
2305
# File 'lib/HDLRuby/verilog_parser.rb', line 2303

def next_state_hook(symbol)
  return AST[:next_state, symbol, self.property_hook ]
end

#next_state_parseObject



2294
2295
2296
2297
2298
2299
2300
2301
# File 'lib/HDLRuby/verilog_parser.rb', line 2294

def next_state_parse
  if self.get_token(HYPHEN_REX) then
    return next_state_hook(HYPHEN_TOK)
  else
    output_symbol = self._OUTPUT_SYMBOL_parse
    return self.next_state_hook(output_symbol)
  end
end

#non_blocking_assignment_hook(lvalue, delay_or_event_control, expression) ⇒ Object



4119
4120
4121
4122
4123
# File 'lib/HDLRuby/verilog_parser.rb', line 4119

def non_blocking_assignment_hook(lvalue, delay_or_event_control,
                             expression)
  return AST[:non_blocking_assignment,
             lvalue,delay_or_event_control,expression, self.property_hook ]
end

#non_blocking_assignment_parseObject



4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
# File 'lib/HDLRuby/verilog_parser.rb', line 4100

def non_blocking_assignment_parse
  parse_state = self.state
  lvalue = self.lvalue_parse
  return nil unless lvalue
  unless self.get_token(ASSIGN_ARROW_REX) then
    self.state = parse_state
    return nil
  end
  delay_or_event_control = self.delay_or_event_control_parse
  expression = self.expression_parse
  unless expression then
    self.state = parse_state
    return nil
  end
  return self.non_blocking_assignment_hook(lvalue,
                                           delay_or_event_control,
                                           expression)
end

#notify_register_hook(identifier) ⇒ Object



5473
5474
5475
# File 'lib/HDLRuby/verilog_parser.rb', line 5473

def notify_register_hook(identifier)
  return AST[:notify_register, identifier, self.property_hook ]
end

#notify_register_parseObject



5467
5468
5469
5470
5471
# File 'lib/HDLRuby/verilog_parser.rb', line 5467

def notify_register_parse
  identifier = self.identifier_parse
  return nil unless identifier
  return self.notify_register_hook(identifier)
end

#number_hook(unsigned_number__decimal_number, base__unsigned_number, decimal_number) ⇒ Object



6582
6583
6584
6585
6586
6587
6588
6589
# File 'lib/HDLRuby/verilog_parser.rb', line 6582

def number_hook(unsigned_number__decimal_number,
                base__unsigned_number,
                decimal_number)
  return AST[:number,
             unsigned_number__decimal_number,
             base__unsigned_number,
             decimal_number, self.property_hook ]
end

#number_parseObject



6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
# File 'lib/HDLRuby/verilog_parser.rb', line 6555

def number_parse
  parse_state = self.state
  unsigned_number = self._UNSIGNED_NUMBER_parse
  base = self._BASE_parse
  if base then
    number = self._NUMBER_parse(base[0])
    self.parse_error("number expected") unless number
    return self.number_hook(unsigned_number,base,number)
  end
  # Not a based number, rewind.
  self.state = parse_state
  decimal_number0 = self._DECIMAL_NUMBER_parse
  return nil unless decimal_number0
  if self.get_token(DOT_REX) then
    unsigned_number = self._UNSIGNED_NUMBER_parse
    if self.get_token(E_REX) then
      decimal_number1 = self._DECIMAL_NUMBER_parse
      self.parse_error("decimal number expected") unless decimal_number1
      return self.number_hook(decimal_number0,unsigned_number,
                              decimal_number1)
    end
    self.parse_error("unsigned number expected") unless unsigned_number
    return self.number_hook(decimal_number0,unsigned_number,nil)
  end
  return self.number_hook(decimal_number0,nil,nil)
end

#origin_rule(name) ⇒ Object

Get an origin rule by +name+.



1358
1359
1360
1361
1362
1363
# File 'lib/HDLRuby/verilog_parser.rb', line 1358

def origin_rule(name)
  name = name.to_sym
  res = ORIGIN_RULES[name]
  res = RULES[name] unless res
  return res
end

#output_declaration_hook(type, sign, range, list_of_variables) ⇒ Object



2651
2652
2653
# File 'lib/HDLRuby/verilog_parser.rb', line 2651

def output_declaration_hook(type, sign, range, list_of_variables)
  return AST[:output_declaration, type,sign,range,list_of_variables, self.property_hook ]
end

#output_declaration_parseObject



2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
# File 'lib/HDLRuby/verilog_parser.rb', line 2636

def output_declaration_parse
  # puts "output_declaration_parse"
  unless self.get_token(OUTPUT_REX) then
    return nil
  end
  type = self.get_token(OUTPUTTYPE_REX)
  sign = self.get_token(SIGNED_REX)
  range = self.range_parse
  list_of_variables = self.list_of_variables_parse
  # list_of_variables = self.list_of_output_variables_parse
  # # Auth: semicolon included in list_of_output_variables!
  self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
  return self.output_declaration_hook(type,sign,range,list_of_variables)
end

#output_identifier_hook(identifier) ⇒ Object



4872
4873
4874
# File 'lib/HDLRuby/verilog_parser.rb', line 4872

def output_identifier_hook(identifier)
  return AST[:output_identifier, identifier, self.property_hook ]
end

#output_identifier_parseObject



4865
4866
4867
4868
4869
4870
# File 'lib/HDLRuby/verilog_parser.rb', line 4865

def output_identifier_parse
  # *Auth*: it should be checked that the identifier comes from
  # an output module. Left the the AST processing.
  identifier = self.identifier_parse
  return self.output_identifier_hook(identifier)
end

#output_port_declaration_hook(type, sign, range, name_of_variable) ⇒ Object



1730
1731
1732
# File 'lib/HDLRuby/verilog_parser.rb', line 1730

def output_port_declaration_hook(type, sign, range, name_of_variable)
  return AST[:output_port_declaration, type,sign,range,name_of_variable, self.property_hook ]
end

#output_port_declaration_parseObject



1720
1721
1722
1723
1724
1725
1726
1727
1728
# File 'lib/HDLRuby/verilog_parser.rb', line 1720

def output_port_declaration_parse
  return nil unless self.get_token(OUTPUT_REX)
  type = self.get_token(OUTPUTTYPE_REX)
  sign = self.get_token(SIGNED_REX)
  range = self.range_parse
  name_of_variable = self.name_of_variable_parse
  self.parse_error("identifier expected") unless name_of_variable
  return output_port_declaration_hook(type,sign,range,name_of_variable)
end

#output_terminal_name_hook(name_of_variable) ⇒ Object



2052
2053
2054
2055
2056
2057
2058
# File 'lib/HDLRuby/verilog_parser.rb', line 2052

def output_terminal_name_hook(name_of_variable)
  if self.state.compress then
    return name_of_variable
  else
    return AST[:output_terminal_name, name_of_variable, self.property_hook]
  end
end

#output_terminal_name_parseObject



2046
2047
2048
2049
2050
# File 'lib/HDLRuby/verilog_parser.rb', line 2046

def output_terminal_name_parse
  name_of_variable = self.name_of_variable_parse
  return nil unless name_of_variable
  return self.output_terminal_name_hook(name_of_variable)
end

#par_block_hook(statements__name_of_block, block_declarations, statements) ⇒ Object



4298
4299
4300
4301
4302
# File 'lib/HDLRuby/verilog_parser.rb', line 4298

def par_block_hook(statements__name_of_block,
                   block_declarations, statements)
  return AST[:name_of_block, statements__name_of_block,
             block_declarations,statements, self.property_hook ]
end

#par_block_parseObject



4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
# File 'lib/HDLRuby/verilog_parser.rb', line 4261

def par_block_parse
  unless self.get_token(FORK_REX) then
    return nil
  end
  if self.get_token(COLON_REX) then
    name_of_block = self.name_of_block_parse
    self.parse_error("block name expected") unless name_of_block
    block_declarations = [ ]
    cur_block_declaration = nil
    loop do
      cur_block_declaration = self.block_declaration_parse
      break unless cur_block_declaration
      block_declarations << cur_block_declaration
    end
    statements = []
    cur_statement = nil
    loop do
      cur_statement = self.statement_parse
      break unless cur_statement
      statements << cur_statement
    end
    self.parse_error("'join' expected") unless self.get_token(JOIN_REX)
    return self.par_block_hook(name_of_block,block_declarations,
                               statements)
  else
    statements = []
    cur_statement = nil
    loop do
      cur_statement = self.statement_parse
      break unless cur_statement
      statements << cur_statement
    end
    self.parse_error("'join' expected") unless self.get_token(JOIN_REX)
    return self.par_block_hook(statements,nil,nil)
  end
end

#param_assignment_hook(identifier, constant_expression) ⇒ Object



2584
2585
2586
# File 'lib/HDLRuby/verilog_parser.rb', line 2584

def param_assignment_hook(identifier, constant_expression)
  return AST[:param_assignment, identifier,constant_expression, self.property_hook ]
end

#param_assignment_parseObject



2577
2578
2579
2580
2581
2582
# File 'lib/HDLRuby/verilog_parser.rb', line 2577

def param_assignment_parse
  identifier = self.identifier_parse
  self.parse_error("equal expected") unless self.get_token(EQUAL_REX)
  constant_expression = self.constant_expression_parse
  return self.param_assignment_hook(identifier,constant_expression)
end

#parameter_declaration_hook(list_of_param_assignments) ⇒ Object



2544
2545
2546
# File 'lib/HDLRuby/verilog_parser.rb', line 2544

def parameter_declaration_hook(list_of_param_assignments)
  return AST[:parameter_declaration, list_of_param_assignments, self.property_hook ]
end

#parameter_declaration_parseObject



2534
2535
2536
2537
2538
2539
2540
2541
2542
# File 'lib/HDLRuby/verilog_parser.rb', line 2534

def parameter_declaration_parse
  # puts "parameter_declaration_parse"
  unless self.get_token(PARAMETER_REX) then
    return nil
  end
  list_of_param_assignments = self.list_of_param_assignments_parse
  self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
  return self.parameter_declaration_hook(list_of_param_assignments)
end

#parameter_override_hook(list_of_param_assignments) ⇒ Object



2995
2996
2997
# File 'lib/HDLRuby/verilog_parser.rb', line 2995

def parameter_override_hook(list_of_param_assignments)
  return AST[:parameter_override, list_of_param_assignments, self.property_hook ]
end

#parameter_override_parseObject



2986
2987
2988
2989
2990
2991
2992
2993
# File 'lib/HDLRuby/verilog_parser.rb', line 2986

def parameter_override_parse
  unless self.get_token(DEFPARAM_REX) then
    return nil
  end
  list_of_param_assignments = self.list_of_param_assignments_parse
  self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
  return parameter_override_hook(list_of_param_assignments)
end

#parameter_value_assignment_hook(expressions) ⇒ Object



3670
3671
3672
# File 'lib/HDLRuby/verilog_parser.rb', line 3670

def parameter_value_assignment_hook(expressions)
  return AST[:parameter_value_assignment, expressions, self.property_hook ]
end

#parameter_value_assignment_parseObject



3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
# File 'lib/HDLRuby/verilog_parser.rb', line 3650

def parameter_value_assignment_parse
  unless self.get_token(SHARP_REX) then
    return nil
  end
  self.parse_error("opening parenthesis expected") unless self.get_token(OPEN_PAR_REX)
  cur_expression = self.expression_parse
  self.parse_error("expression expected") unless cur_expression
  expressions = [ cur_expression ]
  loop do
    unless self.get_token(COMMA_REX) then
      break
    end
    cur_expression = self.expression_parse
    self.parse_error("expression expected") unless cur_expression
    expressions << cur_expression
  end
  self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
  return parameter_value_assignment_hook(expressions)
end

#parseObject

Parse the Verilog HDL text. NOTE: does not support compiler directives, they must be preprocessed first using preprocess method.



537
538
539
540
541
542
543
544
545
546
547
548
# File 'lib/HDLRuby/verilog_parser.rb', line 537

def parse
  # Initialize the state.
  @state.index = 0
  @state.lpos = 1
  @state.cpos = 1
  # Initialize the list of known module names.
  @module_names = []
  # Initialize the list of known UDP names.
  @udp_names = []
  # Execute the parsing.
  return self.source_text_parse
end

#parse_error(msg, line_txt = nil, lpos = @state.lpos, cpos = @state.cpos, filename = ) ⇒ Object

Generate a parse error with message indicated by +msg+ and possible line text +line_text+, line number +lpos+, column +cpos+ and origin file name +filename+.

Raises:



636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
# File 'lib/HDLRuby/verilog_parser.rb', line 636

def parse_error(msg, line_txt=nil, lpos=@state.lpos, cpos=@state.cpos,
                filename=@state.lprop[lpos][:filename])
  # Maybe it was the main file.
  filename = @state.filename unless filename
  # Get the line where the error was.
  # First locate the position of the begining and the end of the line.
  # puts "lpos=#{lpos} line_txt=#{line_txt.class}"
  unless line_txt then
    blpos = @state.index-@state.cpos
    elpos = @state.index + 
      @state.text.match(/[^\n]*/,@state.index).to_s.size
    # Address the case of invalid end of line (e.g., semicolon missing)
    if elpos == blpos then
      count = 1
      while(@state.text[@state.index-count] =~ /[^\n]/) do
        count += 1
      end
      cpos = count-1
      blpos = elpos-count+1
    end
    # The get the line.
    line_txt = @state.text[blpos...elpos]
  end
  # Raise an exception containing an error message made of msg,
  # the adjusted line number, its number, and the column where error
  # happended.
  raise ParseError.new(msg,line_txt,@state.lprop[lpos][:lpos],cpos,
                      filename)
end

#path_declaration_hook(path_description, path_delay_value) ⇒ Object



4656
4657
4658
# File 'lib/HDLRuby/verilog_parser.rb', line 4656

def path_declaration_hook(path_description, path_delay_value)
  return AST[:path_declaration, path_description,path_delay_value, self.property_hook ]
end

#path_declaration_parseObject



4646
4647
4648
4649
4650
4651
4652
4653
4654
# File 'lib/HDLRuby/verilog_parser.rb', line 4646

def path_declaration_parse
  path_description = self.path_description_parse
  return nil unless path_description
  self.parse_error("equal expected") unless self.get_token(EQUAL_REX)
  path_delay_value = self.path_delay_value_parse
  self.parse_error("path delay value expected") unless path_delay_value
  self.parse_error("semicolon expected") unless self.get_toekn == SEMICOLON_TOK
  return self.path_declaration_hook(path_description,path_delay_value)
end

#path_delay_expression_hook(mintypmax_expression) ⇒ Object



4964
4965
4966
4967
4968
4969
4970
# File 'lib/HDLRuby/verilog_parser.rb', line 4964

def path_delay_expression_hook(mintypmax_expression)
  if self.state.compress then
    return mintypmax_expression
  else
    return AST[:path_delay_expression, mintypmax_expression, self.property_hook ]
  end
end

#path_delay_expression_parseObject



4958
4959
4960
4961
4962
# File 'lib/HDLRuby/verilog_parser.rb', line 4958

def path_delay_expression_parse
  mintypmax_expression = self.mintypmax_expression_parse
  return nil unless mintypmax_expression
  return path_delay_expression_hook(mintypmax_expression)
end

#path_delay_value_hook(path_delay_expression0, path_delay_expression1, path_delay_expression2, path_delay_expression3, path_delay_expression4, path_delay_expression5, path_delay_expression6, path_delay_expression7, path_delay_expression8, path_delay_expression9, path_delay_expression10, path_delay_expression11) ⇒ Object



4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
# File 'lib/HDLRuby/verilog_parser.rb', line 4925

def path_delay_value_hook(path_delay_expression0,
                          path_delay_expression1,
                          path_delay_expression2,
                          path_delay_expression3,
                          path_delay_expression4,
                          path_delay_expression5,
                          path_delay_expression6,
                          path_delay_expression7,
                          path_delay_expression8,
                          path_delay_expression9,
                          path_delay_expression10,
                          path_delay_expression11)
  return AST[:path_delay_value, 
             path_delay_expression0,
             path_delay_expression1,
             path_delay_expression2,
             path_delay_expression3,
             path_delay_expression4,
             path_delay_expression5,
             path_delay_expression6,
             path_delay_expression7,
             path_delay_expression8,
             path_delay_expression9,
             path_delay_expression10,
             path_delay_expression11, self.property_hook ]
end

#path_delay_value_parseObject



4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
# File 'lib/HDLRuby/verilog_parser.rb', line 4894

def path_delay_value_parse
  parse_state = self.state
  if self.get_token(OPEN_PAR_REX) then
    cur_path_delay_expression = self.path_delay_expression_parse
    unless cur_path_delay_expression then
      self.state = parse_state
      return nil
    end
    path_delay_expressions = [ cur_path_delay_expression ]
    tok = nil
    11.times do
      break unless self.get_token(COMMA_REX)
      cur_path_delay_expression = self.path_delay_expression_parse
      self.parse_error("path delay expression expected") unless cur_path_delay_expression
      path_delay_expressions << cur_path_delay_expression
    end
    self.parse_error("closing parenthesis expected") unless tok == CLOSE_PAR_TOK
    # Ensure there are 12 elements in the path_delay_expressions
    if path_delay_expressions.size < 12 then
      path_delay_expressions[11] = nil
    end
    return self.path_delay_value_hook(*path_delay_expressions)
  else
    path_delay_expression = self.path_delay_expression_parse
    return nil unless path_delay_expression
    return self.path_delay_value_hook(path_delay_expression,
                                     nil,nil,nil,nil,nil,nil,
                                     nil,nil,nil,nil,nil)
  end
end

#path_description_hook(type, input, output) ⇒ Object



4700
4701
4702
# File 'lib/HDLRuby/verilog_parser.rb', line 4700

def path_description_hook(type, input, output)
  return AST[:path_description, type,input,output, self.property_hook ]
end

#path_description_parseObject



4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
# File 'lib/HDLRuby/verilog_parser.rb', line 4667

def path_description_parse
  parse_state = self.state
  unless self.get_token(OPEN_PAR_REX) then
    self.state = parse_state
    return nil
  end
  specify_input_terminal_descriptor =
    self.specify_input_terminal_descriptor_parse
  if self.get_token(SEND_ARROW_REX) and 
      specify_input_terminal_descriptor then
    specify_output_terminal_descriptor =
      self.specify_output_terminal_descriptor_parse
    self.parse_error("output terminal descriptor expected") unless specify_output_terminal_descriptor
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    return self.path_description_hook(SEND_ARROW_TOK,
                                 specify_input_terminal_descriptor,
                                 specify_output_terminal_descriptor)
  end
  list_of_path_inputs = self.list_of_path_inputs_parse
  unless list_of_path_inputs then
    self.state = parse_state
    return nil
  end
  unless self.get_token(ASTERISK_ARROW_REX) then
    self.state = parse_state
  end
  list_of_path_outputs = self.list_of_path_outputs_parse
  self.parse_error("list of path outputs expected") unless list_of_path_outputs
  return self.path_description_hook(ASTERIS_ARROW_TOK,
                                    list_of_path_inputs,
                                    list_of_path_outputs)
end

#peek_token(rex) ⇒ Object

Check the token matching regexp +rex+ from current position. Returns the match in case of success and nil otherwise but do not change the state of the parser.



566
567
568
# File 'lib/HDLRuby/verilog_parser.rb', line 566

def peek_token(rex)
  return @state.text.match(rex,@state.index)
end

#polarity_operator_hook(tok) ⇒ Object



5603
5604
5605
# File 'lib/HDLRuby/verilog_parser.rb', line 5603

def polarity_operator_hook(tok)
  return AST[:polarity_operator, tok, self.property_hook ]
end

#polarity_operator_parseObject



5594
5595
5596
5597
5598
5599
5600
5601
# File 'lib/HDLRuby/verilog_parser.rb', line 5594

def polarity_operator_parse
  tok = self.get_token(POLARITY_OPERATOR_REX)
  if tok then
    return polarity_operator_hook(tok)
  else
    return nil
  end
end

#port_expression_hook(port_declaration__port_refs) ⇒ Object



1687
1688
1689
# File 'lib/HDLRuby/verilog_parser.rb', line 1687

def port_expression_hook(port_declaration__port_refs)
  return AST[:port_expression, port_declaration__port_refs, self.property_hook ]
end

#port_expression_parseObject



1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
# File 'lib/HDLRuby/verilog_parser.rb', line 1641

def port_expression_parse
  input_port_declaration = self.input_port_declaration_parse
  if input_port_declaration then
    return port_expression_hook(input_port_declaration)
  end
  output_port_declaration = self.output_port_declaration_parse
  if output_port_declaration then
    return port_expression_hook(output_port_declaration)
  end
  inout_port_declaration = self.inout_port_declaration_parse
  if inout_port_declaration then
    return port_expression_hook(inout_port_declaration)
  end

  parse_state = self.state
  port_refs = [ ]
  cur_port_ref = self.port_reference_parse
  if cur_port_ref then
    port_refs << cur_port_ref
  else
    unless self.get_token(OPEN_CUR_REX) then
      self.state = parse_state
      return nil
    end
    port_refs << cur_port_ref
    cur_port_ref = self.port_reference_parse
    if !cur_port_ref then
      self.state = parse_state
      return nil
    end
    loop do
      if self.get_token(COMMMA_REX) then
        cur_port_ref = self.port_reference_parse
      end
      if self.get_token(CLOSE_CUR_REX) then
        cur_port_ref = nil
      else
        self.parse_error("comma or closing parenthesis expected")
      end
      break unless cur_port_ref
      port_refs << cur_port_ref
    end
  end
  return self.port_expression_hook(port_refs)
end

#port_hook(port_expression__name_of_port, port_expression) ⇒ Object



1601
1602
1603
# File 'lib/HDLRuby/verilog_parser.rb', line 1601

def port_hook(port_expression__name_of_port, port_expression)
  return AST[:port, port_expression__name_of_port,port_expression, self.property_hook ]
end

#port_parseObject



1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
# File 'lib/HDLRuby/verilog_parser.rb', line 1584

def port_parse
  port_expression = self.port_expression_parse
  if port_expression then
    return self.port_hook(port_expression,nil)
  end
  unless self.get_token(DOT_REX) then
    return nil
  end
  name_of_port = self.name_of_port_parse
  self.parse_error("name of port expected") unless name_of_port
  self.parse_error("opening parenthesis expected") unless self.get_token(OPEN_PAR_REX)
  port_expression = self.port_expression_parse
  self.parse_error("port expression expected") unless port_expression
  self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
  return self.port_hook(name_of_port,port_expression)
end

#port_reference_hook(name, const0, const1) ⇒ Object



1780
1781
1782
# File 'lib/HDLRuby/verilog_parser.rb', line 1780

def port_reference_hook(name,const0,const1)
  return AST[:port_reference, name,const0,const1, self.property_hook ]
end

#port_reference_parseObject



1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
# File 'lib/HDLRuby/verilog_parser.rb', line 1765

def port_reference_parse
  name = self.name_of_variable_parse
  const0, const1 = nil, nil
  if self.get_token(OPEN_BRA_REX) then
    const0 = self.constant_expression_prase
    self.parse_error("constant expression expected") unless const0
    if self.get_token(COLON_REX) then
      const1 = self.constant_expression_parse
      self.parse_error("constant expression expected") unless const1
    end
    self.parse_error("closing bracket expected") unless self.get_token(CLOSE_BRA_REX)
  end
  return self.port_reference_hook(name,const0,const1)
end

#pre_parameter_declaration_hook(list_of_param_assignments) ⇒ Object



1523
1524
1525
# File 'lib/HDLRuby/verilog_parser.rb', line 1523

def pre_parameter_declaration_hook(list_of_param_assignments)
  return AST[:pre_parameter_declaration, list_of_param_assignments, self.property_hook ]
end

#pre_parameter_declaration_parseObject



1513
1514
1515
1516
1517
1518
1519
1520
1521
# File 'lib/HDLRuby/verilog_parser.rb', line 1513

def pre_parameter_declaration_parse
  return nil unless self.get_token(SHARP_REX)
  self.parse_error("opening parenthesis expected") unless self.get_token(OPEN_PAR_REX)
  self.parse_error("parameter expected") unless self.get_token(PARAMETER_REX)
  list_of_param_assignments = self.list_of_param_assignments_parse
  self.parse_error("paramter assignment expected") unless list_of_param_assignments
  self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
  return pre_parameter_declaration_hook(list_of_param_assignments)
end

#preprocessObject

Preprocess the Verilog HDL text with directives.



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
# File 'lib/HDLRuby/verilog_parser.rb', line 213

def preprocess
  # Initialize the preprocessing variables.
  macro_cons = {}    # The set of macro constants.
  macro_func = {}    # The set of macro functions.
  lpos = 1           # Current line number in text.
  cur_timescale = "" # The Current time scale
  # The initial text becomes the text to preprocesses whereas
  # the text to parse is cleared.
  pre_text = @state.text
  @state.text = ""
  # Initialize the line jump (1 if no line merge).
  ljump = 1
  # Initialize the lines properties.
  # @state.lprop = [ { lpos: 0, timescale: "", celldefine: "" }]
  @state.lprop = [ { lpos: 0 }]
  # Initialize the line skip mode for handling the `ifdef and `ifndef
  # directives.
  skip_mode = [ [:start, false] ]
  # Preprocessing is grammatically straight foward, so use
  # a StringScanner.
  scanner = StringScanner.new(pre_text)
  while(!scanner.eos?) do
    # Set the default propery of the line if none.
    if !@state.lprop[lpos] then
      @state.lprop[lpos] = @state.lprop[lpos-1].clone
      # But not the freeze state.
      @state.lprop[lpos].delete(:lfreeze)
      @state.lprop[lpos][:lpos] = @state.lprop[lpos-1][:lpos] + 1
    else
      # Still need to update the timescale and celldefine properties.
      @state.lprop[lpos][:timescale] = @state.lprop[lpos-1][:timescale]
      @state.lprop[lpos][:celldefine] = @state.lprop[lpos-1][:celldefine]
    end
    # Set the default filename if none.
    unless @state.lprop[lpos][:filename] then
      @state.lprop[lpos][:filename] = @state.filename
    end
    # puts "lpos=#{lpos} @state.lprop[lpos]=#{@state.lprop[lpos]}"
    # Is it a directive line?
    begin
      line = scanner.scan(/[ \t]*`[^\n]*\n/)
    rescue => error
      # Problem in the text, so fix it first.
      estr = scanner.string.scrub("\uFFFD")
      # And locate the error.
      elpos = 1
      ecpos = nil
      eline = nil
      estr.lines do |line|
        elpos = elpos + 1
        unless @state.lprop[elpos] then
          if elpos > 1 then
            @state.lprop[elpos] = @state.lprop[elpos-1]
          else
            @state.lprop[elpos] = { :lpos => 1, 
                                    :filename => @state.filename }
          end
          @state.lprop[elpos][:lpos] += 1
        end
        eline = line
        ecpos = line.index("\uFFFD")
        break if ecpos
      end
      if ecpos then
        # It was an invalid, non-UTF8, character.
        self.parse_error("non UTF-8 character",
                         eline.chomp,elpos,ecpos)
      else
        # It was another kind of error.
        self.file_error(error,@state.lprop[lpos][:lpos])
      end
    end
    if line then
      # Yes, process it.
      # But, first, are there any line merge?
      line,jump = self.process_merge_line(line,scanner,lpos)
      # Get the kind of macro and its arguments.
      type,code = line.scan(/^\s*`[a-zA-Z]+|[^`]*$/)
      type.gsub!(/\s/,"")
      # Add the skip mode: X at the end if skipped.
      type += "X" if skip_mode[-1][1]
      # Depending of the kind of macro.
      case type
      when "`timescaleX" # Skip
      when "`timescale"
        # Process and check to code.
        code = code.gsub(/\s/,"")
        mcode = code.match(/^([0-9]+)(s|ms|us|ns|ps|fs)\/([0-9]+)(s|ms|us|ns|ps|fs)/)
        # Compute the position of the code, used in case of error.
        cpos = line.scan(/\s*`timescale\s*/)[0].size
        unless mcode then
          self.parse_error("invalid timescale format",
                           line.chomp,lpos,cpos)
        end
        unit = mcode.captures[0].to_i * FS_TIME[mcode.captures[1]]
        prec = mcode.captures[2].to_i * FS_TIME[mcode.captures[3]]
        unless unit > prec then
          self.parse_error(
            "in timescale, unit shoud be greater than precision",
                           line.chomp,lpos,cpos)
        end
        # puts "unit=#{unit} precision=#{prec}"
        # @state.lprop[lpos][:timescale] = AST[:timescale, unit, prec ]
        @state.lprop[lpos][:timescale] = [ unit, prec ]
      when "`celldefineX" # Skip
      when "`celldefine"
        # @state.lprop[lpos][:celldefine] = AST[:celldefine]
        @state.lprop[lpos][:celldefine] = true
      when "`endcelldefineX" # Skip
      when "`endcelldefine"
        @state.lprop[lpos][:celldefine] = false
      when "`defineX" # Skip
      when "`define"
        # Get the macro name, arguments and replacement.
        name,args,replace = 
          code.scan(/^\s*[_a-zA-Z][_a-zA-Z0-9]*|\(.*\)|.*$/)
        # Process the name.
        unless name =~ /^\s*[_a-zA-Z][_a-zA-Z0-9]*/ then
          cpos = line.scan(/\s*`define\s*/)[0].size
          self.parse_error("invalid macro name",line.chomp,lpos,cpos)
        end
        name.gsub!(/\s/,"")
        # Process the arguments if any.
        if args[0] == "(" then
          # There are indeed arguments, it is a macro function.
          args = args.split(/[\(\),]/).reject { |arg| arg.empty? }
          # Process the arguments.
          cpos = line.index("(")
          args.map! do |arg|
            cpos += 1
            unless arg =~ /^\s*[_a-zA-Z][_a-zA-Z0-9]*\s*$/ then
              self.parse_error("invalid macro argument",
                               line.chomp,lpos,cpos)
            end
            cpos += arg.size
            /#{arg.gsub(/\s/,"")}(?=[^_a-zA-Z0-9])/
          end
          # Add the macro function.
          macro_func[name] = [ /`#{name}\([^\(]*\)/, args, replace ]
          # Remove the macro constant if any to avoid conflict.
          macro_cons.delete(name)
        else
          # There are no arguments, it is a macro constant.
          macro_cons[name] = [ /`#{name}(?=[^_a-zA-Z0-9])/, args ]
          # Remove the macro function if any to avoid conflict.
          macro_func.delete(name)
        end
      when "`undefX" # Skip
      when "`undef"
        # Get the macro name, arguments and replacement.
        name = code.scan(/^\s*[_a-zA-Z][_a-zA-Z0-9]*\s*$/)[0]
        # Process the name.
        name.gsub!(/\s/,"")
        # Remove the macro.
        macro_cons.delete(name)
        macro_func.delete(name)
      when "`ifdefX" # Skip
      when "`ifdef"
        # Get the macro name, arguments and replacement.
        name = code.scan(/^\s*[_a-zA-Z][_a-zA-Z0-9]*\s*$/)[0]
        unless name =~ /^\s*[_a-zA-Z][_a-zA-Z0-9]*/ then
          cpos = line.scan(/\s*`ifdef\s*/)[0].size
          self.parse_error("invalid macro name",line.chomp,lpos,cpos)
        end
        # Process the name.
        name.gsub!(/\s/,"")
        # Set the the skip mode on if there is no such macro.
        if macro_cons.key?(name) or macro_func.key?(name)
          skip_mode << [ :ifdef, false ]
        else
          skip_mode << [ :ifdef, true ]
        end
      when "`ifndefX" # Skip
      when "`ifndef"
        # Get the macro name, arguments and replacement.
        name = code.scan(/^\s*[_a-zA-Z][_a-zA-Z0-9]*\s*$/)[0]
        unless name =~ /^\s*[_a-zA-Z][_a-zA-Z0-9]*/ then
          cpos = line.scan(/\s*`ifndef\s*/)[0].size
          self.parse_error("invalid macro name",line.chomp,lpos,cpos)
        end
        # Process the name.
        name.gsub!(/\s/,"")
        # Set the the skip mode on if there is such macro.
        if macro_cons.key?(name) or macro_func.key?(name)
          skip_mode << [ :ifndef, true ]
        else
          skip_mode << [ :ifndef, false ]
        end
      when "`else", "`elseX"
        # Invert the last skip mode if any, otherwise, error.
        if skip_mode.size < 2 then
          self.parse_error("misplaced `else directive",
                               line.chomp,lpos,0)
        end
        skip_mode[-1] = [:else, !skip_mode[-1][1] ]
      when "`elsif", "`elsifX"
        # Get the macro name, arguments and replacement.
        name = code.scan(/^\s*[_a-zA-Z][_a-zA-Z0-9]*\s*$/)[0]
        unless name =~ /^\s*[_a-zA-Z][_a-zA-Z0-9]*/ then
          cpos = line.scan(/\s*`elsifX?\s*/)[0].size
          self.parse_error("invalid macro name",line.chomp,lpos,cpos)
        end
        # Process the name.
        name.gsub!(/\s/,"")
        # Depending of the skip mode.
        if (skip_mode[-1][0]==:ifdef or skip_mode[-1][0]==:ifndef) and
            skip_mode[-1][1] then
          # Set the the skip mode on if there is such macro.
          if macro_cons.key?(name) or macro_func.key?(name)
            # This is an elsif so replace the last skip mode.
            skip_mode[-1] = [ :ifdef, false ]
          else
            # This is an elsif so replace the last skip mode.
            skip_mode[-1] [ :ifdef, true ]
          end
        else
          self.parse_error("misplaced `elsif directive",
                               line.chomp,lpos,0)
        end
      when "`endif", "`endifX"
        # Remove the last skip mode if any, otherwise, error.
        if skip_mode.size < 2 then
          self.parse_error("misplaced `endif directive",
                               line.chomp,lpos,0)
        end
        skip_mode.pop
      when "`includeX"
      when "`include"
        # Get the file name to include.
        filename = code.scan(/^\s*"[^\\"]*"\s*$/)[0]
        filename.gsub!(/^\s*/,"")
        filename.gsub!(/"\s*$/,"\"")
        filename = filename[1..-2]
        # Reads the file.
        included_text = ""
        begin
          included_text = File.read(@state.path + filename)
        rescue => error
          self.file_error(error,lpos+ljump)
        end
        # Insert it in pre_text and not in final text so that it
        # is processed again, and setup again the scanner.
        new_pos = scanner.pos-line.size+1
        pre_text = pre_text[0...new_pos] + 
                   included_text + 
                   pre_text[scanner.pos..-1]
        scanner = StringScanner.new(pre_text)
        scanner.pos = new_pos
        # Also update the line numbering and file reference.
        included_jump = included_text.lines.count
        # puts "included_jump=#{included_jump} ljump=#{ljump}"
        idx = 0
        included_jump.times do |i|
          idx = lpos+i+ljump-1
          @state.lprop[idx] = @state.lprop[idx-1].clone
          # i-1 to compenstate the later line increase.
          @state.lprop[idx][:lpos] = i-1
          @state.lprop[idx][:filename] = @state.path + filename
        end
        # puts "lpos=#{lpos} @state.lprop[lpos]=#{@state.lprop[lpos]}"
        next_lpos = lpos+included_jump
        @state.lprop[next_lpos] = @state.lprop[lpos-1].clone
        @state.lprop[next_lpos][:lpos] += ljump
        @state.lprop[next_lpos][:lfreeze] = true
      when "`resetallX" # Skip
      when "`resetall"
        # Clears the macro.
        # Auth: that what it should do right?
        macro_cons.clear
        macro_func.clear
      else
        cpos = line.index("`")
        self.parse_error("unknown directive",line.chomp,lpos,cpos)
      end
      # And add an empty line instead to the final text.
      @state.text << "\n"
    else
      # No, get it as a normal line.
      line = scanner.scan(/[^\n]*\n/)
      # But, first, are there any line merge?
      line,ljump = self.process_merge_line(line,scanner,lpos)
      # Shall we skip?
      if skip_mode[-1][1] then
        # Yes, the line is empty.
        line = "\n"
      else
        # Also, this time, there will be some line position adjustment.
        # And apply the known macros.
        macro_cons.each_value do |rex,replace|
          line.gsub!(rex,replace)
        end
        macro_func.each_value do |rex,formal_args,replace|
          # Extract all the macro function call
          macro_calls = line.scan(rex)
          # Process them to replacements.
          macro_calls.each do |mc|
            real_args = mc.split(/[\(\),]/)[1..-1]
            # puts "real_args=#{real_args} formal_args=#{formal_args}"
            formal_args.each_with_index do |formal_arg,i|
              replace = replace.gsub(formal_arg,real_args[i])
            end
            line.sub!(mc,replace)
          end
        end
      end
      # Write the line to the final text.
      @state.text << line
    end
    # Next line.
    lpos += ljump
  end
  # Are all the `ifdef and `ifndef directive closed?
  if skip_mode.size > 1 then
    # No, error.
    self.parse_error("`endif directive missing",line.chomp,lpos,0)
  end
  # puts "Result: #{@state.text}"
  # puts "lprops=#{@state.lprop.join("\n")}"
end

#primary_hook(base, expression__constant_expression, constant_expression) ⇒ Object



6517
6518
6519
6520
6521
6522
6523
# File 'lib/HDLRuby/verilog_parser.rb', line 6517

def primary_hook(base,
                 expression__constant_expression,
                 constant_expression)
  return AST[:primary,
             base, expression__constant_expression,
             constant_expression, self.property_hook ]
end

#primary_parseObject



6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
# File 'lib/HDLRuby/verilog_parser.rb', line 6470

def primary_parse
  number = self.number_parse
  if number then
    return self.primary_hook(number,nil,nil)
  end
  multiple_concatenation = self.multiple_concatenation_parse
  if multiple_concatenation then
    return self.primary_hook(multiple_concatenation,nil,nil)
  end
  concatenation = self.concatenation_parse
  if concatenation then
    return self.primary_hook(concatenation,nil,nil)
  end
  function_call = self.function_call_parse
  if function_call then
    return self.primary_hook(function_call,nil,nil)
  end
  if self.get_token(OPEN_PAR_REX) then
    mintypmax_expression = self.mintypmax_expression_parse
    if !mintypmax_expression then
      return nil
    end
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    return self.primary_hook(mintypmax_expression,nil,nil)
  end
  identifier = self.identifier_parse
  return nil unless identifier
  unless self.get_token(OPEN_BRA_REX) then
    return self.primary_hook(identifier,nil,nil)
  end
  parse_state = self.state
  constant_expression0 = self.constant_expression_parse
  if !constant_expression0 or !self.get_token(COLON_REX) then
    # Not constant_expression : constant_expression, rewind
    self.state = parse_state
    expression = self.expression_parse
    self.parse_error("expression expected") unless expression
    self.parse_error("closing bracket expected") unless self.get_token(CLOSE_BRA_REX)
    return self.primary_hook(identifier,expression,nil)
  end
  constant_expression1 = self.constant_expression_parse
  self.parse_error("constant expression expected") unless constant_expression1
  self.parse_error("closing bracket expected") unless self.get_token(CLOSE_BRA_REX)
  return self.primary_hook(identifier,
                           constant_expression0,constant_expression1)
end

#property_hookObject

Hook for the properties of the current line. (No syntax rule required).



1388
1389
1390
# File 'lib/HDLRuby/verilog_parser.rb', line 1388

def property_hook
  return AST[:property, @state.lprop[@state.lpos].select {|k,v| v} ]
end

#range_hook(constant_expression0, constant_expression1) ⇒ Object



3264
3265
3266
# File 'lib/HDLRuby/verilog_parser.rb', line 3264

def range_hook(constant_expression0, constant_expression1)
  return AST[:range, constant_expression0,constant_expression1, self.property_hook ]
end

#range_or_type_hook(range_or_type) ⇒ Object



2460
2461
2462
2463
2464
2465
2466
# File 'lib/HDLRuby/verilog_parser.rb', line 2460

def range_or_type_hook(range_or_type)
  if self.state.compress then
    return range_or_type
  else
    return AST[:range_or_type, range_or_type, self.property_hook ]
  end
end

#range_or_type_parseObject



2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
# File 'lib/HDLRuby/verilog_parser.rb', line 2449

def range_or_type_parse
  tok = self.get_token(INTEGER_REAL_REX)
  if tok then
    return self.range_or_type_hook(tok)
  else
    range = self.range_parse
    return nil unless range
    return self.range_or_type_hook(range)
  end
end

#range_parseObject



3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
# File 'lib/HDLRuby/verilog_parser.rb', line 3250

def range_parse
  parse_state = self.state
  return nil unless self.get_token(OPEN_BRA_REX)
  constant_expression0 = self.constant_expression_parse
  if !constant_expression0 or !self.get_token(COLON_REX) then
    self.state = parse_state
    return nil
  end
  constant_expression1 = self.constant_expression_parse
  self.parse_error("constant expression expected") unless constant_expression1
  self.parse_error unless self.get_token(CLOSE_BRA_REX)
  return range_hook(constant_expression0,constant_expression1)
end

#real_declaration_hook(list_of_register_variables) ⇒ Object



2911
2912
2913
# File 'lib/HDLRuby/verilog_parser.rb', line 2911

def real_declaration_hook(list_of_register_variables)
  return AST[:real_declaration, list_of_register_variables, self.property_hook ]
end

#real_declaration_parseObject



2901
2902
2903
2904
2905
2906
2907
2908
2909
# File 'lib/HDLRuby/verilog_parser.rb', line 2901

def real_declaration_parse
  # puts "real_declaration_parse"
  unless self.get_token(REAL_REX) then
    return nil
  end
  list_of_register_variables = self.list_of_register_variables_parse
  self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
  return real_declaration_hook(list_of_register_variables)
end

#reg_declaration_hook(sign, range, list_of_register_variables) ⇒ Object



2851
2852
2853
# File 'lib/HDLRuby/verilog_parser.rb', line 2851

def reg_declaration_hook(sign, range, list_of_register_variables)
  return AST[:reg_declaration, sign,range,list_of_register_variables, self.property_hook ]
end

#reg_declaration_parseObject



2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
# File 'lib/HDLRuby/verilog_parser.rb', line 2839

def reg_declaration_parse
  # puts "reg_declaration_parse"
  unless self.get_token(REG_REX) then
    return nil
  end
  sign = self.get_token(SIGNED_REX)
  range = self.range_parse
  list_of_register_variables = self.list_of_register_variables_parse
  self.parse_error("semicolon exptected") unless self.get_token(SEMICOLON_REX)
  return reg_declaration_hook(sign,range,list_of_register_variables)
end

#register_variable_hook(name, constant_expression1, constant_expression2) ⇒ Object



3088
3089
3090
3091
3092
3093
# File 'lib/HDLRuby/verilog_parser.rb', line 3088

def register_variable_hook(name, 
                           constant_expression1,
                           constant_expression2)
  return AST[:register_variable, 
             name, constant_expression1, constant_expression2, self.property_hook ]
end

#register_variable_parseObject



3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
# File 'lib/HDLRuby/verilog_parser.rb', line 3068

def register_variable_parse
  parse_state = self.state
  name_of_memory = self.name_of_memory_parse
  if self.get_token(OPEN_BRA_REX) then
    constant_expression1 = self.constant_expression_parse
    self.parse_error("constant expression expected") unless constant_expression1
    self.parse_error("colon expected") unless self.get_token(COLON_REX)
    constant_expression2  = self.constant_expression_parse
    self.parse_error("constant expression expected") unless constant_expression2
    self.parse_error("closing bracket expected") unless self.get_token(CLOSE_BRA_REX)
    return register_variable_hook(name_of_memory,
                                  constant_expression1, 
                                  constant_expression2)
  else
    self.state = parse_state
    name_of_register = self.name_of_register_parse
    return register_variable_hook(name_of_register,nil,nil)
  end
end

#rule(name) ⇒ Object

Get a rule by +name+.



1353
1354
1355
# File 'lib/HDLRuby/verilog_parser.rb', line 1353

def rule(name)
  return RULES[name.to_sym]
end

#run(text: nil, filename: "", compress: false) ⇒ Object

Runs the full preprocesser and parser for text to parse +text+ and/or origin file named +filename+. If +compress+ is true the compressed version of the AST will be generated.



150
151
152
153
154
# File 'lib/HDLRuby/verilog_parser.rb', line 150

def run(text: nil, filename: "", compress: false)
  self.setup(text: text, filename: filename, compress: compress)
  self.preprocess
  self.parse
end

#scalar_constant_hook(tok) ⇒ Object



5457
5458
5459
# File 'lib/HDLRuby/verilog_parser.rb', line 5457

def scalar_constant_hook(tok)
  return AST[:scalar_constant, tok, self.property_hook ]
end

#scalar_constant_parseObject



5449
5450
5451
5452
5453
5454
5455
# File 'lib/HDLRuby/verilog_parser.rb', line 5449

def scalar_constant_parse
  tok = self.get_token(SCALAR_CONSTANT_REX)
  unless tok then
    return nil
  end
  return self.scalar_constant_hook(tok)
end

#scalar_event_expression_hook(scalar_event_expression) ⇒ Object



7284
7285
7286
# File 'lib/HDLRuby/verilog_parser.rb', line 7284

def scalar_event_expression_hook(scalar_event_expression)
  return AST[:scalar_event_expression, scalar_event_expression, self.property_hook ]
end

#scalar_event_expression_parseObject



7276
7277
7278
7279
7280
7281
7282
# File 'lib/HDLRuby/verilog_parser.rb', line 7276

def scalar_event_expression_parse
  # *Auth*: we use a simple expression here. The check is left to
  # the AST.
  expression = self.expression_parse
  return nil unless expression 
  return self.scalar_event_expression_hook(expression)
end

#scalar_expression_hook(expression) ⇒ Object



5414
5415
5416
# File 'lib/HDLRuby/verilog_parser.rb', line 5414

def scalar_expression_hook(expression)
  return AST[:scalar_expression, expression, self.property_hook ]
end

#scalar_expression_parseObject



5404
5405
5406
5407
5408
5409
5410
5411
5412
# File 'lib/HDLRuby/verilog_parser.rb', line 5404

def scalar_expression_parse
  # *Auth*: assume to be a plain expression: actually it should be
  # one-bit.
  # This is assumed to be checked at the AST level, for example
  # by redefinition the hook method.
  expression = self.expression_parse
  return nil unless expression
  return self.scalar_expression_hook(expression)
end

#scalar_timing_check_condition_hook(scalar_expression__tok, scalar_expression, scalar_constant) ⇒ Object



5390
5391
5392
5393
5394
5395
5396
# File 'lib/HDLRuby/verilog_parser.rb', line 5390

def scalar_timing_check_condition_hook(scalar_expression__tok,
                                       scalar_expression,
                                       scalar_constant)
  return AST[:scalar_timing_check_condition,
             scalar_expression__tok,
             scalar_expression,scalar_constant, self.property_hook ]
end

#scalar_timing_check_condition_parseObject



5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
# File 'lib/HDLRuby/verilog_parser.rb', line 5368

def scalar_timing_check_condition_parse
  if self.get_token(TILDE_REX) then
    scalar_expression = self.scalar_expression_parse
    self.parse_error("scalar expression expected") unless scalar_expression
    return self.scalar_timing_check_condition_hook(TILDE_TOK,
                                                   scalar_expression,
                                                   nil)
  end
  scalar_expression = self.scalar_expression_parse
  return nil unless scalar_expression
  tok = self.get_token(SCALAR_TIMING_CHECK_CONDITION_REX)
  if tok then
    scalar_constant = self.scalar_constant_parse
    self.parse_error("scalar constant expected") unless scalar_constant
    return self.scalar_timing_check_condition(tok,
                                              scalar_expression,
                                              scalar_constant)
  end
  return self.scalar_timing_check_condition_hook(scalar_expression,
                                                 nil,nil)
end

#sdpd_conditional_expression_hook(unary_operator__expression, expression__binary_operator, expression) ⇒ Object



5792
5793
5794
5795
5796
5797
5798
5799
# File 'lib/HDLRuby/verilog_parser.rb', line 5792

def sdpd_conditional_expression_hook(unary_operator__expression,
                                     expression__binary_operator,
                                     expression)
  return AST[:sdpd_conditionla_expression,
             unary_operator__expression,
             expression__binary_operator,
             expression, self.property_hook ]
end

#sdpd_conditional_expression_parseObject



5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
# File 'lib/HDLRuby/verilog_parser.rb', line 5772

def sdpd_conditional_expression_parse
  unary_operator = self._UNARY_OPERATOR_parse
  if unary_operator then
    expression = self.expression_parse
    self.parse_error("expression expected") unless expression
    return self.sdpd_conditional_expression_hook(unary_operator,
                                                 expression,nil)
  else
    expression0 = self.expression_parse
    return nil unless expression0
    binary_operator = self._BINARY_OPERATOR_parse
    self.parse_error("one of [#{BINARY_OPERATOR_TOKS.join(",")}] expected") unless binary_operator
    expression1 = self.expression_parse
    self.parse_error("expression expected") unless expression1
    return self.sdpd_conditional_expression_hook(expression0,
                                                 binary_operator,
                                                 expression1)
  end
end

#sdpd_hook(sdpd_conditional_expression, path_description, path_delay_value) ⇒ Object



5758
5759
5760
5761
5762
5763
# File 'lib/HDLRuby/verilog_parser.rb', line 5758

def sdpd_hook(sdpd_conditional_expression, path_description,
              path_delay_value)
  return AST[:sdpd, 
             sdpd_conditional_expression,path_description,
             path_delay_value, self.property_hook ]
end

#sdpd_parseObject



5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
# File 'lib/HDLRuby/verilog_parser.rb', line 5735

def sdpd_parse
  parse_state = self.state
  unless self.get_token(IF_REX) then
    self.state = parse_state
    return nil
  end
  self.parse_error("opening parenthesis expected") unless self.get_token(OPEN_PAR_REX)
  sdpd_conditional_expression = self.sdpd_conditional_expression_parse
  if !sdpd_conditional_expression then
    self.state = parse_state
    return nil
  end
  self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
  path_description = self.path_description_parse
  self.parse_error("path description expected") unless path_description
  self.parse_error("equal expected") unless self.get_token(EQUAL_REX)
  path_delay_value = self.path_delay_value_parse
  self.parse_error("path delay value expected") unless path_delay_value
  self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
  return sdpd_hook(sdpd_conditional_expression,path_description,
                   path_delay_value)
end

#seq_block_hook(name_of_block, block_declarations, statements) ⇒ Object



4248
4249
4250
4251
4252
# File 'lib/HDLRuby/verilog_parser.rb', line 4248

def seq_block_hook(name_of_block,
                   block_declarations, statements)
  return AST[:seq_block, name_of_block,
             block_declarations,statements, self.property_hook ]
end

#seq_block_parseObject



4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
# File 'lib/HDLRuby/verilog_parser.rb', line 4211

def seq_block_parse
  unless self.get_token(BEGIN_REX) then
    return nil
  end
  if self.get_token(COLON_REX) then
    name_of_block = self.name_of_block_parse
    self.parse_error("block name expected") unless name_of_block
    block_declarations = [ ]
    cur_block_declaration = nil
    loop do
      cur_block_declaration = self.block_declaration_parse
      break unless cur_block_declaration
      block_declarations << cur_block_declaration
    end
    statements = []
    cur_statement = nil
    loop do
      cur_statement = self.statement_parse
      break unless cur_statement
      statements << cur_statement
    end
    self.parse_error("'end' expected") unless self.get_token(END_REX)
    return self.seq_block_hook(name_of_block,block_declarations,
                               statements)
  else
    statements = []
    cur_statement = nil
    loop do
      cur_statement = self.statement_parse
      break unless cur_statement
      statements << cur_statement
    end
    self.parse_error("'end' expected") unless self.get_token(END_REX)
    return self.seq_block_hook(nil,nil,statements)
  end
end

#sequential_entry_hook(input_list, _state, next_state) ⇒ Object



2165
2166
2167
# File 'lib/HDLRuby/verilog_parser.rb', line 2165

def sequential_entry_hook(input_list, _state, next_state)
  return AST[:sequential_entry, input_list,_state,next_state, self.property_hook ]
end

#sequential_entry_parseObject



2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
# File 'lib/HDLRuby/verilog_parser.rb', line 2144

def sequential_entry_parse
  parse_state = self.state
  input_list = self.input_list_parse
  if !input_list or !self.get_token(COLON_REX) then
    self.state = parse_state
    return nil
  end
  parse_state = self.state
  _state = self.state_parse
  if !_state or !self.get_token(COLON_REX) then
    self.state = parse_state
    return nil
  end
  next_state = self.next_state_parse
  if !next_state or !self.get_token(SEMICOLON_REX) then
    self.state = parse_state
    return nil
  end
  return self.sequential_entry_hook(input_list,_state,next_state)
end

#setup(text: nil, filename: "", compress: false) ⇒ Object

Set up the parser with text to parse +text+ and/or origin file named +filename+



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/HDLRuby/verilog_parser.rb', line 159

def setup(text: nil, filename: "", compress: false)
  # Shall we load the file?
  if text then
    # The text is provided, so do not load it.
    @state.text = text.to_s
    @state.filename = filename.to_s
  else
    # Yes, load from filename.
    @state.filename = filename.to_s
    @state.text = File.read(@state.filename)
  end
  # Set the path the the files.
  @state.path = File.dirname(@state.filename) + "/"
  # Set the compress mode.
  @state.compress = compress ? true : false
end

#shift_term_hook(add_terms) ⇒ Object



6315
6316
6317
6318
6319
6320
6321
# File 'lib/HDLRuby/verilog_parser.rb', line 6315

def shift_term_hook(add_terms)
  if self.state.compress and add_terms.size == 1 then
    return add_terms[0]
  else
    return AST[:shift_term, add_terms, self.property_hook ]
  end
end

#shift_term_parseObject



6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
# File 'lib/HDLRuby/verilog_parser.rb', line 6298

def shift_term_parse
  # puts "shift_term_parse"
  cur_add_term = self.add_term_parse
  return nil unless cur_add_term
  add_terms = [ cur_add_term ]
  tok = nil
  loop do
    tok = self.get_token(ADD_OPERATOR_REX)
    break unless tok
    add_terms << tok
    cur_add_term = self.add_term_parse
    self.parse_error("expression expected") unless cur_add_term
    add_terms << cur_add_term
  end
  return shift_term_hook(add_terms)
end

#short_comment_hook(comment_text) ⇒ Object



6925
6926
6927
# File 'lib/HDLRuby/verilog_parser.rb', line 6925

def short_comment_hook(comment_text)
  return AST[:short_comment, comment_text, self.property_hook ]
end

#short_comment_parseObject



6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
# File 'lib/HDLRuby/verilog_parser.rb', line 6913

def short_comment_parse
  unless self.get_token(SLASH_SLASH_REX) then
    return nil
  end
  # *Auth*: long and short comment are separated while in the
  # BNF the are the same rule.
  comment_text = self.short_comment_text_parse
  self.parse_error("comment text expected") unless comment_text
  self.parse_error("end of line expected") unless self.get_token(EOL_REX)
  return self.short_comment_hook(comment_text)
end

#short_comment_text_parseObject



6973
6974
6975
6976
6977
# File 'lib/HDLRuby/verilog_parser.rb', line 6973

def short_comment_text_parse
  # *Auth*: long and short comment are separated while in the
  # BNF the are the same rule.
  return comment_text_hook(self.get_token(SHORT_COMMENT_TEXT_REX))
end

#source_text_hook(elems) ⇒ Object



1410
1411
1412
# File 'lib/HDLRuby/verilog_parser.rb', line 1410

def source_text_hook(elems)
  return AST[:source_text, elems, self.property_hook ]
end

#source_text_parseObject



1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
# File 'lib/HDLRuby/verilog_parser.rb', line 1399

def source_text_parse
  elems = []
  cur_elem = nil
  loop do
    cur_elem = self.description_parse
    break unless cur_elem
    elems << cur_elem
  end
  return self.source_text_hook(elems)
end

#specify_block_hook(specify_items) ⇒ Object



4524
4525
4526
# File 'lib/HDLRuby/verilog_parser.rb', line 4524

def specify_block_hook(specify_items)
  return AST[:specify_block, specify_items, self.property_hook ]
end

#specify_block_parseObject



4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
# File 'lib/HDLRuby/verilog_parser.rb', line 4509

def specify_block_parse
  unless self.get_token(SPECIFY_REX) then
    return nil
  end
  specify_items = []
  cur_specify_item = nil
  loop do
    cur_specify_item = self.specify_item_parse
    break unless cur_specify_item
    specify_items << cur_specify_item
  end
  self.parse_error("'endspecify expected'") unless self.get_token(ENDSPECIFY_REX)
  return self.specify_block_hook(specify_items)
end

#specify_input_terminal_descriptor_hook(input_identifier, constant_expression, constant_expression2) ⇒ Object



4794
4795
4796
4797
4798
4799
4800
# File 'lib/HDLRuby/verilog_parser.rb', line 4794

def specify_input_terminal_descriptor_hook(input_identifier,
                                           constant_expression,
                                           constant_expression2)
  return AST[:specify_input_terminal_descriptor,
             input_identifier,
             constant_expression,constant_expression2, self.property_hook ]
end

#specify_input_terminal_descriptor_parseObject



4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
# File 'lib/HDLRuby/verilog_parser.rb', line 4770

def specify_input_terminal_descriptor_parse
  input_identifier = self.input_identifier_parse
  return nil unless input_identifier
  unless self.get_token(OPEN_BRA_REX) then
    return self.specify_input_terminal_descriptor_hook(
      input_identifier,nil,nil)
  end
  constant_expression = self.constant_expression_parse
  self.parse_error("constant expression expected") unless constant_expression
  tok = self.get_token(CLOSE_BRA_COLON_REX)
  if tok == CLOSE_BRA_TOK then
    return self.specify_input_terminal_descriptor_hook(
      input_identifier,constant_expression,nil)
  elsif tok == COLON_TOK then
    constant_expression2 = self.constant_expression_parse
    self.parse_error("constant expression expected") unless constant_expression
    self.parse_error("closing bracket expected") unless self.get_token(CLOSE_BRA_REX)
    return self.specify_input_terminal_descriptor_hook(
      input_identifier,constant_expression,constant_expression2)
  else
    self.parse_error("invalid input terminal descriptor")
  end
end

#specify_item_hook(declaration) ⇒ Object



4569
4570
4571
4572
4573
4574
4575
# File 'lib/HDLRuby/verilog_parser.rb', line 4569

def specify_item_hook(declaration)
  if self.state.compress then
    return declaration
  else
    return AST[:specify_item, declaration, self.property_hook ]
  end
end

#specify_item_parseObject



4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
# File 'lib/HDLRuby/verilog_parser.rb', line 4539

def specify_item_parse
  specparam_declaration = self.specparam_declaration_parse
  if specparam_declaration then
    return self.specify_item_hook(specparam_declaration)
  end
  path_declaration = self.path_declaration_parse
  if path_declaration then
    return self.specify_item_hook(path_declaration)
  end
  level_sensitive_path_declaration = 
    self.level_sensitive_path_declaration_parse
  if level_sensitive_path_declaration then
    return self.specify_item_hook(level_sensitive_path_declaration)
  end
  edge_sensitive_path_declaration =
    self.edge_sensitive_path_declaration_parse
  if edge_sensitive_path_declaration then
    return self.specify_item_hook(edge_sensitive_path_declaration)
  end
  system_timing_check = self.system_timing_check_parse
  if system_timing_check then
    return self.specify_item_hook(system_timing_check)
  end
  sdpd = self.sdpd_parse
  if sdpd then
    return self.specify_item_hook(sdpd)
  end
  return nil
end

#specify_output_terminal_descriptor_hook(output_identifier, constant_expression, constant_expression2) ⇒ Object



4834
4835
4836
4837
4838
4839
4840
# File 'lib/HDLRuby/verilog_parser.rb', line 4834

def specify_output_terminal_descriptor_hook(output_identifier,
                                           constant_expression,
                                           constant_expression2)
  return AST[:specify_output_terminal_descriptor,
             output_identifier,
             constant_expression,constant_expression2, self.property_hook ]
end

#specify_output_terminal_descriptor_parseObject



4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
# File 'lib/HDLRuby/verilog_parser.rb', line 4810

def specify_output_terminal_descriptor_parse
  output_identifier = self.output_identifier_parse
  return nil unless output_identifier
  unless self.get_token(OPEN_BRA_REX) then
    return self.specify_output_terminal_descriptor_hook(
      output_identifier,nil,nil)
  end
  constant_expression = self.constant_expression_parse
  self.parse_error("constant expression expected") unless constant_expression
  tok = self.get_token(CLOSE_BRA_COLON_REX)
  if tok == CLOSE_BRA_TOK then
    return self.specify_output_terminal_descriptor_hook(
      output_identifier,constant_expression,nil)
  elsif tok == COLON_TOK then
    constant_expression2 = self.constant_expression_parse
    self.parse_error("constant expression expected") unless constant_expression
    self.parse_error("closing bracket expected") unless self.get_token(CLOSE_BRA_REX)
    return self.specify_output_terminal_descriptor_hook(
      output_identifier,constant_expression,constant_expression2)
  else
    self.parse_error("invalid output terminal descriptor")
  end
end

#specify_terminal_descriptor_hook(specify_terminal_descriptor) ⇒ Object



5201
5202
5203
5204
5205
5206
5207
# File 'lib/HDLRuby/verilog_parser.rb', line 5201

def specify_terminal_descriptor_hook(specify_terminal_descriptor)
  if self.state.compress then
    return specify_terminal_descriptor
  else
    return AST[:specify_terminal_descriptor, specify_terminal_descriptor, self.property_hook ]
  end
end

#specify_terminal_descriptor_parseObject



5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
# File 'lib/HDLRuby/verilog_parser.rb', line 5185

def specify_terminal_descriptor_parse
  specify_input_terminal_descriptor = 
    self.specify_input_terminal_descriptor_parse
  if specify_input_terminal_descriptor then
    return self.specify_terminal_descriptor(
      specify_input_terminal_descriptor)
  end
  specify_output_terminal_descriptor = 
    self.specify_output_terminal_descriptor_parse
  unless specify_output_terminal_descriptor then
    return nil
  end
  return self.specify_terminal_descriptor_hook(
    specify_output_terminal_descriptor)
end

#specparam_declaration_hook(list_of_param_assignments) ⇒ Object



4593
4594
4595
# File 'lib/HDLRuby/verilog_parser.rb', line 4593

def specparam_declaration_hook(list_of_param_assignments)
  return AST[:specparam_declaration, list_of_param_assignments, self.property_hook ]
end

#specparam_declaration_parseObject



4583
4584
4585
4586
4587
4588
4589
4590
4591
# File 'lib/HDLRuby/verilog_parser.rb', line 4583

def specparam_declaration_parse
  unless self.get_token(SPECPARAM_REX) then
    return nil
  end
  list_of_param_assignments = self.list_of_param_assignments_parse
  self.parse_error("list of parameter assignments expected") unless list_of_param_assignments
  self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
  return self.specparam_declaration_hook(list_of_param_assignments)
end

#stateObject

Get a copy of the current state.



551
552
553
# File 'lib/HDLRuby/verilog_parser.rb', line 551

def state
  return @state.clone
end

#state=(state) ⇒ Object

Sets the current state.



556
557
558
559
560
561
# File 'lib/HDLRuby/verilog_parser.rb', line 556

def state=(state)
  # @state.index = state.index
  # @state.lpos = state.lpos
  # @state.cpos = state.cpos
  @state = state
end

#state_hook(level_symbol) ⇒ Object



2283
2284
2285
# File 'lib/HDLRuby/verilog_parser.rb', line 2283

def state_hook(level_symbol)
  return AST[:state, level_symbol, self.property_hook ]
end

#state_parseObject



2277
2278
2279
2280
2281
# File 'lib/HDLRuby/verilog_parser.rb', line 2277

def state_parse
  level_symbol = self._LEVEL_SYMBOL_parse
  return nil unless level_symbol
  return self.state_hook(level_symbol)
end

#statement_hook(base, arg0, arg1, arg2, arg3) ⇒ Object



4032
4033
4034
# File 'lib/HDLRuby/verilog_parser.rb', line 4032

def statement_hook(base,arg0,arg1,arg2,arg3)
  return AST[:statement, base,arg0,arg1,arg2,arg3, self.property_hook ]
end

#statement_or_null_hook(statement) ⇒ Object



3866
3867
3868
# File 'lib/HDLRuby/verilog_parser.rb', line 3866

def statement_or_null_hook(statement)
  return AST[:statement_or_null, statement, self.property_hook ]
end

#statement_or_null_parseObject



3857
3858
3859
3860
3861
3862
3863
3864
# File 'lib/HDLRuby/verilog_parser.rb', line 3857

def statement_or_null_parse
  if self.get_token(SEMICOLON_REX) then
    return statement_or_null_hook(self._NULL_hook)
  end
  statement = self.statement_parse
  return nil unless statement
  return statement_or_null_hook(statement)
end

#statement_parseObject



3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
# File 'lib/HDLRuby/verilog_parser.rb', line 3899

def statement_parse
  tok = self.get_token(STATEMENT_REX)
  case(tok)
  when IF_TOK
    self.parse_error("opening parenthesis expected") unless self.get_token(OPEN_PAR_REX)
    expression = self.expression_parse
    self.parse_error("expression expected") unless expression
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    statement_or_null = self.statement_or_null_parse
    self.parse_error("statement or nothing expected") unless statement_or_null
    if self.get_token(ELSE_REX) then
      statement_or_null2 = self.statement_or_null_parse
      self.parse_error("statement or nothing expected") unless statement_or_null2
      return statement_hook(IF_TOK,expression,statement_or_null,
                            statement_or_null2,nil)
    else
      return statement_hook(tok,expression,statement_or_null,nil,nil)
    end
  when CASE_TOK, CASEZ_TOK, CASEX_TOK
    self.parse_error("opening parenthesis expected") unless self.get_token(OPEN_PAR_REX)
    expression = self.expression_parse
    self.parse_error("expression expected") unless expression
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    cur_case_item = self.case_item_parse
    self.parse_error("closing parenthesis expected") unless cur_case_item
    case_items = [ cur_case_item ]
    loop do
      cur_case_item = self.case_item_parse
      break unless cur_case_item
      case_items << cur_case_item
    end
    self.parse_error("'endcase' expected") unless self.get_token(ENDCASE_REX)
    return self.statement_hook(tok,expression,case_items,nil,nil)
  when FOREVER_TOK
    statement = self.statement_parse
    self.parse_error("statement expected") unless statement
    return self.statement_hook(tok,statement,nil,nil,nil)
  when REPEAT_TOK, WHILE_TOK
    self.parse_error("opening parenthesis expected") unless self.get_token(OPEN_PAR_REX)
    expression = self.expression_parse
    self.parse_error("expression expected") unless expression
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    statement = self.statement_parse
    self.parse_error("statement expression expected") unless statement
    return self.statement_hook(tok,expression,statement,nil,nil)
  when FOR_TOK
    self.parse_error("opening parenthesis expected") unless self.get_token(OPEN_PAR_REX)
    assignment = self.assignment_parse
    self.parse_error("assignment expected") unless assignment
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    expression = self.expression_parse
    self.parse_error("expression expected") unless expression
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    assignment2 = self.assignment_parse
    self.parse_error("assignment expected") unless assignment2
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    statement = self.statement_parse
    self.parse_error("statement expected") unless statement
    return self.statement_hook(tok,assignment,expression,assignment2,
                              statement)
  when WAIT_TOK
    self.parse_error("opening parenthesis expected") unless self.get_token(OPEN_PAR_REX)
    expression = self.expression_parse
    self.parse_error("expression expected") unless expression
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    statement_or_null = self.statement_or_null_parse
    self.parse_error("statement or nothing expected") unless statement_or_null
    return self.statement_hook(tok,expression,statement_or_null,
                               nil,nil)
  when RIGHT_ARROW_TOK
    name_of_event = self.parse_name_of_event
    self.parse_error("event name expected") unless name_of_event
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    return self.statement_hook(tok,name_of_event,nil,nil,nil)
  when DISABLE_TOK
    name_of_task = self.name_of_task_parse
    if name_of_task then
      self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
      return self.statement_hook(tok,name_of_task,nil,nil,nil)
    end
    name_of_block = self.name_of_block_parse
    if name_of_block then
      self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
      return self.statement_hook(tok,name_of_block,nil,nil,nil)
    end
    self.parse_error("invalid disable")
  when ASSIGN_TOK, FORCE_TOK
    assignment = self.assignment_parse
    self.parse_error("assignment expected") unless assignment
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    return self.statement_hook(tok,assignment,nil,nil,nil)
  when DEASSIGN_TOK, RELEASE_TOK
    lvalue = self.lvalue_parse
    self.parse_error("left value expected") unless lvalue
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    return self.statement_hook(tok,lvalue,nil,nil,nil)
  end
  delay_or_event_control = self.delay_or_event_control_parse
  if delay_or_event_control then
    statement_or_null = self.statement_or_null_parse
    self.parse_error("statement or nothing expected") unless statement_or_null
    return self.statement_hook(delay_or_event_control,
                               statement_or_null,nil,nil,nil)
  end
  seq_block = self.seq_block_parse
  if seq_block then
    return self.statement_hook(seq_block,nil,nil,nil,nil)
  end
  par_block = self.par_block_parse
  if par_block then
    return self.statement_hook(par_block,nil,nil,nil,nil)
  end
  task_enable = self.task_enable_parse
  if task_enable then
    return self.statement_hook(task_enable,nil,nil,nil,nil)
  end
  system_task_enable = self.system_task_enable_parse
  if system_task_enable then
    return self.statement_hook(system_task_enable,nil,nil,nil,nil)
  end
  blocking_assignment = self.blocking_assignment_parse
  if blocking_assignment then
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    return self.statement_hook(blocking_assignment,nil,nil,nil,nil)
  end
  non_blocking_assignment = self.non_blocking_assignment_parse
  if non_blocking_assignment then
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    return self.statement_hook(non_blocking_assignment,nil,nil,nil,nil)
  end
  return nil
end

#system_identifier_hook(tok) ⇒ Object



4496
4497
4498
# File 'lib/HDLRuby/verilog_parser.rb', line 4496

def system_identifier_hook(tok)
  AST[:system_identifier, tok, self.property_hook ]
end

#system_identifier_parseObject



4487
4488
4489
4490
4491
4492
4493
4494
# File 'lib/HDLRuby/verilog_parser.rb', line 4487

def system_identifier_parse
  tok = self.get_token(SYSTEM_IDENTIFIER_REX)
  if tok then
    return self.system_identifier_hook(tok)
  end
  return nil
  # self.parse_error("dollar-starting identifier expected")
end

#system_task_enable_hook(name_of_system_task, expressions) ⇒ Object



4460
4461
4462
# File 'lib/HDLRuby/verilog_parser.rb', line 4460

def system_task_enable_hook(name_of_system_task,expressions)
  return AST[:system_task_enable, name_of_system_task,expressions, self.property_hook ]
end

#system_task_enable_parseObject



4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
# File 'lib/HDLRuby/verilog_parser.rb', line 4425

def system_task_enable_parse
  parse_state = self.state
  name_of_system_task = self.name_of_system_task_parse
  return nil unless name_of_system_task
  unless self.get_token(OPEN_PAR_REX) then
    if self.get_token(SEMICOLON_REX) then
      return self.system_task_enable_hook(name_of_system_task,nil)
    else
      self.state = parse_state
      return nil
    end
  end
  cur_expression = self.expression_parse
  # self.parse_error("expression expected") unless cur_expression
  if !cur_expression then
    # No arguments, check for closing parenthsis and semicolon 
    # then return.
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    return self.system_task_enable_hook(name_of_system_task,[])
  end
  expressions = [ cur_expression ]
  loop do
    unless self.get_token(COMMA_REX) then
      break
    end
    cur_expression = self.expression_parse
    self.parse_error("expression expected") unless cur_expression
    expressions << cur_expression
  end
  self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
  self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
  return self.system_task_enable_hook(name_of_system_task,expressions)
end

#system_timing_check_hook(tok, arg0, arg1, arg2, arg3, arg4) ⇒ Object



5138
5139
5140
5141
# File 'lib/HDLRuby/verilog_parser.rb', line 5138

def system_timing_check_hook(tok,arg0,arg1,arg2,arg3,arg4)
  return AST[:system_timing_check,
             tok,arg0,arg1,arg2,arg3,arg4, self.property_hook ]
end

#system_timing_check_parseObject



4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
# File 'lib/HDLRuby/verilog_parser.rb', line 4995

def system_timing_check_parse
  tok = self.get_token(SYSTEM_TIMING_REX)
  case(tok)
  when SETUP_TOK, HOLD_TOK
    timing_check_event0 = self.timing_check_event_parse
    self.parse_error("timing check event expected") unless timing_check_event0
    self.parse_error("comma expected") unless self.get_token(COMMA_REX)
    timing_check_event1 = self.timing_check_event_parse
    self.parse_error("timing check event expected") unless timing_check_event1
    self.parse_error("comma expected") unless self.get_token(COMMA_REX)
    timing_check_limit = self.timing_check_limit_parse
    self.parse_error("timing check limit expected") unless timing_check_limit
    notify_register = nil
    if self.get_token(COMMA_REX) then
      notify_register = self.notify_register_parse
      self.parse_error("identifier expected") unless cur_notify_register
    end
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    return self.system_timing_check_hook(tok,
                                         timing_check_event0,
                                         timing_check_event1,
                                         timing_check_limit,
                                         notify_register,
                                         nil)
  when PERIOD_TOK
    controlled_timing_check_event = 
      self.controlled_timing_check_event_parse
    self.parse_error("controlled timing check expected") unless controlled_timing_check_event
    self.parse_error("comma expected") unless self.get_token(COMMA_REX)
    timing_check_limit = self.timing_check_limit_parse
    self.parse_error("timing check limit expected") unless timing_check_limit
    notify_register = nil
    if self.get_token(COMMA_REX) then
      notify_register = self.notify_register_parse
      self.parse_error("identifier expected") unless cur_notify_register
    end
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    return self.system_timing_check_hook(tok,
                                        controlled_timing_check_event,
                                        timing_check_limit,
                                        notify_register,
                                        nil,nil)
  when WIDTH_TOK
    controlled_timing_check_event = 
      self.controlled_timing_check_event_parse
    self.parse_error("controlled timing check event expected") unless controlled_timing_check_event
    self.parse_error("comma expected") unless self.get_token(COMMA_REX)
    timing_check_limit = self.timing_check_limit_parse
    self.parse_error("timing check limit expected") unless timing_check_limit
    constant_expression = nil
    notify_register = nil
    if self.get_token(COMMA_REX) then
      constant_expression = self.constant_expression_parse
      self.parse_error("constant expression expected") unless constant_expression
      self.parse_error("comma expected") unless self.get_token(COMMA_REX)
      notify_register = self.notify_register_parse
      self.parse_error("identifier expected") unless notify_register
    end
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    return self.system_timing_check_hook(tok,
                                        controlled_timing_check_event,
                                        timing_check_limit,
                                        constant_expression,
                                        notify_register,
                                        nil)
  when SKEW_TOK
    timing_check_event0 = self.timing_check_event_parse
    self.parse_error("timing check event expected") unless timing_check_event0
    self.parse_error("comma expected") unless self.get_token(COMMA_REX)
    timing_check_event1 = self.timing_check_event1
    self.parse_error("timing check event expected") unless timing_check_event1
    timing_check_limit = self.timing_check_limit_parse
    self.parse_error("timing check limit expected") unless timing_check_limit
    notify_register = nil
    if self.get_token(COMMA_REX) then
      notify_register = self.notify_register_parse
      self.parse_error("identifier expected") unless cur_notify_register
    end
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    return self.system_timing_check_hook(tok,
                                         timing_check_event0.
                                         timing_check_event1,
                                         timing_check_limit,
                                         notify_register,
                                         nil)
  when RECOVERY_TOK
    controlled_timing_check_event = 
      self.controlled_timing_check_event_parse
    self.parse_error("controlled timing check event expected") unless controlled_timing_check_event
    self.parse_error("comma expected") unless self.get_token(COMMA_REX)
    timing_check_event = self.timing_check_event_parse
    self.parse_error("timing check event expected") unless timing_check_event
    self.parse_error("comma expected") unless self.get_token(COMMA_REX)
    timing_check_limit = self.timing_check_limit_parse
    self.parse_error("timing check event expected") unless timing_check_limit
    notify_register = nil
    if self.get_token(COMMA_REX) then
      notify_register = self.notify_register_parse
      self.parse_error("identifier expected") unless cur_notify_register
    end
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    return self.system_timing_check_hook(tok,
                                        controlled_timing_check_event,
                                        timing_check_event,
                                        timing_check_limit,
                                        notify_register,
                                        nil)
  when SETUPHOLD_TOK
    timing_check_event0 = self.timing_check_event_parse
    self.parse_error("timing check event expected") unless timing_check_event0
    self.parse_error("comma expected") unless self.get_token(COMMA_REX)
    timing_check_event1 = self.timing_check_event_parse
    self.parse_error("timing check event expected") unless timing_check_event1
    self.parse_error("comma expected") unless self.get_token(COMMA_REX)
    timing_check_limit0 = self.timing_check_limit_parse
    self.parse_error("timing check limit expected") unless timing_check_limit0
    self.parse_error("comma expected") unless self.get_token(COMMA_REX)
    timing_check_limit1 = self.timing_check_limit_parse
    self.parse_error("timing check limit expected") unless timing_check_limit1
    self.parse_error("comma expected") unless self.get_token(COMMA_REX)
    notify_register = nil
    if self.get_token(COMMA_REX) then
      notify_register = self.notify_register_parse
      self.parse_error("identifier expected") unless cur_notify_register
    end
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    return self.system_timing_check_hook(tok,
                                         timing_check_event0,
                                         timing_check_event1,
                                         timing_check_limit0,
                                         timing_check_limit1,
                                         notify_register)
  else
    return nil
  end
end

#table_definition_hook(table_entries) ⇒ Object



2075
2076
2077
# File 'lib/HDLRuby/verilog_parser.rb', line 2075

def table_definition_hook(table_entries)
  return AST[:table_definition, table_entries, self.property_hook ]
end

#table_definition_parseObject



2066
2067
2068
2069
2070
2071
2072
2073
# File 'lib/HDLRuby/verilog_parser.rb', line 2066

def table_definition_parse
  unless self.get_token(TABLE_REX) then
    return nil
  end
  table_entries = self.table_entries_parse
  self.parse_error("'endtable' expected") unless self.get_token(ENDTABLE_REX)
  return self.table_definition_hook(table_entries)
end

#table_entries_hook(entries) ⇒ Object



2109
2110
2111
# File 'lib/HDLRuby/verilog_parser.rb', line 2109

def table_entries_hook(entries)
  return AST[:table_entries, entries, self.property_hook ]
end

#table_entries_parseObject



2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
# File 'lib/HDLRuby/verilog_parser.rb', line 2086

def table_entries_parse
  cur_combinational_entry = self.combinational_entry_parse
  if cur_combinational_entry then
    combinational_entries = [ cur_combinational_entry ]
    loop do
      cur_combinational_entry = self.combinational_entry_parse
      break unless cur_combinational_entry
      combinational_entries << cur_combinational_entry
    end
    return table_entries_hook(combinational_entries)
  else
    cur_sequential_entry = self.sequential_entry_parse
    self.parse_error("sequential entry expected") unless cur_sequential_entry
    sequential_entries = [ cur_sequential_entry ]
    loop do
      cur_sequential_entry = self.sequential_entry_parse
      break unless cur_sequential_entry
      sequential_entries << cur_sequential_entry
    end
    return self.table_entries_hook(sequential_entries)
  end
end

#task_enable_hook(name_of_task, expressions) ⇒ Object



4414
4415
4416
# File 'lib/HDLRuby/verilog_parser.rb', line 4414

def task_enable_hook(name_of_task,expressions)
  return AST[:task_enable, name_of_task,expressions, self.property_hook ]
end

#task_enable_parseObject



4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
# File 'lib/HDLRuby/verilog_parser.rb', line 4386

def task_enable_parse
  parse_state = self.state
  name_of_task = self.name_of_task_parse
  return nil unless name_of_task
  unless self.get_token(OPEN_PAR_REX) then
    if self.get_token(SEMICOLON_REX) then
      return self.task_enable_hook(name_of_task,nil)
    else
      self.state = parse_state
      return nil
    end
  end
  cur_expression = self.expression_parse
  self.parse_error("expression expected") unless cur_expression
  expressions = [ cur_expression ]
  loop do
    unless self.get_token(COMMA_REX) then
      break
    end
    cur_expression = self.expression_parse
    self.parse_error("expression expected") unless cur_expression
    expressions << cur_expression
  end
  self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
  self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
  return self.task_enable_hook(name_of_task,expressions)
end

#task_hook(name_of_task, tf_declaration, statement_or_null) ⇒ Object



2384
2385
2386
# File 'lib/HDLRuby/verilog_parser.rb', line 2384

def task_hook(name_of_task, tf_declaration, statement_or_null)
  return AST[:task, name_of_task,tf_declaration,statement_or_null, self.property_hook ]
end

#task_parseObject



2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
# File 'lib/HDLRuby/verilog_parser.rb', line 2364

def task_parse
  unless self.get_token(TASK_REX) then
    return nil
  else
    name_of_task = self.name_of_task_parse
    self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
    tf_declarations = []
    cur_tf_declaration = nil
    loop do
      cur_tf_declaration = self.tf_declaration_parse
      break unless cur_tf_declaration
      tf_declarations << cur_tf_declaration
    end
    statement_or_null = self.statement_or_null_parse
    self.parse_error("statement or nothing expected") unless statement_or_null
    self.parse_error("'endtask' expected") unless self.get_token(ENDTASK_REX)
    return self.task_hook(name_of_task,tf_declarations,statement_or_null)
  end
end

#terminal_hook(terminal) ⇒ Object



3574
3575
3576
# File 'lib/HDLRuby/verilog_parser.rb', line 3574

def terminal_hook(terminal)
  return AST[:terminal, terminal, self.property_hook ]
end

#terminal_parseObject



3564
3565
3566
3567
3568
3569
3570
3571
3572
# File 'lib/HDLRuby/verilog_parser.rb', line 3564

def terminal_parse
  expression = self.expression_parse
  if expression then
    return self.terminal_hook(expression)
  end
  identifier = self._IDENTIFIER_parse
  return nil unless identifier
  return self.terminal_hook(identifier)
end

#tf_declaration_hook(declaration) ⇒ Object



2517
2518
2519
2520
2521
2522
2523
# File 'lib/HDLRuby/verilog_parser.rb', line 2517

def tf_declaration_hook(declaration)
  if self.state.compress then
    return declaration
  else
    return AST[:tf_declaration, declaration, self.property_hook ]
  end
end

#tf_declaration_parseObject



2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
# File 'lib/HDLRuby/verilog_parser.rb', line 2497

def tf_declaration_parse
  declaration = self.parameter_declaration_parse
  return self.tf_declaration_hook(declaration) if declaration
  declaration = self.input_declaration_parse
  return self.tf_declaration_hook(declaration) if declaration
  declaration = self.output_declaration_parse
  return self.tf_declaration_hook(declaration) if declaration
  declaration = self.inout_declaration_parse
  return self.tf_declaration_hook(declaration) if declaration
  declaration = self.reg_declaration_parse
  return self.tf_declaration_hook(declaration) if declaration
  declaration = self.time_declaration_parse
  return self.tf_declaration_hook(declaration) if declaration
  declaration = self.integer_declaration_parse
  return self.tf_declaration_hook(declaration) if declaration
  declaration = self.real_declaration_parse
  return self.tf_declaration_hook(declaration) if declaration
  return nil
end

#time_declaration_hook(list_of_register_variables) ⇒ Object



2871
2872
2873
# File 'lib/HDLRuby/verilog_parser.rb', line 2871

def time_declaration_hook(list_of_register_variables)
  return AST[:time_declaration, list_of_register_variables, self.property_hook ]
end

#time_declaration_parseObject



2861
2862
2863
2864
2865
2866
2867
2868
2869
# File 'lib/HDLRuby/verilog_parser.rb', line 2861

def time_declaration_parse
  # puts "time_declaration_parse"
  unless self.get_token(TIME_REX) then
    return nil
  end
  list_of_register_variables = self.list_of_register_variables_parse
  self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
  return time_declaration_hook(list_of_register_variables)
end

#timing_check_condition_hook(scalar_timing_check_condition) ⇒ Object



5348
5349
5350
5351
5352
5353
5354
5355
# File 'lib/HDLRuby/verilog_parser.rb', line 5348

def timing_check_condition_hook(scalar_timing_check_condition)
  if self.state.compress then
    return scalar_timing_check_condition
  else
    return AST[:timing_check_condition,
               scalar_timing_check_condition, self.property_hook ]
  end
end

#timing_check_condition_parseObject



5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
# File 'lib/HDLRuby/verilog_parser.rb', line 5331

def timing_check_condition_parse
  scalar_timing_check_condition = nil
  if self.get_token(OPEN_PAR_REX) then
    scalar_timing_check_condition = 
      self.scalar_timig_check_condition_parse
    unless scalar_timing_check_condition then
      return nil
    end
    self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
  else
    scalar_timing_check_condition = 
      self.scalar_timig_check_condition_parse
    return nil unless scalar_timing_check_condition
  end
  return self.timing_check_condition_hook(scalar_timing_check_condition)
end

#timing_check_event_control_hook(tok__edge_control_specifier) ⇒ Object



5267
5268
5269
# File 'lib/HDLRuby/verilog_parser.rb', line 5267

def timing_check_event_control_hook(tok__edge_control_specifier)
  return AST[:timing_check_event_control, tok__event_control_specifier, self.property_hook ]
end

#timing_check_event_control_parseObject



5257
5258
5259
5260
5261
5262
5263
5264
5265
# File 'lib/HDLRuby/verilog_parser.rb', line 5257

def timing_check_event_control_parse
  tok = self.get_token(POSEDGE_NEGEDGE_REX)
  if tok then
    return self.timing_check_event_control_hook(tok)
  end
  edge_control_specifier = self.edge_control_specifier_parse
  return nil unless edge_control_specifier
  return self.timing_check_event_control_hook(edge_control_specifier)
end

#timing_check_event_hook(timing_check_event_control, specify_terminal_descriptor, timing_check_condition) ⇒ Object



5170
5171
5172
5173
5174
5175
5176
# File 'lib/HDLRuby/verilog_parser.rb', line 5170

def timing_check_event_hook(timing_check_event_control,
                            specify_terminal_descriptor,
                            timing_check_condition)
  return AST[:timing_check_event, timing_check_event_control,
             specify_terminal_descriptor,
             timing_check_condition, self.property_hook ]
end

#timing_check_event_parseObject



5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
# File 'lib/HDLRuby/verilog_parser.rb', line 5150

def timing_check_event_parse
  parse_state = self.state
  timing_check_event_control = self.timing_check_event_control_parse
  specify_terminal_descriptor = self.specify_terminal_descriptor_parse
  unless specify_terminal_descriptor then
    self.state = parse_state
    return nil
  end
  unless self.get_token(AND_AND_AND_REX) then
    return self.timing_check_event_hook(timing_check_event_control,
                                        specify_terminal_descriptor,
                                        nil)
  end
  timing_check_condition = self.timing_check_condition_parse
  self.parse_error("timing check condition expected") unless timing_check_condition
  return self.timing_check_event_hook(timing_check_event_control,
                                      specify_terminal_descriptor,
                                      timing_check_condition)
end

#timing_check_list_hook(expression) ⇒ Object



5430
5431
5432
# File 'lib/HDLRuby/verilog_parser.rb', line 5430

def timing_check_list_hook(expression)
  return AST[:timing_check_list, expression, self.property_hook ]
end

#timing_check_list_parseObject



5424
5425
5426
5427
5428
# File 'lib/HDLRuby/verilog_parser.rb', line 5424

def timing_check_list_parse
  expression = self.expression_parse
  return nil unless expression
  return self.timing_check_list_hook(expression)
end

#udp_declaration_hook(declaration) ⇒ Object



1988
1989
1990
1991
1992
1993
1994
# File 'lib/HDLRuby/verilog_parser.rb', line 1988

def udp_declaration_hook(declaration)
  if self.state.compress then
    return declaration
  else
    return AST[:UDP_declaration, declaration, self.property_hook ]
  end
end

#udp_declaration_parseObject



1978
1979
1980
1981
1982
1983
1984
1985
1986
# File 'lib/HDLRuby/verilog_parser.rb', line 1978

def udp_declaration_parse
  declaration = self.output_declaration_parse
  return self.udp_declaration_hook(declaration) if declaration
  declaration = self.reg_declaration_parse
  return self.udp_declaration_hook(declaration) if declaration
  declaration = self.input_declaration_parse
  return self.udp_declaration_hook(declaration) if declaration
  return nil
end

#udp_hook(name, name_of_variables, udp_declarations, udp_initial_statement, table_definition) ⇒ Object



1941
1942
1943
1944
1945
1946
# File 'lib/HDLRuby/verilog_parser.rb', line 1941

def udp_hook(name, name_of_variables, udp_declarations,
             udp_initial_statement, table_definition)
  return AST[:UDP, 
             name,name_of_variables,udp_declarations,
             udp_initial_statement,table_definition, self.property_hook ]
end

#udp_initial_statement_hook(output_terminal_name, init_val) ⇒ Object



2011
2012
2013
# File 'lib/HDLRuby/verilog_parser.rb', line 2011

def udp_initial_statement_hook(output_terminal_name,init_val)
  return AST[:UDP_initial_statement, output_terminal_name,init_val, self.property_hook ]
end

#udp_initial_statement_parseObject



2002
2003
2004
2005
2006
2007
2008
2009
# File 'lib/HDLRuby/verilog_parser.rb', line 2002

def udp_initial_statement_parse
  return nil unless self.get_token(INITIAL_REX)
  output_terminal_name = self.output_terminal_name_parse
  self.parse_error("equal expected") unless self.get_token(EQUAL_REX)
  init_val = self.init_val_parse
  self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
  return self.udp_initial_statement_hook(output_terminal_name,init_val)
end

#udp_instance_hook(name_of_udp_instance, terminals) ⇒ Object



3536
3537
3538
# File 'lib/HDLRuby/verilog_parser.rb', line 3536

def udp_instance_hook(name_of_udp_instance, terminals)
  return AST[:UDP_instance, name_of_udp_instance,terminals, self.property_hook ]
end

#udp_instance_parseObject



3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
# File 'lib/HDLRuby/verilog_parser.rb', line 3511

def udp_instance_parse
  parse_state = self.state
  name_of_udp_instance = self.name_of_udp_instance_parse
  unless self.get_token(OPEN_PAR_REX) then
    self.state = parse_state
    return nil
  end
  cur_terminal = self.terminal_parse
  unless cur_terminal then
    self.state = parse_state
    return nil
  end
  terminals = [ cur_terminal ]
  loop do
    unless self.get_token(COMMA_REX) then
      break
    end
    cur_terminal = self.terminal_parse
    self.parse_error("terminal expected") unless cur_terminal
    terminals << cur_terminal
  end
  self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
  return udp_instance_hook(name_of_udp_instance,terminals)
end

#udp_instantiation_hook(name_of_udp, drive_strength, delay, udp_instances) ⇒ Object



3483
3484
3485
3486
3487
# File 'lib/HDLRuby/verilog_parser.rb', line 3483

def udp_instantiation_hook(name_of_udp, drive_strength, delay,
                           udp_instances)
  return AST[:udp_instantiation,
             name_of_udp,drive_strength,delay,udp_instances, self.property_hook ]
end

#udp_instantiation_parseObject



3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
# File 'lib/HDLRuby/verilog_parser.rb', line 3459

def udp_instantiation_parse
  # puts "udp_instantiation_parse"
  parse_state = self.state
  name_of_udp = self.name_of_udp_parse
  return nil unless name_of_udp
  drive_strength = self.drive_strength_parse
  delay = self.delay_parse
  cur_udp_instance = self.udp_instance_parse
  unless cur_udp_instance then
    self.state = parse_state
    return nil
  end
  udp_instances = [ cur_udp_instance ]
  loop do
    break unless self.get_token(COMMA_REX)
    cur_udp_instance = self.udp_instance_parse
    self.parse_error("UDP instance expected") unless cur_udp_instance
    udp_instances << cur_udp_instance
  end
  self.parse_error("semicolon expected") unless self.get_token(SEMICOLON)
  return udp_instantiation_hook(name_of_udp,drive_strength,delay,
                                udp_instances)
end

#udp_name?(name) ⇒ Boolean

Tells if a name is a known UDP name.

Returns:

  • (Boolean)


624
625
626
# File 'lib/HDLRuby/verilog_parser.rb', line 624

def udp_name?(name)
  return @udp_names.include?(name)
end

#udp_parseObject



1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
# File 'lib/HDLRuby/verilog_parser.rb', line 1904

def udp_parse
  unless self.get_token(PRIMITIVE_REX) then
    return nil
  end
  name = self.name_of_udp_parse
  self.parse_error("name of UDP expected") unless name
  self.parse_error("opening parenthesis expected") unless self.get_token(OPEN_PAR_REX)
  cur_name_of_variable = self.name_of_variable_parse
  self.parse_error("variable name expected") unless cur_name_of_variable
  name_of_variables = [ cur_name_of_variable ]
  loop do
    break unless self.get_token(COMMA_REX)
    cur_name_of_variable = self.name_of_variable_parse
    self.parse_error("identifier expected") unless cur_name_of_variable
    name_of_variables << cur_name_of_variable
  end
  self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
  self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
  udp_declarations = []
  cur_udp_declaration = nil
  loop do
    cur_udp_declaration = self.udp_declaration_parse
    break unless cur_udp_declaration
    udp_declarations << cur_udp_declaration
  end
  self.parse_error("empty UDP declaration") if udp_declarations.empty? # udp_declaration+ rule
  udp_initial_statement = self.udp_initial_statement_parse
  table_definition = self.table_definition_parse
  self.parse_error("'endprimitive' expected") unless self.get_token(ENDPRIMITIVE_REX)

  # Add a know udp name.
  self.add_udp_name(name)
  # And return the corresponding AST
  return self.udp_hook(name,name_of_variables,udp_declarations,
                       udp_initial_statement, table_definition)
end