2019-04-03 19:45:43 +02:00
|
|
|
{- sv2v
|
|
|
|
|
- Author: Zachary Snow <zach@zachjs.com>
|
|
|
|
|
- Original Parser Author: Tom Hawkins <tomahawkins@gmail.com>
|
2020-05-07 01:03:32 +02:00
|
|
|
- vim: filetype=haskell
|
2019-04-03 19:45:43 +02:00
|
|
|
-
|
|
|
|
|
- This file has been *heavily* modified and extended from the original version
|
|
|
|
|
- in tomahawkins/verilog. I have added support for numerous SystemVerilog
|
|
|
|
|
- constructs, which has necessitated rewriting nearly all of this.
|
2019-04-04 02:24:09 +02:00
|
|
|
-
|
|
|
|
|
- This file is the only remaining one that still uses 2-space indentation. I've
|
|
|
|
|
- decided to leave it this way because I think it is too important to preserve
|
|
|
|
|
- the ability to easily blame/diff this file.
|
2019-04-03 19:45:43 +02:00
|
|
|
-}
|
2019-02-08 05:49:12 +01:00
|
|
|
{
|
2020-01-31 04:17:17 +01:00
|
|
|
{-# LANGUAGE BlockArguments #-}
|
2021-06-25 06:15:46 +02:00
|
|
|
{-# LANGUAGE TupleSections #-}
|
2019-04-04 02:24:09 +02:00
|
|
|
module Language.SystemVerilog.Parser.Parse (parse) where
|
2019-02-24 09:06:40 +01:00
|
|
|
|
2019-09-18 01:34:53 +02:00
|
|
|
import Control.Monad.Except
|
2020-08-12 01:14:18 +02:00
|
|
|
import Control.Monad.State.Strict
|
2021-07-14 21:50:12 +02:00
|
|
|
import Data.Maybe (catMaybes, fromMaybe)
|
2019-02-08 06:19:39 +01:00
|
|
|
import Language.SystemVerilog.AST
|
2019-03-04 08:58:00 +01:00
|
|
|
import Language.SystemVerilog.Parser.ParseDecl
|
2019-02-08 06:19:39 +01:00
|
|
|
import Language.SystemVerilog.Parser.Tokens
|
2019-02-08 05:49:12 +01:00
|
|
|
}
|
|
|
|
|
|
2020-01-31 04:17:17 +01:00
|
|
|
%monad { ParseState }
|
|
|
|
|
%lexer { positionKeep } { TokenEOF }
|
2021-04-21 01:47:55 +02:00
|
|
|
%name parseMain
|
2019-02-08 05:49:12 +01:00
|
|
|
%tokentype { Token }
|
2021-07-03 19:23:33 +02:00
|
|
|
%error { parseErrorTok }
|
2019-02-08 05:49:12 +01:00
|
|
|
|
2019-02-10 23:46:18 +01:00
|
|
|
%expect 0
|
2019-02-08 05:49:12 +01:00
|
|
|
|
|
|
|
|
%token
|
|
|
|
|
|
2019-09-14 18:31:44 +02:00
|
|
|
"$bits" { Token KW_dollar_bits _ _ }
|
|
|
|
|
"$dimensions" { Token KW_dollar_dimensions _ _ }
|
|
|
|
|
"$unpacked_dimensions" { Token KW_dollar_unpacked_dimensions _ _ }
|
|
|
|
|
"$left" { Token KW_dollar_left _ _ }
|
|
|
|
|
"$right" { Token KW_dollar_right _ _ }
|
|
|
|
|
"$low" { Token KW_dollar_low _ _ }
|
|
|
|
|
"$high" { Token KW_dollar_high _ _ }
|
|
|
|
|
"$increment" { Token KW_dollar_increment _ _ }
|
|
|
|
|
"$size" { Token KW_dollar_size _ _ }
|
|
|
|
|
|
2019-09-05 03:02:02 +02:00
|
|
|
"accept_on" { Token KW_accept_on _ _ }
|
|
|
|
|
"alias" { Token KW_alias _ _ }
|
2019-02-18 06:26:43 +01:00
|
|
|
"always" { Token KW_always _ _ }
|
|
|
|
|
"always_comb" { Token KW_always_comb _ _ }
|
|
|
|
|
"always_ff" { Token KW_always_ff _ _ }
|
|
|
|
|
"always_latch" { Token KW_always_latch _ _ }
|
2019-03-22 06:31:43 +01:00
|
|
|
"and" { Token KW_and _ _ }
|
2019-03-30 05:47:37 +01:00
|
|
|
"assert" { Token KW_assert _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"assign" { Token KW_assign _ _ }
|
2019-04-04 01:08:30 +02:00
|
|
|
"assume" { Token KW_assume _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"automatic" { Token KW_automatic _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"before" { Token KW_before _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"begin" { Token KW_begin _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"bind" { Token KW_bind _ _ }
|
|
|
|
|
"bins" { Token KW_bins _ _ }
|
|
|
|
|
"binsof" { Token KW_binsof _ _ }
|
2019-03-22 21:57:13 +01:00
|
|
|
"bit" { Token KW_bit _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"break" { Token KW_break _ _ }
|
2019-03-22 06:31:43 +01:00
|
|
|
"buf" { Token KW_buf _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"bufif0" { Token KW_bufif0 _ _ }
|
|
|
|
|
"bufif1" { Token KW_bufif1 _ _ }
|
2019-03-22 21:57:13 +01:00
|
|
|
"byte" { Token KW_byte _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"case" { Token KW_case _ _ }
|
|
|
|
|
"casex" { Token KW_casex _ _ }
|
|
|
|
|
"casez" { Token KW_casez _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"cell" { Token KW_cell _ _ }
|
|
|
|
|
"chandle" { Token KW_chandle _ _ }
|
|
|
|
|
"checker" { Token KW_checker _ _ }
|
|
|
|
|
"class" { Token KW_class _ _ }
|
|
|
|
|
"clocking" { Token KW_clocking _ _ }
|
|
|
|
|
"cmos" { Token KW_cmos _ _ }
|
|
|
|
|
"config" { Token KW_config _ _ }
|
|
|
|
|
"const" { Token KW_const _ _ }
|
|
|
|
|
"constraint" { Token KW_constraint _ _ }
|
|
|
|
|
"context" { Token KW_context _ _ }
|
|
|
|
|
"continue" { Token KW_continue _ _ }
|
2019-04-04 01:08:30 +02:00
|
|
|
"cover" { Token KW_cover _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"covergroup" { Token KW_covergroup _ _ }
|
|
|
|
|
"coverpoint" { Token KW_coverpoint _ _ }
|
|
|
|
|
"cross" { Token KW_cross _ _ }
|
|
|
|
|
"deassign" { Token KW_deassign _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"default" { Token KW_default _ _ }
|
2019-03-18 17:37:46 +01:00
|
|
|
"defparam" { Token KW_defparam _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"design" { Token KW_design _ _ }
|
2019-03-30 05:47:37 +01:00
|
|
|
"disable" { Token KW_disable _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"dist" { Token KW_dist _ _ }
|
2019-03-05 03:32:30 +01:00
|
|
|
"do" { Token KW_do _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"edge" { Token KW_edge _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"else" { Token KW_else _ _ }
|
|
|
|
|
"end" { Token KW_end _ _ }
|
|
|
|
|
"endcase" { Token KW_endcase _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"endchecker" { Token KW_endchecker _ _ }
|
|
|
|
|
"endclass" { Token KW_endclass _ _ }
|
|
|
|
|
"endclocking" { Token KW_endclocking _ _ }
|
|
|
|
|
"endconfig" { Token KW_endconfig _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"endfunction" { Token KW_endfunction _ _ }
|
|
|
|
|
"endgenerate" { Token KW_endgenerate _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"endgroup" { Token KW_endgroup _ _ }
|
2019-03-04 08:58:00 +01:00
|
|
|
"endinterface" { Token KW_endinterface _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"endmodule" { Token KW_endmodule _ _ }
|
2019-04-23 21:53:51 +02:00
|
|
|
"endpackage" { Token KW_endpackage _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"endprimitive" { Token KW_endprimitive _ _ }
|
|
|
|
|
"endprogram" { Token KW_endprogram _ _ }
|
|
|
|
|
"endproperty" { Token KW_endproperty _ _ }
|
|
|
|
|
"endspecify" { Token KW_endspecify _ _ }
|
|
|
|
|
"endsequence" { Token KW_endsequence _ _ }
|
|
|
|
|
"endtable" { Token KW_endtable _ _ }
|
2019-03-07 19:58:20 +01:00
|
|
|
"endtask" { Token KW_endtask _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"enum" { Token KW_enum _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"event" { Token KW_event _ _ }
|
|
|
|
|
"eventually" { Token KW_eventually _ _ }
|
|
|
|
|
"expect" { Token KW_expect _ _ }
|
2019-04-23 21:53:51 +02:00
|
|
|
"export" { Token KW_export _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"extends" { Token KW_extends _ _ }
|
2019-03-26 20:10:16 +01:00
|
|
|
"extern" { Token KW_extern _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"final" { Token KW_final _ _ }
|
2019-03-30 05:47:37 +01:00
|
|
|
"first_match" { Token KW_first_match _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"for" { Token KW_for _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"force" { Token KW_force _ _ }
|
|
|
|
|
"foreach" { Token KW_foreach _ _ }
|
2019-03-05 03:32:30 +01:00
|
|
|
"forever" { Token KW_forever _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"fork" { Token KW_fork _ _ }
|
|
|
|
|
"forkjoin" { Token KW_forkjoin _ _ }
|
2019-03-05 03:32:30 +01:00
|
|
|
"function" { Token KW_function _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"generate" { Token KW_generate _ _ }
|
|
|
|
|
"genvar" { Token KW_genvar _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"global" { Token KW_global _ _ }
|
|
|
|
|
"highz0" { Token KW_highz0 _ _ }
|
|
|
|
|
"highz1" { Token KW_highz1 _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"if" { Token KW_if _ _ }
|
2019-03-30 05:47:37 +01:00
|
|
|
"iff" { Token KW_iff _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"ifnone" { Token KW_ifnone _ _ }
|
|
|
|
|
"ignore_bins" { Token KW_ignore_bins _ _ }
|
|
|
|
|
"illegal_bins" { Token KW_illegal_bins _ _ }
|
|
|
|
|
"implements" { Token KW_implements _ _ }
|
|
|
|
|
"implies" { Token KW_implies _ _ }
|
2019-04-23 21:53:51 +02:00
|
|
|
"import" { Token KW_import _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"incdir" { Token KW_incdir _ _ }
|
|
|
|
|
"include" { Token KW_include _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"initial" { Token KW_initial _ _ }
|
|
|
|
|
"inout" { Token KW_inout _ _ }
|
|
|
|
|
"input" { Token KW_input _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"inside" { Token KW_inside _ _ }
|
|
|
|
|
"instance" { Token KW_instance _ _ }
|
2019-03-22 21:57:13 +01:00
|
|
|
"int" { Token KW_int _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"integer" { Token KW_integer _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"interconnect" { Token KW_interconnect _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"interface" { Token KW_interface _ _ }
|
2019-03-30 05:47:37 +01:00
|
|
|
"intersect" { Token KW_intersect _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"join" { Token KW_join _ _ }
|
|
|
|
|
"join_any" { Token KW_join_any _ _ }
|
|
|
|
|
"join_none" { Token KW_join_none _ _ }
|
|
|
|
|
"large" { Token KW_large _ _ }
|
|
|
|
|
"let" { Token KW_let _ _ }
|
|
|
|
|
"liblist" { Token KW_liblist _ _ }
|
|
|
|
|
"library" { Token KW_library _ _ }
|
|
|
|
|
"local" { Token KW_local _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"localparam" { Token KW_localparam _ _ }
|
|
|
|
|
"logic" { Token KW_logic _ _ }
|
2019-03-22 21:57:13 +01:00
|
|
|
"longint" { Token KW_longint _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"macromodule" { Token KW_macromodule _ _ }
|
|
|
|
|
"matches" { Token KW_matches _ _ }
|
|
|
|
|
"medium" { Token KW_medium _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"modport" { Token KW_modport _ _ }
|
2019-03-05 03:32:30 +01:00
|
|
|
"module" { Token KW_module _ _ }
|
2019-03-22 06:31:43 +01:00
|
|
|
"nand" { Token KW_nand _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"negedge" { Token KW_negedge _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"nettype" { Token KW_nettype _ _ }
|
|
|
|
|
"new" { Token KW_new _ _ }
|
|
|
|
|
"nexttime" { Token KW_nexttime _ _ }
|
|
|
|
|
"nmos" { Token KW_nmos _ _ }
|
2019-03-22 06:31:43 +01:00
|
|
|
"nor" { Token KW_nor _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"noshowcancelled" { Token KW_noshowcancelled _ _ }
|
2019-03-22 06:31:43 +01:00
|
|
|
"not" { Token KW_not _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"notif0" { Token KW_notif0 _ _ }
|
|
|
|
|
"notif1" { Token KW_notif1 _ _ }
|
|
|
|
|
"null" { Token KW_null _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"or" { Token KW_or _ _ }
|
|
|
|
|
"output" { Token KW_output _ _ }
|
2019-04-23 21:53:51 +02:00
|
|
|
"package" { Token KW_package _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"packed" { Token KW_packed _ _ }
|
|
|
|
|
"parameter" { Token KW_parameter _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"pmos" { Token KW_pmos _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"posedge" { Token KW_posedge _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"primitive" { Token KW_primitive _ _ }
|
2019-03-30 05:47:37 +01:00
|
|
|
"priority" { Token KW_priority _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"program" { Token KW_program _ _ }
|
2019-03-30 05:47:37 +01:00
|
|
|
"property" { Token KW_property _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"protected" { Token KW_protected _ _ }
|
|
|
|
|
"pull0" { Token KW_pull0 _ _ }
|
|
|
|
|
"pull1" { Token KW_pull1 _ _ }
|
|
|
|
|
"pulldown" { Token KW_pulldown _ _ }
|
|
|
|
|
"pullup" { Token KW_pullup _ _ }
|
|
|
|
|
"pulsestyle_ondetect" { Token KW_pulsestyle_ondetect _ _ }
|
|
|
|
|
"pulsestyle_onevent" { Token KW_pulsestyle_onevent _ _ }
|
|
|
|
|
"pure" { Token KW_pure _ _ }
|
|
|
|
|
"rand" { Token KW_rand _ _ }
|
|
|
|
|
"randc" { Token KW_randc _ _ }
|
|
|
|
|
"randcase" { Token KW_randcase _ _ }
|
|
|
|
|
"randsequence" { Token KW_randsequence _ _ }
|
|
|
|
|
"rcmos" { Token KW_rcmos _ _ }
|
2019-03-22 21:57:13 +01:00
|
|
|
"real" { Token KW_real _ _ }
|
|
|
|
|
"realtime" { Token KW_realtime _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"ref" { Token KW_ref _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"reg" { Token KW_reg _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"reject_on" { Token KW_reject_on _ _ }
|
|
|
|
|
"release" { Token KW_release _ _ }
|
2019-03-05 03:32:30 +01:00
|
|
|
"repeat" { Token KW_repeat _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"restrict" { Token KW_restrict _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"return" { Token KW_return _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"rnmos" { Token KW_rnmos _ _ }
|
|
|
|
|
"rpmos" { Token KW_rpmos _ _ }
|
|
|
|
|
"rtran" { Token KW_rtran _ _ }
|
|
|
|
|
"rtranif0" { Token KW_rtranif0 _ _ }
|
|
|
|
|
"rtranif1" { Token KW_rtranif1 _ _ }
|
|
|
|
|
"s_always" { Token KW_s_always _ _ }
|
|
|
|
|
"s_eventually" { Token KW_s_eventually _ _ }
|
|
|
|
|
"s_nexttime" { Token KW_s_nexttime _ _ }
|
|
|
|
|
"s_until" { Token KW_s_until _ _ }
|
|
|
|
|
"s_until_with" { Token KW_s_until_with _ _ }
|
|
|
|
|
"scalared" { Token KW_scalared _ _ }
|
|
|
|
|
"sequence" { Token KW_sequence _ _ }
|
2019-03-22 21:57:13 +01:00
|
|
|
"shortint" { Token KW_shortint _ _ }
|
|
|
|
|
"shortreal" { Token KW_shortreal _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"showcancelled" { Token KW_showcancelled _ _ }
|
2019-03-22 21:57:13 +01:00
|
|
|
"signed" { Token KW_signed _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"small" { Token KW_small _ _ }
|
|
|
|
|
"soft" { Token KW_soft _ _ }
|
|
|
|
|
"solve" { Token KW_solve _ _ }
|
|
|
|
|
"specify" { Token KW_specify _ _ }
|
|
|
|
|
"specparam" { Token KW_specparam _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"static" { Token KW_static _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"string" { Token KW_string _ _ }
|
|
|
|
|
"strong" { Token KW_strong _ _ }
|
|
|
|
|
"strong0" { Token KW_strong0 _ _ }
|
|
|
|
|
"strong1" { Token KW_strong1 _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"struct" { Token KW_struct _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"super" { Token KW_super _ _ }
|
2019-03-22 21:57:13 +01:00
|
|
|
"supply0" { Token KW_supply0 _ _ }
|
|
|
|
|
"supply1" { Token KW_supply1 _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"sync_accept_on" { Token KW_sync_accept_on _ _ }
|
|
|
|
|
"sync_reject_on" { Token KW_sync_reject_on _ _ }
|
|
|
|
|
"table" { Token KW_table _ _ }
|
|
|
|
|
"tagged" { Token KW_tagged _ _ }
|
2019-03-07 19:58:20 +01:00
|
|
|
"task" { Token KW_task _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"this" { Token KW_this _ _ }
|
2019-03-30 05:47:37 +01:00
|
|
|
"throughout" { Token KW_throughout _ _ }
|
2019-03-22 21:57:13 +01:00
|
|
|
"time" { Token KW_time _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"timeprecision" { Token KW_timeprecision _ _ }
|
|
|
|
|
"timeunit" { Token KW_timeunit _ _ }
|
|
|
|
|
"tran" { Token KW_tran _ _ }
|
|
|
|
|
"tranif0" { Token KW_tranif0 _ _ }
|
|
|
|
|
"tranif1" { Token KW_tranif1 _ _ }
|
2019-03-22 21:57:13 +01:00
|
|
|
"tri" { Token KW_tri _ _ }
|
|
|
|
|
"tri0" { Token KW_tri0 _ _ }
|
|
|
|
|
"tri1" { Token KW_tri1 _ _ }
|
|
|
|
|
"triand" { Token KW_triand _ _ }
|
|
|
|
|
"trior" { Token KW_trior _ _ }
|
|
|
|
|
"trireg" { Token KW_trireg _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"type" { Token KW_type _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"typedef" { Token KW_typedef _ _ }
|
2019-08-09 05:12:06 +02:00
|
|
|
"union" { Token KW_union _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"unique" { Token KW_unique _ _ }
|
2019-03-30 05:47:37 +01:00
|
|
|
"unique0" { Token KW_unique0 _ _ }
|
2019-03-22 21:57:13 +01:00
|
|
|
"unsigned" { Token KW_unsigned _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"until" { Token KW_until _ _ }
|
|
|
|
|
"until_with" { Token KW_until_with _ _ }
|
|
|
|
|
"untyped" { Token KW_untyped _ _ }
|
|
|
|
|
"use" { Token KW_use _ _ }
|
2019-03-22 21:57:13 +01:00
|
|
|
"uwire" { Token KW_uwire _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"var" { Token KW_var _ _ }
|
|
|
|
|
"vectored" { Token KW_vectored _ _ }
|
|
|
|
|
"virtual" { Token KW_virtual _ _ }
|
|
|
|
|
"void" { Token KW_void _ _ }
|
|
|
|
|
"wait" { Token KW_wait _ _ }
|
|
|
|
|
"wait_order" { Token KW_wait_order _ _ }
|
2019-03-22 21:57:13 +01:00
|
|
|
"wand" { Token KW_wand _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"weak" { Token KW_weak _ _ }
|
|
|
|
|
"weak0" { Token KW_weak0 _ _ }
|
|
|
|
|
"weak1" { Token KW_weak1 _ _ }
|
2019-03-05 03:32:30 +01:00
|
|
|
"while" { Token KW_while _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"wildcard" { Token KW_wildcard _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"wire" { Token KW_wire _ _ }
|
2019-09-05 03:02:02 +02:00
|
|
|
"with" { Token KW_with _ _ }
|
2019-03-30 05:47:37 +01:00
|
|
|
"within" { Token KW_within _ _ }
|
2019-03-22 21:57:13 +01:00
|
|
|
"wor" { Token KW_wor _ _ }
|
2019-03-22 06:31:43 +01:00
|
|
|
"xnor" { Token KW_xnor _ _ }
|
|
|
|
|
"xor" { Token KW_xor _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
|
|
|
|
|
simpleIdentifier { Token Id_simple _ _ }
|
|
|
|
|
escapedIdentifier { Token Id_escaped _ _ }
|
|
|
|
|
systemIdentifier { Token Id_system _ _ }
|
2020-07-12 23:06:27 +02:00
|
|
|
real { Token Lit_real _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
number { Token Lit_number _ _ }
|
|
|
|
|
string { Token Lit_string _ _ }
|
2019-09-12 03:44:57 +02:00
|
|
|
time { Token Lit_time _ _ }
|
2020-02-07 05:27:51 +01:00
|
|
|
|
|
|
|
|
"`celldefine" { Token Dir_celldefine _ _ }
|
|
|
|
|
"`endcelldefine" { Token Dir_endcelldefine _ _ }
|
|
|
|
|
"`unconnected_drive" { Token Dir_unconnected_drive _ _ }
|
|
|
|
|
"`nounconnected_drive" { Token Dir_nounconnected_drive _ _ }
|
|
|
|
|
"`default_nettype" { Token Dir_default_nettype _ _ }
|
|
|
|
|
"`resetall" { Token Dir_resetall _ _ }
|
|
|
|
|
"`begin_keywords" { Token Dir_begin_keywords _ _ }
|
|
|
|
|
"`end_keywords" { Token Dir_end_keywords _ _ }
|
2019-02-08 05:49:12 +01:00
|
|
|
|
|
|
|
|
"(" { Token Sym_paren_l _ _ }
|
|
|
|
|
")" { Token Sym_paren_r _ _ }
|
|
|
|
|
"[" { Token Sym_brack_l _ _ }
|
|
|
|
|
"]" { Token Sym_brack_r _ _ }
|
|
|
|
|
"{" { Token Sym_brace_l _ _ }
|
|
|
|
|
"}" { Token Sym_brace_r _ _ }
|
|
|
|
|
"~" { Token Sym_tildy _ _ }
|
|
|
|
|
"!" { Token Sym_bang _ _ }
|
|
|
|
|
"@" { Token Sym_at _ _ }
|
|
|
|
|
"#" { Token Sym_pound _ _ }
|
|
|
|
|
"%" { Token Sym_percent _ _ }
|
|
|
|
|
"^" { Token Sym_hat _ _ }
|
|
|
|
|
"&" { Token Sym_amp _ _ }
|
|
|
|
|
"|" { Token Sym_bar _ _ }
|
|
|
|
|
"*" { Token Sym_aster _ _ }
|
|
|
|
|
"." { Token Sym_dot _ _ }
|
|
|
|
|
"," { Token Sym_comma _ _ }
|
|
|
|
|
":" { Token Sym_colon _ _ }
|
|
|
|
|
";" { Token Sym_semi _ _ }
|
|
|
|
|
"=" { Token Sym_eq _ _ }
|
|
|
|
|
"<" { Token Sym_lt _ _ }
|
|
|
|
|
">" { Token Sym_gt _ _ }
|
|
|
|
|
"+" { Token Sym_plus _ _ }
|
|
|
|
|
"-" { Token Sym_dash _ _ }
|
|
|
|
|
"?" { Token Sym_question _ _ }
|
|
|
|
|
"/" { Token Sym_slash _ _ }
|
|
|
|
|
"$" { Token Sym_dollar _ _ }
|
|
|
|
|
"'" { Token Sym_s_quote _ _ }
|
|
|
|
|
"~&" { Token Sym_tildy_amp _ _ }
|
|
|
|
|
"~|" { Token Sym_tildy_bar _ _ }
|
|
|
|
|
"~^" { Token Sym_tildy_hat _ _ }
|
|
|
|
|
"^~" { Token Sym_hat_tildy _ _ }
|
|
|
|
|
"==" { Token Sym_eq_eq _ _ }
|
|
|
|
|
"!=" { Token Sym_bang_eq _ _ }
|
|
|
|
|
"&&" { Token Sym_amp_amp _ _ }
|
|
|
|
|
"||" { Token Sym_bar_bar _ _ }
|
|
|
|
|
"**" { Token Sym_aster_aster _ _ }
|
|
|
|
|
"<=" { Token Sym_lt_eq _ _ }
|
|
|
|
|
">=" { Token Sym_gt_eq _ _ }
|
|
|
|
|
">>" { Token Sym_gt_gt _ _ }
|
|
|
|
|
"<<" { Token Sym_lt_lt _ _ }
|
|
|
|
|
"++" { Token Sym_plus_plus _ _ }
|
|
|
|
|
"--" { Token Sym_dash_dash _ _ }
|
|
|
|
|
"+=" { Token Sym_plus_eq _ _ }
|
|
|
|
|
"-=" { Token Sym_dash_eq _ _ }
|
|
|
|
|
"*=" { Token Sym_aster_eq _ _ }
|
|
|
|
|
"/=" { Token Sym_slash_eq _ _ }
|
|
|
|
|
"%=" { Token Sym_percent_eq _ _ }
|
|
|
|
|
"&=" { Token Sym_amp_eq _ _ }
|
|
|
|
|
"|=" { Token Sym_bar_eq _ _ }
|
|
|
|
|
"^=" { Token Sym_hat_eq _ _ }
|
|
|
|
|
"+:" { Token Sym_plus_colon _ _ }
|
|
|
|
|
"-:" { Token Sym_dash_colon _ _ }
|
|
|
|
|
"::" { Token Sym_colon_colon _ _ }
|
|
|
|
|
".*" { Token Sym_dot_aster _ _ }
|
|
|
|
|
"->" { Token Sym_dash_gt _ _ }
|
|
|
|
|
":=" { Token Sym_colon_eq _ _ }
|
|
|
|
|
":/" { Token Sym_colon_slash _ _ }
|
|
|
|
|
"##" { Token Sym_pound_pound _ _ }
|
|
|
|
|
"[*" { Token Sym_brack_l_aster _ _ }
|
|
|
|
|
"[=" { Token Sym_brack_l_eq _ _ }
|
|
|
|
|
"=>" { Token Sym_eq_gt _ _ }
|
|
|
|
|
"@*" { Token Sym_at_aster _ _ }
|
|
|
|
|
"(*" { Token Sym_paren_l_aster _ _ }
|
|
|
|
|
"*)" { Token Sym_aster_paren_r _ _ }
|
|
|
|
|
"*>" { Token Sym_aster_gt _ _ }
|
|
|
|
|
"===" { Token Sym_eq_eq_eq _ _ }
|
|
|
|
|
"!==" { Token Sym_bang_eq_eq _ _ }
|
2019-03-05 00:25:14 +01:00
|
|
|
"==?" { Token Sym_eq_eq_question _ _ }
|
|
|
|
|
"!=?" { Token Sym_bang_eq_question _ _ }
|
2019-02-08 05:49:12 +01:00
|
|
|
">>>" { Token Sym_gt_gt_gt _ _ }
|
|
|
|
|
"<<<" { Token Sym_lt_lt_lt _ _ }
|
|
|
|
|
"<<=" { Token Sym_lt_lt_eq _ _ }
|
|
|
|
|
">>=" { Token Sym_gt_gt_eq _ _ }
|
2019-09-15 19:55:40 +02:00
|
|
|
"<->" { Token Sym_lt_dash_gt _ _ }
|
2019-02-08 05:49:12 +01:00
|
|
|
"|->" { Token Sym_bar_dash_gt _ _ }
|
|
|
|
|
"|=>" { Token Sym_bar_eq_gt _ _ }
|
|
|
|
|
"[->" { Token Sym_brack_l_dash_gt _ _ }
|
2019-03-30 05:47:37 +01:00
|
|
|
"#-#" { Token Sym_pound_dash_pound _ _ }
|
|
|
|
|
"#=#" { Token Sym_pound_eq_pound _ _ }
|
2019-02-08 05:49:12 +01:00
|
|
|
"@@(" { Token Sym_at_at_paren_l _ _ }
|
|
|
|
|
"(*)" { Token Sym_paren_l_aster_paren_r _ _ }
|
|
|
|
|
"->>" { Token Sym_dash_gt_gt _ _ }
|
|
|
|
|
"&&&" { Token Sym_amp_amp_amp _ _ }
|
|
|
|
|
"<<<=" { Token Sym_lt_lt_lt_eq _ _ }
|
|
|
|
|
">>>=" { Token Sym_gt_gt_gt_eq _ _ }
|
|
|
|
|
|
2019-03-18 10:00:23 +01:00
|
|
|
|
2019-03-05 00:25:14 +01:00
|
|
|
-- operator precedences, from *lowest* to *highest*
|
2021-07-02 23:59:21 +02:00
|
|
|
%nonassoc DefaultStrength
|
|
|
|
|
%nonassoc DriveStrength ChargeStrength
|
2019-02-08 05:49:12 +01:00
|
|
|
%nonassoc NoElse
|
|
|
|
|
%nonassoc "else"
|
2019-03-30 05:47:37 +01:00
|
|
|
%right "|->" "|=>" "#-#" "#=#"
|
|
|
|
|
%right "iff"
|
|
|
|
|
%left "or"
|
|
|
|
|
%left "and"
|
|
|
|
|
%left "intersect"
|
|
|
|
|
%left "within"
|
|
|
|
|
%right "throughout"
|
|
|
|
|
%left "##"
|
|
|
|
|
%nonassoc "[*]" "[=]" "[->]"
|
2019-09-15 19:55:40 +02:00
|
|
|
%right "->" "<->"
|
2019-02-08 05:49:12 +01:00
|
|
|
%right "?" ":"
|
|
|
|
|
%left "||"
|
|
|
|
|
%left "&&"
|
|
|
|
|
%left "|" "~|"
|
2019-03-30 06:33:49 +01:00
|
|
|
%left "^" "^~" "~^"
|
2019-02-08 05:49:12 +01:00
|
|
|
%left "&" "~&"
|
2019-03-05 00:25:14 +01:00
|
|
|
%left "==" "!=" "===" "!==" "==?" "!=?"
|
2019-09-05 03:36:50 +02:00
|
|
|
%left "<" "<=" ">" ">=" "inside" "dist"
|
2019-02-18 02:52:01 +01:00
|
|
|
%left "<<" ">>" "<<<" ">>>"
|
2019-02-08 05:49:12 +01:00
|
|
|
%left "+" "-"
|
|
|
|
|
%left "*" "/" "%"
|
2019-03-05 00:25:14 +01:00
|
|
|
%left "**"
|
2019-03-23 00:24:45 +01:00
|
|
|
%right REDUCE_OP "!" "~" "++" "--"
|
2020-02-15 22:40:50 +01:00
|
|
|
%left "'"
|
2020-07-09 01:46:37 +02:00
|
|
|
%left "(" ")" "[" "]" "." "::" "#"
|
2019-02-08 05:49:12 +01:00
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
2020-04-05 19:40:44 +02:00
|
|
|
opt(p)
|
2019-02-10 00:35:15 +01:00
|
|
|
: p { Just $1 }
|
|
|
|
|
| { Nothing }
|
|
|
|
|
|
2019-02-18 09:59:17 +01:00
|
|
|
Descriptions :: { [Description] }
|
2019-03-07 19:19:31 +01:00
|
|
|
: {- empty -} { [] }
|
|
|
|
|
| Descriptions ";" { $1 }
|
2019-04-23 23:12:56 +02:00
|
|
|
| Descriptions Description { $1 ++ $2 }
|
2019-02-08 05:49:12 +01:00
|
|
|
|
2019-04-23 23:12:56 +02:00
|
|
|
Description :: { [Description] }
|
2021-03-06 21:03:04 +01:00
|
|
|
: Part(ModuleKW , endmodule ) { [$1] }
|
|
|
|
|
| Part(InterfaceKW, endinterface) { [$1] }
|
|
|
|
|
| PackageDeclaration { [$1] }
|
2021-07-12 02:43:30 +02:00
|
|
|
| PITrace PackageItem { map PackageItem $ addPITrace $1 $2 }
|
2019-02-18 09:59:17 +01:00
|
|
|
|
2021-01-21 20:02:03 +01:00
|
|
|
OptAsgn :: { Expr }
|
|
|
|
|
: {- empty -} { Nil }
|
|
|
|
|
| "=" Expr { $2 }
|
|
|
|
|
|
2019-02-18 09:59:17 +01:00
|
|
|
Type :: { Type }
|
2019-04-03 19:45:43 +02:00
|
|
|
: TypeNonIdent { $1 }
|
2020-07-09 01:46:37 +02:00
|
|
|
| TypeAlias { $1 }
|
|
|
|
|
TypeAlias :: { Type }
|
|
|
|
|
: Identifier Dimensions { Alias $1 $2 }
|
|
|
|
|
| Identifier "::" Identifier Dimensions { PSAlias $1 $3 $4 }
|
|
|
|
|
| Identifier ParamBindings "::" Identifier Dimensions { CSAlias $1 $2 $4 $5 }
|
2019-04-03 19:45:43 +02:00
|
|
|
TypeNonIdent :: { Type }
|
|
|
|
|
: PartialType OptSigning Dimensions { $1 $2 $3 }
|
2020-01-11 22:22:07 +01:00
|
|
|
| "type" "(" Expr ")" { TypeOf $3 }
|
2019-03-22 21:57:13 +01:00
|
|
|
PartialType :: { Signing -> [Range] -> Type }
|
2021-07-03 19:23:33 +02:00
|
|
|
: PartialTypeP { snd $1 }
|
|
|
|
|
PartialTypeP :: { (Position, Signing -> [Range] -> Type) }
|
|
|
|
|
: IntegerVectorTypeP { (fst $1, makeIntegerVector $1) }
|
|
|
|
|
| IntegerAtomTypeP { (fst $1, makeIntegerAtom $1) }
|
|
|
|
|
| NonIntegerTypeP { (fst $1, makeNonInteger $1) }
|
|
|
|
|
| "enum" EnumBaseType "{" EnumItems "}" { makeComplex $1 $ Enum $2 $4 }
|
|
|
|
|
| "struct" Packing "{" StructItems "}" { makeComplex $1 $ Struct $2 $4 }
|
|
|
|
|
| "union" Packing "{" StructItems "}" { makeComplex $1 $ Union $2 $4 }
|
2019-03-22 21:57:13 +01:00
|
|
|
CastingType :: { Type }
|
2021-07-03 19:23:33 +02:00
|
|
|
: IntegerVectorTypeP { IntegerVector (snd $1) Unspecified [] }
|
|
|
|
|
| IntegerAtomTypeP { IntegerAtom (snd $1) Unspecified }
|
|
|
|
|
| NonIntegerTypeP { NonInteger (snd $1) }
|
|
|
|
|
| SigningP { Implicit (snd $1) [] }
|
2020-06-05 02:19:21 +02:00
|
|
|
EnumBaseType :: { Type }
|
|
|
|
|
: Type { $1 }
|
|
|
|
|
| Dimensions { Implicit Unspecified $1 }
|
2019-03-22 21:57:13 +01:00
|
|
|
|
|
|
|
|
Signing :: { Signing }
|
2021-07-03 19:23:33 +02:00
|
|
|
: SigningP { snd $1 }
|
|
|
|
|
SigningP :: { (Position, Signing) }
|
|
|
|
|
: "signed" { withPos $1 Signed }
|
|
|
|
|
| "unsigned" { withPos $1 Unsigned }
|
2019-04-03 19:45:43 +02:00
|
|
|
OptSigning :: { Signing }
|
|
|
|
|
: Signing { $1 }
|
|
|
|
|
| {- empty -} { Unspecified }
|
2019-03-22 21:57:13 +01:00
|
|
|
|
2021-07-03 19:23:33 +02:00
|
|
|
NetTypeP :: { (Position, NetType) }
|
|
|
|
|
: "supply0" { withPos $1 TSupply0 }
|
|
|
|
|
| "supply1" { withPos $1 TSupply1 }
|
|
|
|
|
| "tri" { withPos $1 TTri }
|
|
|
|
|
| "triand" { withPos $1 TTriand }
|
|
|
|
|
| "trior" { withPos $1 TTrior }
|
|
|
|
|
| "trireg" { withPos $1 TTrireg }
|
|
|
|
|
| "tri0" { withPos $1 TTri0 }
|
|
|
|
|
| "tri1" { withPos $1 TTri1 }
|
|
|
|
|
| "uwire" { withPos $1 TUwire }
|
|
|
|
|
| "wire" { withPos $1 TWire }
|
|
|
|
|
| "wand" { withPos $1 TWand }
|
|
|
|
|
| "wor" { withPos $1 TWor }
|
|
|
|
|
IntegerVectorTypeP :: { (Position, IntegerVectorType) }
|
|
|
|
|
: "bit" { withPos $1 TBit }
|
|
|
|
|
| "logic" { withPos $1 TLogic }
|
|
|
|
|
| "reg" { withPos $1 TReg }
|
|
|
|
|
IntegerAtomTypeP :: { (Position, IntegerAtomType) }
|
|
|
|
|
: "byte" { withPos $1 TByte }
|
|
|
|
|
| "shortint" { withPos $1 TShortint }
|
|
|
|
|
| "int" { withPos $1 TInt }
|
|
|
|
|
| "longint" { withPos $1 TLongint }
|
|
|
|
|
| "integer" { withPos $1 TInteger }
|
|
|
|
|
| "time" { withPos $1 TTime }
|
|
|
|
|
NonIntegerTypeP :: { (Position, NonIntegerType) }
|
|
|
|
|
: "shortreal" { withPos $1 TShortreal }
|
|
|
|
|
| "real" { withPos $1 TReal }
|
|
|
|
|
| "realtime" { withPos $1 TRealtime }
|
|
|
|
|
| "string" { withPos $1 TString }
|
|
|
|
|
| "event" { withPos $1 TEvent }
|
2019-02-18 09:59:17 +01:00
|
|
|
|
2020-06-14 21:56:09 +02:00
|
|
|
EnumItems :: { [(Identifier, Expr)] }
|
2019-03-02 02:26:44 +01:00
|
|
|
: VariablePortIdentifiers { $1 }
|
|
|
|
|
|
|
|
|
|
StructItems :: { [(Type, Identifier)] }
|
2019-03-29 21:48:58 +01:00
|
|
|
: StructItem { $1 }
|
|
|
|
|
| StructItems StructItem { $1 ++ $2 }
|
|
|
|
|
StructItem :: { [(Type, Identifier)] }
|
2019-10-14 05:59:21 +02:00
|
|
|
: Type FieldDecls ";" { map (fieldDecl $1) $2 }
|
|
|
|
|
|
|
|
|
|
FieldDecls :: { [(Identifier, [Range])] }
|
|
|
|
|
: FieldDecl { [$1] }
|
|
|
|
|
| FieldDecls "," FieldDecl { $1 ++ [$3] }
|
|
|
|
|
FieldDecl :: { (Identifier, [Range]) }
|
|
|
|
|
: Identifier Dimensions { ($1, $2) }
|
2019-03-02 02:26:44 +01:00
|
|
|
|
2019-03-22 21:57:13 +01:00
|
|
|
Packing :: { Packing }
|
2019-04-03 19:45:43 +02:00
|
|
|
: "packed" OptSigning { Packed $2 }
|
|
|
|
|
| {- empty -} { Unpacked }
|
2019-03-02 02:26:44 +01:00
|
|
|
|
2019-03-26 20:10:16 +01:00
|
|
|
Part(begin, end) :: { Description }
|
2021-06-15 23:47:32 +02:00
|
|
|
: AttributeInstances begin PartHeader ModuleItems end StrTag {% $3 $1 False $2 $4 $6 }
|
|
|
|
|
| AttributeInstances "extern" begin PartHeader {% $4 $1 True $3 [] "" }
|
2019-09-16 05:17:14 +02:00
|
|
|
|
2021-06-15 23:47:32 +02:00
|
|
|
PartHeader :: { [Attr] -> Bool -> PartKW -> [ModuleItem] -> Identifier -> ParseState Description }
|
|
|
|
|
: Lifetime Identifier PackageImportDeclarations Params PortDecls ";"
|
|
|
|
|
{ \attrs extern kw items label -> checkTag $2 label $ Part attrs extern kw $1 $2 (fst $5) ($3 ++ $4 ++ (snd $5) ++ items) }
|
2019-03-26 20:10:16 +01:00
|
|
|
|
|
|
|
|
ModuleKW :: { PartKW }
|
|
|
|
|
: "module" { Module }
|
2020-02-01 22:45:33 +01:00
|
|
|
| "macromodule" { Module }
|
2019-03-26 20:10:16 +01:00
|
|
|
InterfaceKW :: { PartKW }
|
|
|
|
|
: "interface" { Interface }
|
2019-03-04 08:58:00 +01:00
|
|
|
|
2019-04-23 21:53:51 +02:00
|
|
|
PackageDeclaration :: { Description }
|
2021-06-15 23:47:32 +02:00
|
|
|
: "package" Lifetime Identifier ";" PackageItems endpackage StrTag {% checkTag $3 $7 $ Package $2 $3 $5 }
|
2021-06-25 06:15:46 +02:00
|
|
|
| "class" Lifetime Identifier PIParams ";" ClassItems endclass StrTag {% checkTag $3 $8 $ Class $2 $3 $4 $6 }
|
2019-02-11 20:07:46 +01:00
|
|
|
|
2019-10-01 05:03:55 +02:00
|
|
|
StrTag :: { Identifier }
|
|
|
|
|
: {- empty -} { "" }
|
|
|
|
|
| ":" Identifier { $2 }
|
|
|
|
|
|
2019-08-04 03:50:26 +02:00
|
|
|
PackageImportDeclarations :: { [ModuleItem] }
|
|
|
|
|
: PackageImportDeclaration PackageImportDeclarations { $1 ++ $2 }
|
|
|
|
|
| {- empty -} { [] }
|
|
|
|
|
|
|
|
|
|
PackageImportDeclaration :: { [ModuleItem] }
|
|
|
|
|
: "import" PackageImportItems ";" { map (MIPackageItem . uncurry Import) $2 }
|
|
|
|
|
|
2019-02-11 20:07:46 +01:00
|
|
|
Params :: { [ModuleItem] }
|
2021-03-23 01:01:38 +01:00
|
|
|
: PIParams { map (MIPackageItem . Decl) $1 }
|
|
|
|
|
PIParams :: { [Decl] }
|
2019-08-07 01:53:19 +02:00
|
|
|
: {- empty -} { [] }
|
2020-03-26 04:55:15 +01:00
|
|
|
| "#" "(" ")" { [] }
|
2021-03-23 01:01:38 +01:00
|
|
|
| "#" "(" ParamsFollow { $3 }
|
2019-08-07 01:53:19 +02:00
|
|
|
ParamsFollow :: { [Decl] }
|
2021-07-12 02:43:30 +02:00
|
|
|
: ParamAsgn ParamsEnd { $1 }
|
|
|
|
|
| ParamAsgn "," ParamsFollow { $1 ++ $3 }
|
2019-09-18 01:48:08 +02:00
|
|
|
| ParamsDecl { $1 }
|
|
|
|
|
ParamsDecl :: { [Decl] }
|
2021-04-23 22:06:57 +02:00
|
|
|
: ModuleParameterDecl(ParamsEnd) { $1 }
|
2019-10-02 04:02:30 +02:00
|
|
|
| ModuleParameterDecl(",") ParamsDecl { $1 ++ $2 }
|
2021-07-12 02:43:30 +02:00
|
|
|
ParamAsgn :: { [Decl] }
|
|
|
|
|
: DeclTrace Identifier "=" Expr { [$1, Param Parameter (Implicit Unspecified []) $2 $4] }
|
2021-04-23 22:06:57 +02:00
|
|
|
ParamsEnd
|
|
|
|
|
: ")" {}
|
|
|
|
|
| "," ")" {}
|
2019-02-08 05:49:12 +01:00
|
|
|
|
2019-03-04 08:58:00 +01:00
|
|
|
PortDecls :: { ([Identifier], [ModuleItem]) }
|
2020-08-09 04:43:47 +02:00
|
|
|
: "(" PortDeclTokens(")") { parseDTsAsPortDecls $2 }
|
|
|
|
|
| "(" ")" { ([], []) }
|
|
|
|
|
| {- empty -} { ([], []) }
|
2019-03-04 08:58:00 +01:00
|
|
|
|
|
|
|
|
ModportItems :: { [(Identifier, [ModportDecl])] }
|
|
|
|
|
: ModportItem { [$1] }
|
|
|
|
|
| ModportItems "," ModportItem { $1 ++ [$3] }
|
|
|
|
|
ModportItem :: { (Identifier, [ModportDecl]) }
|
|
|
|
|
: Identifier "(" ModportPortsDeclarations { ($1, $3) }
|
|
|
|
|
ModportPortsDeclarations :: { [ModportDecl] }
|
|
|
|
|
: ModportPortsDeclaration(")") { $1 }
|
|
|
|
|
| ModportPortsDeclaration(",") ModportPortsDeclarations { $1 ++ $2 }
|
|
|
|
|
ModportPortsDeclaration(delim) :: { [ModportDecl] }
|
|
|
|
|
: ModportSimplePortsDeclaration(delim) { $1 }
|
|
|
|
|
ModportSimplePortsDeclaration(delim) :: { [ModportDecl] }
|
2020-08-09 04:43:47 +02:00
|
|
|
: Direction ModportSimplePorts delim { map (\(a, b) -> ($1, a, b)) $2 }
|
2020-06-14 21:56:09 +02:00
|
|
|
ModportSimplePorts :: { [(Identifier, Expr)] }
|
2019-03-04 08:58:00 +01:00
|
|
|
: ModportSimplePort { [$1] }
|
|
|
|
|
| ModportSimplePorts "," ModportSimplePort { $1 ++ [$3] }
|
2020-06-14 21:56:09 +02:00
|
|
|
ModportSimplePort :: { (Identifier, Expr) }
|
|
|
|
|
: "." Identifier "(" ExprOrNil ")" { ($2, $4) }
|
|
|
|
|
| Identifier { ($1, Ident $1) }
|
2019-03-04 08:58:00 +01:00
|
|
|
|
2019-02-08 05:49:12 +01:00
|
|
|
Identifier :: { Identifier }
|
2021-07-03 19:23:33 +02:00
|
|
|
: IdentifierP { snd $1 }
|
|
|
|
|
IdentifierP :: { (Position, Identifier) }
|
|
|
|
|
: simpleIdentifier { withPos $1 $ tokenString $1 }
|
|
|
|
|
| escapedIdentifier { withPos $1 $ tokenString $1 }
|
|
|
|
|
| systemIdentifier { withPos $1 $ tokenString $1 }
|
2019-02-08 05:49:12 +01:00
|
|
|
|
2019-02-10 00:35:15 +01:00
|
|
|
Identifiers :: { [Identifier] }
|
|
|
|
|
: Identifier { [$1] }
|
|
|
|
|
| Identifiers "," Identifier { $1 ++ [$3] }
|
|
|
|
|
|
2021-07-02 23:59:21 +02:00
|
|
|
Strength :: { Strength }
|
|
|
|
|
: {- empty -} %prec DefaultStrength { DefaultStrength }
|
|
|
|
|
| DriveStrength %prec DriveStrength { uncurry DriveStrength $1 }
|
|
|
|
|
| ChargeStrength %prec ChargeStrength { ChargeStrength $1 }
|
|
|
|
|
|
2019-03-04 08:58:00 +01:00
|
|
|
-- uses delimiter propagation hack to avoid conflicts
|
|
|
|
|
DeclTokens(delim) :: { [DeclToken] }
|
2020-08-09 04:43:47 +02:00
|
|
|
: DeclTokensBase(DeclTokens(delim), delim) { $1 }
|
|
|
|
|
DeclTokensBase(repeat, delim) :: { [DeclToken] }
|
2021-07-06 00:00:12 +02:00
|
|
|
: DeclToken DTDelim(delim) { [$1, $2] }
|
2021-07-03 19:23:33 +02:00
|
|
|
| DeclToken repeat { [$1] ++ $2 }
|
|
|
|
|
| IdentifierP ParamBindings repeat { [uncurry DTIdent $1, DTParams (fst $1) $2] ++ $3 }
|
|
|
|
|
| DeclTokenAsgn "," repeat { [$1, DTComma (tokenPosition $2)] ++ $3 }
|
2021-07-06 00:00:12 +02:00
|
|
|
| DeclTokenAsgn DTDelim(delim) { [$1, $2] }
|
2019-03-04 08:58:00 +01:00
|
|
|
DeclToken :: { DeclToken }
|
2021-07-03 19:23:33 +02:00
|
|
|
: "," { DTComma $ tokenPosition $1 }
|
|
|
|
|
| "[" "]" { DTAutoDim $ tokenPosition $1 }
|
|
|
|
|
| "const" { DTConst $ tokenPosition $1 }
|
|
|
|
|
| "var" { DTVar $ tokenPosition $1 }
|
2021-07-06 00:00:12 +02:00
|
|
|
| PartSelectP { uncurry (DTRange $ fst $1) (snd $1) }
|
2021-07-03 19:23:33 +02:00
|
|
|
| IdentifierP { uncurry DTIdent $1 }
|
|
|
|
|
| DirectionP { uncurry DTDir $1 }
|
2021-07-07 03:20:44 +02:00
|
|
|
| LHSConcatP { uncurry DTLHSBase $1 }
|
|
|
|
|
| LHSStreamP { uncurry DTLHSBase $1 }
|
2021-07-03 19:23:33 +02:00
|
|
|
| PartialTypeP { uncurry DTType $1 }
|
|
|
|
|
| NetTypeP Strength { uncurry DTNet $1 $2 }
|
|
|
|
|
| PortBindingsP { uncurry DTPorts $1 }
|
|
|
|
|
| SigningP { uncurry DTSigning $1 }
|
|
|
|
|
| "[" Expr "]" { DTBit (tokenPosition $1) $2 }
|
|
|
|
|
| "." Identifier { DTDot (tokenPosition $1) $2 }
|
|
|
|
|
| "automatic" { DTLifetime (tokenPosition $1) Automatic }
|
|
|
|
|
| "type" "(" Expr ")" { uncurry DTType $ makeTypeOf $1 $3 }
|
|
|
|
|
| IncOrDecOperatorP { DTAsgn (fst $1) (AsgnOp $ snd $1) Nothing (RawNum 1) }
|
|
|
|
|
| IdentifierP "::" Identifier { uncurry DTPSIdent $1 $3 }
|
|
|
|
|
| IdentifierP ParamBindings "::" Identifier { uncurry DTCSIdent $1 $2 $4 }
|
2021-07-06 00:00:12 +02:00
|
|
|
DTDelim(delim) :: { DeclToken }
|
|
|
|
|
: delim { DTEnd (tokenPosition $1) (head $ tokenString $1) }
|
2020-02-01 21:52:52 +01:00
|
|
|
DeclTokenAsgn :: { DeclToken }
|
2021-07-03 19:23:33 +02:00
|
|
|
: "=" opt(DelayOrEvent) Expr { DTAsgn (tokenPosition $1) AsgnOpEq $2 $3 }
|
|
|
|
|
| AsgnBinOpP Expr { uncurry DTAsgn $1 Nothing $2 }
|
2021-07-06 00:00:12 +02:00
|
|
|
| "<=" opt(DelayOrEvent) Expr { DTAsgn (tokenPosition $1) AsgnOpNonBlocking $2 $3 }
|
2020-08-09 04:43:47 +02:00
|
|
|
PortDeclTokens(delim) :: { [DeclToken] }
|
|
|
|
|
: DeclTokensBase(PortDeclTokens(delim), delim) { $1 }
|
|
|
|
|
| GenericInterfaceDecl PortDeclTokens(delim) { $1 ++ $2}
|
2021-07-06 00:00:12 +02:00
|
|
|
| GenericInterfaceDecl DTDelim(delim) { $1 ++ [$2] }
|
2021-07-03 19:23:33 +02:00
|
|
|
| AttributeInstanceP PortDeclTokens(delim) { uncurry DTAttr $1 : $2 }
|
2021-06-25 20:53:03 +02:00
|
|
|
ModuleDeclTokens(delim) :: { [DeclToken] }
|
|
|
|
|
: DeclTokensBase(ModuleDeclTokens(delim), delim) { $1 }
|
|
|
|
|
| GenericInterfaceDecl ModuleDeclTokens(delim) { $1 ++ $2}
|
2021-07-06 00:00:12 +02:00
|
|
|
| GenericInterfaceDecl DTDelim(delim) { $1 ++ [$2] }
|
2020-08-09 04:43:47 +02:00
|
|
|
GenericInterfaceDecl :: { [DeclToken] }
|
2021-07-03 19:23:33 +02:00
|
|
|
: "interface" IdentifierP { [DTType (tokenPosition $1) (\Unspecified -> InterfaceT "" ""), uncurry DTIdent $2] }
|
2019-03-02 02:26:44 +01:00
|
|
|
|
2020-06-14 21:56:09 +02:00
|
|
|
VariablePortIdentifiers :: { [(Identifier, Expr)] }
|
2019-02-10 00:35:15 +01:00
|
|
|
: VariablePortIdentifier { [$1] }
|
|
|
|
|
| VariablePortIdentifiers "," VariablePortIdentifier { $1 ++ [$3] }
|
2020-06-14 21:56:09 +02:00
|
|
|
VariablePortIdentifier :: { (Identifier, Expr) }
|
2021-01-21 20:02:03 +01:00
|
|
|
: Identifier OptAsgn { ($1,$2) }
|
2019-02-08 05:49:12 +01:00
|
|
|
|
2019-03-02 02:26:44 +01:00
|
|
|
Direction :: { Direction }
|
2021-07-03 19:23:33 +02:00
|
|
|
: DirectionP { snd $1 }
|
|
|
|
|
DirectionP :: { (Position, Direction) }
|
|
|
|
|
: "inout" { (tokenPosition $1, Inout ) }
|
|
|
|
|
| "input" { (tokenPosition $1, Input ) }
|
|
|
|
|
| "output" { (tokenPosition $1, Output) }
|
2019-03-02 02:26:44 +01:00
|
|
|
|
2019-02-08 05:49:12 +01:00
|
|
|
ModuleItems :: { [ModuleItem] }
|
2020-01-31 04:17:17 +01:00
|
|
|
: {- empty -} { [] }
|
2020-03-20 23:50:54 +01:00
|
|
|
| ";" ModuleItems { $2 }
|
2021-07-12 02:43:30 +02:00
|
|
|
| MITrace ModuleItem ModuleItems { addMITrace $1 ($2 ++ $3) }
|
2019-02-09 23:35:31 +01:00
|
|
|
|
|
|
|
|
ModuleItem :: { [ModuleItem] }
|
2019-04-23 20:38:44 +02:00
|
|
|
: NonGenerateModuleItem { $1 }
|
2021-03-06 21:03:04 +01:00
|
|
|
| ConditionalGenerateConstruct { [Generate [$1]] }
|
|
|
|
|
| LoopGenerateConstruct { [Generate [$1]] }
|
|
|
|
|
| "generate" GenItems endgenerate { [Generate $2] }
|
2019-04-23 20:38:44 +02:00
|
|
|
NonGenerateModuleItem :: { [ModuleItem] }
|
2019-03-04 08:58:00 +01:00
|
|
|
-- This item covers module instantiations and all declarations
|
2021-06-25 20:53:03 +02:00
|
|
|
: ModuleDeclTokens(";") { parseDTsAsModuleItems $1 }
|
2019-08-07 01:53:19 +02:00
|
|
|
| ParameterDecl(";") { map (MIPackageItem . Decl) $1 }
|
2019-10-04 01:37:42 +02:00
|
|
|
| "defparam" LHSAsgns ";" { map (uncurry Defparam) $2 }
|
2020-03-21 02:13:57 +01:00
|
|
|
| "assign" AssignOption LHSAsgns ";" { map (uncurry $ Assign $2) $3 }
|
2019-03-04 20:25:38 +01:00
|
|
|
| AlwaysKW Stmt { [AlwaysC $1 $2] }
|
2019-03-05 02:58:09 +01:00
|
|
|
| "initial" Stmt { [Initial $2] }
|
2019-11-01 01:39:11 +01:00
|
|
|
| "final" Stmt { [Final $2] }
|
2019-03-04 20:25:38 +01:00
|
|
|
| "genvar" Identifiers ";" { map Genvar $2 }
|
|
|
|
|
| "modport" ModportItems ";" { map (uncurry Modport) $2 }
|
2019-04-24 00:44:45 +02:00
|
|
|
| NonDeclPackageItem { map MIPackageItem $1 }
|
2021-06-25 06:15:46 +02:00
|
|
|
| TaskOrFunction { [MIPackageItem $1] }
|
2020-02-01 02:24:37 +01:00
|
|
|
| NInputGateKW NInputGates ";" { map (\(a, b, c, d) -> NInputGate $1 a b c d) $2 }
|
|
|
|
|
| NOutputGateKW NOutputGates ";" { map (\(a, b, c, d) -> NOutputGate $1 a b c d) $2 }
|
2021-02-17 19:35:10 +01:00
|
|
|
| AttributeInstance ModuleItem { map (addMIAttr $1) $2 }
|
2019-04-04 01:08:30 +02:00
|
|
|
| AssertionItem { [AssertionItem $1] }
|
2019-03-30 05:47:37 +01:00
|
|
|
|
2020-03-21 02:13:57 +01:00
|
|
|
AssignOption :: { AssignOption }
|
|
|
|
|
: {- empty -} { AssignOptionNone }
|
|
|
|
|
| DelayControl { AssignOptionDelay $1 }
|
2021-07-02 23:59:21 +02:00
|
|
|
| DriveStrength { uncurry AssignOptionDrive $1 }
|
2020-03-21 02:13:57 +01:00
|
|
|
|
2019-03-30 05:47:37 +01:00
|
|
|
-- for ModuleItem, for now
|
|
|
|
|
AssertionItem :: { AssertionItem }
|
|
|
|
|
: ConcurrentAssertionItem { $1 }
|
|
|
|
|
|
|
|
|
|
-- for Stmt, for now
|
|
|
|
|
ProceduralAssertionStatement :: { Assertion }
|
|
|
|
|
: ConcurrentAssertionStatement { $1 }
|
|
|
|
|
| ImmediateAssertionStatement { $1 }
|
|
|
|
|
|
|
|
|
|
ConcurrentAssertionItem :: { AssertionItem }
|
2020-06-10 03:18:31 +02:00
|
|
|
: Identifier ":" ConcurrentAssertionStatement { ($1, $3) }
|
|
|
|
|
| ConcurrentAssertionStatement { ("", $1) }
|
2019-03-30 05:47:37 +01:00
|
|
|
ConcurrentAssertionStatement :: { Assertion }
|
2019-04-04 01:08:30 +02:00
|
|
|
: "assert" "property" "(" PropertySpec ")" ActionBlock { Assert (Left $4) $6 }
|
|
|
|
|
| "assume" "property" "(" PropertySpec ")" ActionBlock { Assume (Left $4) $6 }
|
|
|
|
|
| "cover" "property" "(" PropertySpec ")" Stmt { Cover (Left $4) $6 }
|
2019-03-30 05:47:37 +01:00
|
|
|
|
|
|
|
|
ImmediateAssertionStatement :: { Assertion }
|
|
|
|
|
: SimpleImmediateAssertionStatement { $1 }
|
|
|
|
|
SimpleImmediateAssertionStatement :: { Assertion }
|
2019-04-04 01:08:30 +02:00
|
|
|
: "assert" "(" Expr ")" ActionBlock { Assert (Right $3) $5 }
|
|
|
|
|
| "assume" "(" Expr ")" ActionBlock { Assume (Right $3) $5 }
|
|
|
|
|
| "cover" "(" Expr ")" Stmt { Cover (Right $3) $5 }
|
2019-03-30 05:47:37 +01:00
|
|
|
|
|
|
|
|
PropertySpec :: { PropertySpec }
|
2020-06-14 21:56:09 +02:00
|
|
|
: opt(ClockingEvent) "disable" "iff" "(" Expr ")" PropExpr { PropertySpec $1 $5 $7 }
|
|
|
|
|
| opt(ClockingEvent) PropExpr { PropertySpec $1 Nil $2 }
|
2019-04-03 19:45:43 +02:00
|
|
|
|
|
|
|
|
PropExpr :: { PropExpr }
|
|
|
|
|
: SeqExpr { PropExpr $1 }
|
2019-04-04 01:08:30 +02:00
|
|
|
| PropExprParens { $1 }
|
|
|
|
|
PropExprParens :: { PropExpr }
|
|
|
|
|
: "(" PropExprParens ")" { $2 }
|
2019-04-03 19:45:43 +02:00
|
|
|
| SeqExpr "|->" PropExpr { PropExprImpliesO $1 $3 }
|
|
|
|
|
| SeqExpr "|=>" PropExpr { PropExprImpliesNO $1 $3 }
|
|
|
|
|
| SeqExpr "#-#" PropExpr { PropExprFollowsO $1 $3 }
|
|
|
|
|
| SeqExpr "#=#" PropExpr { PropExprFollowsNO $1 $3 }
|
|
|
|
|
| PropExpr "iff" PropExpr { PropExprIff $1 $3 }
|
2019-03-30 05:47:37 +01:00
|
|
|
SeqExpr :: { SeqExpr }
|
|
|
|
|
: Expr { SeqExpr $1 }
|
2019-04-04 01:08:30 +02:00
|
|
|
| SeqExprParens { $1 }
|
|
|
|
|
SeqExprParens :: { SeqExpr }
|
|
|
|
|
: "(" SeqExprParens ")" { $2 }
|
2019-03-30 05:47:37 +01:00
|
|
|
| SeqExpr "and" SeqExpr { SeqExprAnd $1 $3 }
|
|
|
|
|
| SeqExpr "or" SeqExpr { SeqExprOr $1 $3 }
|
|
|
|
|
| SeqExpr "intersect" SeqExpr { SeqExprIntersect $1 $3 }
|
|
|
|
|
| Expr "throughout" SeqExpr { SeqExprThroughout $1 $3 }
|
|
|
|
|
| SeqExpr "within" SeqExpr { SeqExprWithin $1 $3 }
|
|
|
|
|
| SeqExpr "##" Number SeqExpr { SeqExprDelay (Just $1) (Number $3) $4 }
|
|
|
|
|
| "##" Number SeqExpr { SeqExprDelay (Nothing) (Number $2) $3 }
|
|
|
|
|
| "first_match" "(" SeqExpr SeqMatchItems ")" { SeqExprFirstMatch $3 $4 }
|
|
|
|
|
SeqMatchItems :: { [SeqMatchItem] }
|
|
|
|
|
: "," SeqMatchItem { [$2] }
|
|
|
|
|
| SeqMatchItems "," SeqMatchItem { $1 ++ [$3] }
|
|
|
|
|
SeqMatchItem :: { SeqMatchItem }
|
2021-07-16 15:54:05 +02:00
|
|
|
: ForStepAssignment { SeqMatchAsgn $1 }
|
|
|
|
|
| Identifier CallArgs { SeqMatchCall $1 $2 }
|
2019-03-30 05:47:37 +01:00
|
|
|
|
|
|
|
|
ActionBlock :: { ActionBlock }
|
2020-06-10 03:18:31 +02:00
|
|
|
: Stmt %prec NoElse { ActionBlock $1 Null }
|
|
|
|
|
| "else" Stmt { ActionBlock Null $2 }
|
|
|
|
|
| Stmt "else" Stmt { ActionBlock $1 $3 }
|
2019-03-26 06:54:16 +01:00
|
|
|
|
2019-09-16 05:17:14 +02:00
|
|
|
AttributeInstances :: { [Attr] }
|
|
|
|
|
: {- empty -} { [] }
|
|
|
|
|
| AttributeInstance AttributeInstances { $1 : $2 }
|
2019-03-26 06:54:16 +01:00
|
|
|
AttributeInstance :: { Attr }
|
2021-07-03 19:23:33 +02:00
|
|
|
: AttributeInstanceP { snd $1 }
|
|
|
|
|
AttributeInstanceP :: { (Position, Attr) }
|
|
|
|
|
: "(*" AttrSpecs "*)" { withPos $1 $ Attr $2 }
|
2019-03-26 06:54:16 +01:00
|
|
|
AttrSpecs :: { [AttrSpec] }
|
|
|
|
|
: AttrSpec { [$1] }
|
|
|
|
|
| AttrSpecs "," AttrSpec { $1 ++ [$3] }
|
|
|
|
|
AttrSpec :: { AttrSpec }
|
2021-01-21 20:02:03 +01:00
|
|
|
: Identifier OptAsgn { ($1, $2) }
|
2019-03-22 06:31:43 +01:00
|
|
|
|
2020-06-14 21:56:09 +02:00
|
|
|
NInputGates :: { [(Expr, Identifier, LHS, [Expr])] }
|
2019-03-22 06:31:43 +01:00
|
|
|
: NInputGate { [$1] }
|
|
|
|
|
| NInputGates "," NInputGate { $1 ++ [$3]}
|
2020-06-14 21:56:09 +02:00
|
|
|
NOutputGates :: { [(Expr, Identifier, [LHS], Expr)] }
|
2019-03-22 06:31:43 +01:00
|
|
|
: NOutputGate { [$1] }
|
|
|
|
|
| NOutputGates "," NOutputGate { $1 ++ [$3]}
|
|
|
|
|
|
2020-06-14 21:56:09 +02:00
|
|
|
NInputGate :: { (Expr, Identifier, LHS, [Expr]) }
|
|
|
|
|
: DelayControlOrNil opt(Identifier) "(" LHS "," Exprs ")" { ($1, fromMaybe "" $2, $4, $6) }
|
|
|
|
|
NOutputGate :: { (Expr, Identifier, [LHS], Expr) }
|
|
|
|
|
: DelayControlOrNil opt(Identifier) "(" NOutputGateItems { ($1, fromMaybe "" $2, fst $4, snd $4) }
|
2019-03-22 06:31:43 +01:00
|
|
|
NOutputGateItems :: { ([LHS], Expr) }
|
|
|
|
|
: Expr ")" { ([], $1) }
|
2020-09-14 05:24:21 +02:00
|
|
|
| Expr "," NOutputGateItems { (toLHS $1 : fst $3, snd $3) }
|
2020-06-14 21:56:09 +02:00
|
|
|
DelayControlOrNil :: { Expr }
|
|
|
|
|
: DelayControl { $1 }
|
|
|
|
|
| {- empty -} { Nil }
|
2019-03-22 06:31:43 +01:00
|
|
|
|
|
|
|
|
NInputGateKW :: { NInputGateKW }
|
|
|
|
|
: "and" { GateAnd }
|
|
|
|
|
| "nand" { GateNand }
|
|
|
|
|
| "or" { GateOr }
|
|
|
|
|
| "nor" { GateNor }
|
|
|
|
|
| "xor" { GateXor }
|
|
|
|
|
| "xnor" { GateXnor }
|
|
|
|
|
NOutputGateKW :: { NOutputGateKW }
|
|
|
|
|
: "buf" { GateBuf }
|
|
|
|
|
| "not" { GateNot }
|
2019-03-07 19:19:31 +01:00
|
|
|
|
2021-07-02 23:59:21 +02:00
|
|
|
DriveStrength :: { (Strength0, Strength1) }
|
|
|
|
|
: "(" Strength0 "," Strength1 ")" { ($2 , $4 ) }
|
|
|
|
|
| "(" Strength1 "," Strength0 ")" { ($4 , $2 ) }
|
|
|
|
|
| "(" Strength0 "," "highz1" ")" { ($2 , Highz1) }
|
|
|
|
|
| "(" Strength1 "," "highz0" ")" { (Highz0, $2 ) }
|
|
|
|
|
| "(" "highz0" "," Strength1 ")" { (Highz0, $4 ) }
|
|
|
|
|
| "(" "highz1" "," Strength0 ")" { ($4 , Highz1) }
|
2020-03-21 02:13:57 +01:00
|
|
|
Strength0 :: { Strength0 }
|
|
|
|
|
: "supply0" { Supply0 }
|
|
|
|
|
| "strong0" { Strong0 }
|
|
|
|
|
| "pull0" { Pull0 }
|
|
|
|
|
| "weak0" { Weak0 }
|
|
|
|
|
Strength1 :: { Strength1 }
|
|
|
|
|
: "supply1" { Supply1 }
|
|
|
|
|
| "strong1" { Strong1 }
|
|
|
|
|
| "pull1" { Pull1 }
|
|
|
|
|
| "weak1" { Weak1 }
|
|
|
|
|
ChargeStrength :: { ChargeStrength }
|
|
|
|
|
: "(" "small" ")" { Small }
|
|
|
|
|
| "(" "medium" ")" { Medium }
|
|
|
|
|
| "(" "large" ")" { Large }
|
|
|
|
|
|
2019-10-04 01:37:42 +02:00
|
|
|
LHSAsgns :: { [(LHS, Expr)] }
|
|
|
|
|
: LHSAsgn { [$1] }
|
|
|
|
|
| LHSAsgns "," LHSAsgn { $1 ++ [$3] }
|
|
|
|
|
LHSAsgn :: { (LHS, Expr) }
|
2019-03-18 17:37:46 +01:00
|
|
|
: LHS "=" Expr { ($1, $3) }
|
|
|
|
|
|
2019-04-23 23:12:56 +02:00
|
|
|
PackageItems :: { [PackageItem] }
|
2020-01-31 04:17:17 +01:00
|
|
|
: {- empty -} { [] }
|
2020-03-20 23:50:54 +01:00
|
|
|
| ";" PackageItems { $2 }
|
2021-07-12 02:43:30 +02:00
|
|
|
| PITrace PackageItem PackageItems { addPITrace $1 ($2 ++ $3) }
|
2019-04-23 23:12:56 +02:00
|
|
|
PackageItem :: { [PackageItem] }
|
2021-06-25 06:15:46 +02:00
|
|
|
: PackageOrClassItem { $1}
|
|
|
|
|
| TaskOrFunction { [$1] }
|
|
|
|
|
|
|
|
|
|
ClassItems :: { [ClassItem] }
|
|
|
|
|
: {- empty -} { [] }
|
|
|
|
|
| ";" ClassItems { $2 }
|
2021-07-12 02:43:30 +02:00
|
|
|
| CITrace ClassItem ClassItems { addCITrace $1 ($2 ++ $3) }
|
2021-06-25 06:15:46 +02:00
|
|
|
ClassItem :: { [ClassItem] }
|
|
|
|
|
: ClassItemQualifier PackageOrClassItem { map ($1, ) $2 }
|
|
|
|
|
| ClassItemQualifier TaskOrFunction { [($1, $2)] }
|
|
|
|
|
ClassItemQualifier :: { Qualifier }
|
|
|
|
|
: {- empty -} { QNone }
|
|
|
|
|
| "static" { QStatic }
|
|
|
|
|
| "local" { QLocal }
|
|
|
|
|
| "protected" { QProtected }
|
|
|
|
|
|
|
|
|
|
PackageOrClassItem :: { [PackageItem] }
|
2021-07-09 21:41:17 +02:00
|
|
|
: DeclTokens(";") { map Decl $ parseDTsAsDecl $1 }
|
2021-01-27 22:41:39 +01:00
|
|
|
| ParameterDecl(";") { map Decl $1 }
|
2019-08-07 01:53:19 +02:00
|
|
|
| NonDeclPackageItem { $1 }
|
2019-04-24 00:44:45 +02:00
|
|
|
NonDeclPackageItem :: { [PackageItem] }
|
2021-06-25 06:15:46 +02:00
|
|
|
: Typedef { [Decl $1] }
|
|
|
|
|
| ImportOrExport { $1 }
|
|
|
|
|
| ForwardTypedef ";" { $1 }
|
|
|
|
|
| TimeunitsDeclaration { $1 }
|
|
|
|
|
| Directive { [Directive $1] }
|
|
|
|
|
|
|
|
|
|
ImportOrExport :: { [PackageItem] }
|
|
|
|
|
: "import" PackageImportItems ";" { map (uncurry Import) $2 }
|
2021-01-24 00:50:06 +01:00
|
|
|
| "export" PackageImportItems ";" { map (uncurry Export) $2 }
|
|
|
|
|
| "export" "*" "::" "*" ";" { [Export "" ""] }
|
2021-06-25 06:15:46 +02:00
|
|
|
TaskOrFunction :: { PackageItem }
|
|
|
|
|
: "function" Lifetime FuncRetAndName TFItems DeclsAndStmts endfunction StrTag {% checkTag (snd $3) $7 $ Function $2 (fst $3) (snd $3) (map makeInput $4 ++ fst $5) (snd $5) }
|
|
|
|
|
| "function" Lifetime "void" Identifier TFItems DeclsAndStmts endfunction StrTag {% checkTag $4 $8 $ Task $2 $4 ($5 ++ fst $6) (snd $6) }
|
|
|
|
|
| "task" Lifetime Identifier TFItems DeclsAndStmts endtask StrTag {% checkTag $3 $7 $ Task $2 $3 ($4 ++ fst $5) (snd $5) }
|
|
|
|
|
Typedef :: { Decl }
|
|
|
|
|
: "typedef" Type Identifier ";" { ParamType Localparam $3 $2 }
|
|
|
|
|
| "typedef" Type Identifier DimensionsNonEmpty ";" { ParamType Localparam $3 (UnpackedType $2 $4) }
|
|
|
|
|
| "typedef" TypedefRef Identifier ";" { ParamType Localparam $3 $2 }
|
2021-04-15 17:35:20 +02:00
|
|
|
TypedefRef :: { Type }
|
|
|
|
|
: Identifier "." Identifier { TypedefRef $ Dot (Ident $1) $3 }
|
|
|
|
|
| Identifier "[" Expr "]" "." Identifier { TypedefRef $ Dot (Bit (Ident $1) $3) $6 }
|
2019-09-05 05:41:24 +02:00
|
|
|
ForwardTypedef :: { [PackageItem] }
|
2019-09-18 02:42:48 +02:00
|
|
|
: "typedef" Identifier { [] }
|
|
|
|
|
| "typedef" "enum" Identifier { [] }
|
2019-09-05 05:41:24 +02:00
|
|
|
| "typedef" "struct" Identifier { [] }
|
|
|
|
|
| "typedef" "union" Identifier { [] }
|
2019-09-12 03:44:57 +02:00
|
|
|
TimeunitsDeclaration :: { [PackageItem] }
|
|
|
|
|
: "timeunit" Time ";" { [] }
|
|
|
|
|
| "timeunit" Time "/" Time ";" { [] }
|
|
|
|
|
| "timeprecision" Time ";" { [] }
|
2019-04-23 21:53:51 +02:00
|
|
|
|
2019-10-11 02:53:49 +02:00
|
|
|
Directive :: { String }
|
2020-02-07 05:27:51 +01:00
|
|
|
: "`celldefine" { tokenString $1 }
|
|
|
|
|
| "`endcelldefine" { tokenString $1 }
|
|
|
|
|
| "`unconnected_drive" Drive { tokenString $1 ++ " " ++ $2 }
|
|
|
|
|
| "`nounconnected_drive" { tokenString $1 }
|
|
|
|
|
| "`default_nettype" DefaultNetType { tokenString $1 ++ " " ++ $2 }
|
|
|
|
|
| "`resetall" { tokenString $1 }
|
|
|
|
|
Drive :: { String }
|
|
|
|
|
: "pull0" { tokenString $1 }
|
|
|
|
|
| "pull1" { tokenString $1 }
|
|
|
|
|
DefaultNetType :: { String }
|
2021-07-03 19:23:33 +02:00
|
|
|
: NetTypeP { show $ snd $1 }
|
2020-02-07 05:27:51 +01:00
|
|
|
| Identifier { $1 }
|
2019-10-11 02:53:49 +02:00
|
|
|
|
2021-01-24 00:50:06 +01:00
|
|
|
PackageImportItems :: { [(Identifier, Identifier)] }
|
2019-04-23 21:53:51 +02:00
|
|
|
: PackageImportItem { [$1] }
|
|
|
|
|
| PackageImportItems "," PackageImportItem { $1 ++ [$3] }
|
2021-01-24 00:50:06 +01:00
|
|
|
PackageImportItem :: { (Identifier, Identifier) }
|
|
|
|
|
: Identifier "::" Identifier { ($1, $3) }
|
|
|
|
|
| Identifier "::" "*" { ($1, "") }
|
2019-03-04 20:25:38 +01:00
|
|
|
|
|
|
|
|
FuncRetAndName :: { (Type, Identifier) }
|
2019-03-22 21:57:13 +01:00
|
|
|
: Type Identifier { ($1 , $2) }
|
|
|
|
|
| Identifier { (Implicit Unspecified [], $1) }
|
|
|
|
|
| Signing Identifier { (Implicit $1 [], $2) }
|
|
|
|
|
| DimensionsNonEmpty Identifier { (Implicit Unspecified $1, $2) }
|
|
|
|
|
| Signing DimensionsNonEmpty Identifier { (Implicit $1 $2, $3) }
|
2019-02-15 05:29:42 +01:00
|
|
|
|
2019-02-18 06:26:43 +01:00
|
|
|
AlwaysKW :: { AlwaysKW }
|
|
|
|
|
: "always" { Always }
|
|
|
|
|
| "always_comb" { AlwaysComb }
|
|
|
|
|
| "always_ff" { AlwaysFF }
|
|
|
|
|
| "always_latch" { AlwaysLatch }
|
|
|
|
|
|
2019-03-04 20:25:38 +01:00
|
|
|
Lifetime :: { Lifetime }
|
2019-12-22 18:01:05 +01:00
|
|
|
: {- empty -} { Inherit }
|
|
|
|
|
| ExplicitLifetime { $1 }
|
|
|
|
|
ExplicitLifetime :: { Lifetime }
|
2019-03-04 20:25:38 +01:00
|
|
|
: "static" { Static }
|
|
|
|
|
| "automatic" { Automatic }
|
|
|
|
|
|
2019-03-07 19:58:20 +01:00
|
|
|
TFItems :: { [Decl] }
|
2021-07-09 21:41:17 +02:00
|
|
|
: "(" DeclTokens(")") ";" { parseDTsAsTFDecls $2 }
|
2019-08-29 02:28:56 +02:00
|
|
|
| "(" ")" ";" { [] }
|
2019-03-04 20:25:38 +01:00
|
|
|
| ";" { [] }
|
2019-02-24 09:06:40 +01:00
|
|
|
|
|
|
|
|
ParamType :: { Type }
|
2019-04-03 19:45:43 +02:00
|
|
|
: PartialType OptSigning Dimensions { $1 $2 $3 }
|
2019-03-30 05:47:37 +01:00
|
|
|
| DimensionsNonEmpty { Implicit Unspecified $1 }
|
2019-03-22 21:57:13 +01:00
|
|
|
| Signing Dimensions { Implicit $1 $2 }
|
2019-02-11 21:16:25 +01:00
|
|
|
|
2019-02-11 19:47:56 +01:00
|
|
|
Dimensions :: { [Range] }
|
2019-02-20 22:03:04 +01:00
|
|
|
: {- empty -} { [] }
|
|
|
|
|
| DimensionsNonEmpty { $1 }
|
|
|
|
|
DimensionsNonEmpty :: { [Range] }
|
2019-03-07 07:38:42 +01:00
|
|
|
: Dimension { [$1] }
|
|
|
|
|
| DimensionsNonEmpty Dimension { $1 ++ [$2] }
|
|
|
|
|
Dimension :: { Range }
|
|
|
|
|
: Range { $1 }
|
2020-07-12 23:06:27 +02:00
|
|
|
| "[" Expr "]" { (RawNum 0, BinOp Sub $2 (RawNum 1)) }
|
2019-02-11 19:47:56 +01:00
|
|
|
|
2019-08-30 02:52:01 +02:00
|
|
|
DeclAsgns :: { [(Identifier, Expr, [Range])] }
|
2019-02-11 08:12:52 +01:00
|
|
|
: DeclAsgn { [$1] }
|
2019-02-11 20:07:46 +01:00
|
|
|
| DeclAsgns "," DeclAsgn { $1 ++ [$3] }
|
2019-08-30 02:52:01 +02:00
|
|
|
DeclAsgn :: { (Identifier, Expr, [Range]) }
|
2021-01-21 20:02:03 +01:00
|
|
|
: Identifier Dimensions OptAsgn { ($1, $3, $2) }
|
2019-02-11 08:12:52 +01:00
|
|
|
|
2019-02-08 05:49:12 +01:00
|
|
|
Range :: { Range }
|
2019-03-30 07:50:45 +01:00
|
|
|
: "[" Expr ":" Expr "]" { ($2, $4) }
|
2019-04-05 19:53:52 +02:00
|
|
|
|
2021-07-03 19:23:33 +02:00
|
|
|
PartSelectP :: { (Position, (PartSelectMode, Range)) }
|
|
|
|
|
: "[" Expr ":" Expr "]" { (tokenPosition $1, (NonIndexed , ($2, $4))) }
|
|
|
|
|
| "[" Expr "+:" Expr "]" { (tokenPosition $1, (IndexedPlus , ($2, $4))) }
|
|
|
|
|
| "[" Expr "-:" Expr "]" { (tokenPosition $1, (IndexedMinus, ($2, $4))) }
|
2019-02-08 05:49:12 +01:00
|
|
|
|
|
|
|
|
LHS :: { LHS }
|
2019-03-04 21:16:53 +01:00
|
|
|
: Identifier { LHSIdent $1 }
|
2021-07-03 19:23:33 +02:00
|
|
|
| LHS PartSelectP { uncurry (LHSRange $1) (snd $2) }
|
2019-03-04 21:16:53 +01:00
|
|
|
| LHS "[" Expr "]" { LHSBit $1 $3 }
|
|
|
|
|
| LHS "." Identifier { LHSDot $1 $3 }
|
2021-07-07 03:20:44 +02:00
|
|
|
| LHSConcatP { snd $1 }
|
|
|
|
|
| LHSStreamP { snd $1 }
|
2019-02-08 05:49:12 +01:00
|
|
|
|
2021-07-07 03:20:44 +02:00
|
|
|
LHSStreamP :: { (Position, LHS) }
|
|
|
|
|
: "{" StreamOp StreamSize Concat "}" { withPos $1 $ LHSStream $2 $3 (map toLHS $4) }
|
|
|
|
|
| "{" StreamOp Concat "}" { withPos $1 $ LHSStream $2 (RawNum 1) (map toLHS $3) }
|
|
|
|
|
|
|
|
|
|
LHSConcatP :: { (Position, LHS) }
|
|
|
|
|
: "{" LHSs "}" { withPos $1 $ LHSConcat $2 }
|
2019-02-08 05:49:12 +01:00
|
|
|
LHSs :: { [LHS] }
|
2019-03-04 21:16:53 +01:00
|
|
|
: LHS { [$1] }
|
|
|
|
|
| LHSs "," LHS { $1 ++ [$3] }
|
2019-02-08 05:49:12 +01:00
|
|
|
|
2021-07-03 19:23:33 +02:00
|
|
|
PortBindingsP:: { (Position, [PortBinding]) }
|
|
|
|
|
: "(" PortBindingsInside ")" {% checkPortBindings $2 >>= return . withPos $1 }
|
2019-09-09 07:38:14 +02:00
|
|
|
PortBindingsInside :: { [PortBinding] }
|
2021-05-21 20:02:29 +02:00
|
|
|
: OptPortBinding { [$1] }
|
|
|
|
|
| OptPortBinding "," PortBindingsInside { $1 : $3}
|
|
|
|
|
OptPortBinding :: { PortBinding }
|
|
|
|
|
: {- empty -} { ("", Nil) }
|
|
|
|
|
| PortBinding { $1 }
|
|
|
|
|
|
2019-09-09 07:38:14 +02:00
|
|
|
PortBinding :: { PortBinding }
|
2020-06-14 21:56:09 +02:00
|
|
|
: "." Identifier "(" ExprOrNil ")" { ($2, $4) }
|
|
|
|
|
| "." Identifier { ($2, Ident $2) }
|
|
|
|
|
| Expr { ("", $1) }
|
|
|
|
|
| ".*" { ("*", Nil) }
|
2019-09-09 07:38:14 +02:00
|
|
|
|
2020-01-31 04:17:17 +01:00
|
|
|
ParamBindings :: { [ParamBinding] }
|
2020-03-31 01:27:44 +02:00
|
|
|
: "#" "(" ")" { [] }
|
2021-04-29 21:32:54 +02:00
|
|
|
| "#" "(" ParamBindingsInside ")" {% checkParamBindings $3 }
|
2019-09-09 07:38:14 +02:00
|
|
|
ParamBindingsInside :: { [ParamBinding] }
|
2021-04-23 22:06:57 +02:00
|
|
|
: ParamBinding opt(",") { [$1] }
|
2019-09-09 07:38:14 +02:00
|
|
|
| ParamBinding "," ParamBindingsInside { $1 : $3}
|
|
|
|
|
ParamBinding :: { ParamBinding }
|
|
|
|
|
: "." Identifier "(" TypeOrExpr ")" { ($2, $4) }
|
|
|
|
|
| "." Identifier "(" ")" { ($2, Right Nil) }
|
|
|
|
|
| TypeOrExpr { ("", $1) }
|
|
|
|
|
|
2019-02-08 05:49:12 +01:00
|
|
|
Stmts :: { [Stmt] }
|
2019-02-11 21:16:25 +01:00
|
|
|
: {- empty -} { [] }
|
|
|
|
|
| Stmts Stmt { $1 ++ [$2] }
|
2019-02-08 05:49:12 +01:00
|
|
|
|
|
|
|
|
Stmt :: { Stmt }
|
2020-01-31 04:17:17 +01:00
|
|
|
: StmtTrace StmtAsgn { Block Seq "" [] [$1, $2] }
|
|
|
|
|
| StmtTrace StmtNonAsgn { $2 }
|
2019-10-01 05:03:55 +02:00
|
|
|
|
|
|
|
|
StmtAsgn :: { Stmt }
|
2020-02-01 21:52:52 +01:00
|
|
|
: LHS "=" opt(DelayOrEvent) Expr ";" { Asgn AsgnOpEq $3 $1 $4 }
|
|
|
|
|
| LHS "<=" opt(DelayOrEvent) Expr ";" { Asgn AsgnOpNonBlocking $3 $1 $4 }
|
|
|
|
|
| LHS AsgnBinOp Expr ";" { Asgn $2 Nothing $1 $3 }
|
2020-07-12 23:06:27 +02:00
|
|
|
| LHS IncOrDecOperator ";" { Asgn (AsgnOp $2) Nothing $1 (RawNum 1) }
|
|
|
|
|
| IncOrDecOperator LHS ";" { Asgn (AsgnOp $1) Nothing $2 (RawNum 1) }
|
2019-10-19 22:22:39 +02:00
|
|
|
| LHS ";" { Subroutine (lhsToExpr $1) (Args [] []) }
|
|
|
|
|
| LHS CallArgs ";" { Subroutine (lhsToExpr $1) $2 }
|
2021-01-24 00:50:06 +01:00
|
|
|
| Identifier "::" Identifier ";" { Subroutine (PSIdent $1 $3) (Args [] []) }
|
|
|
|
|
| Identifier "::" Identifier CallArgs ";" { Subroutine (PSIdent $1 $3) $4 }
|
2021-05-30 04:23:20 +02:00
|
|
|
| Identifier ParamBindings "::" Identifier ";" { Subroutine (CSIdent $1 $2 $4) (Args [] []) }
|
|
|
|
|
| Identifier ParamBindings "::" Identifier CallArgs ";" { Subroutine (CSIdent $1 $2 $4) $5 }
|
2019-03-04 20:25:38 +01:00
|
|
|
StmtNonAsgn :: { Stmt }
|
2021-03-06 21:03:04 +01:00
|
|
|
: StmtBlock(BlockKWSeq, end ) { $1 }
|
|
|
|
|
| StmtBlock(BlockKWPar, join) { $1 }
|
|
|
|
|
| StmtNonBlock { $1 }
|
|
|
|
|
| Identifier ":" StmtNonBlock { Block Seq $1 [] [$3] }
|
2019-10-01 05:03:55 +02:00
|
|
|
StmtBlock(begin, end) :: { Stmt }
|
2021-06-15 23:47:32 +02:00
|
|
|
: begin StrTag DeclsAndStmts end StrTag {% checkTag $2 $5 $ uncurry (Block $1 $2) $3 }
|
|
|
|
|
| Identifier ":" begin DeclsAndStmts end StrTag {% checkTag $1 $6 $ uncurry (Block $3 $1) $4 }
|
2019-10-01 05:03:55 +02:00
|
|
|
StmtNonBlock :: { Stmt }
|
2019-02-11 20:46:09 +01:00
|
|
|
: ";" { Null }
|
2019-10-01 05:03:55 +02:00
|
|
|
| Unique "if" "(" Expr ")" Stmt "else" Stmt { If $1 $4 $6 $8 }
|
|
|
|
|
| Unique "if" "(" Expr ")" Stmt %prec NoElse { If $1 $4 $6 Null }
|
2021-07-14 21:50:12 +02:00
|
|
|
| "for" "(" ForInit ForCond ForStep ")" Stmt { makeFor $3 $4 $5 $7 }
|
2021-02-17 19:26:13 +01:00
|
|
|
| CaseStmt { $1 }
|
2019-03-05 02:58:09 +01:00
|
|
|
| TimingControl Stmt { Timing $1 $2 }
|
2020-06-14 21:56:09 +02:00
|
|
|
| "return" ExprOrNil ";" { Return $2 }
|
2019-10-09 04:13:05 +02:00
|
|
|
| "break" ";" { Break }
|
|
|
|
|
| "continue" ";" { Continue }
|
2019-03-05 03:32:30 +01:00
|
|
|
| "while" "(" Expr ")" Stmt { While $3 $5 }
|
|
|
|
|
| "repeat" "(" Expr ")" Stmt { RepeatL $3 $5 }
|
|
|
|
|
| "do" Stmt "while" "(" Expr ")" ";" { DoWhile $5 $2 }
|
|
|
|
|
| "forever" Stmt { Forever $2 }
|
2019-09-15 21:49:21 +02:00
|
|
|
| "foreach" "(" Identifier IdxVars ")" Stmt { Foreach $3 $4 $6 }
|
2019-10-01 05:22:05 +02:00
|
|
|
| "->" Identifier ";" { Trigger True $2 }
|
|
|
|
|
| "->>" Identifier ";" { Trigger False $2 }
|
2019-03-26 06:54:16 +01:00
|
|
|
| AttributeInstance Stmt { StmtAttr $1 $2 }
|
2019-04-04 01:08:30 +02:00
|
|
|
| ProceduralAssertionStatement { Assertion $1 }
|
2020-01-12 03:06:09 +01:00
|
|
|
| "void" "'" "(" Expr CallArgs ")" ";" { Subroutine $4 $5 }
|
2019-03-30 05:47:37 +01:00
|
|
|
|
2021-02-17 19:26:13 +01:00
|
|
|
CaseStmt :: { Stmt }
|
|
|
|
|
: Unique CaseKW "(" Expr ")" Cases "endcase" { Case $1 $2 $4 $ validateCases $5 $6 }
|
|
|
|
|
| Unique CaseKW "(" Expr ")" "inside" InsideCases "endcase" { Case $1 (caseInsideKW $3 $2) $4 $ validateCases $5 $7 }
|
|
|
|
|
|
2019-10-01 05:03:55 +02:00
|
|
|
BlockKWPar :: { BlockKW }
|
|
|
|
|
: "fork" { Par }
|
|
|
|
|
BlockKWSeq :: { BlockKW }
|
|
|
|
|
: "begin" { Seq }
|
|
|
|
|
|
2019-12-02 05:25:33 +01:00
|
|
|
Unique :: { ViolationCheck }
|
|
|
|
|
: {- empty -} { NoCheck }
|
|
|
|
|
| "unique" { Unique }
|
|
|
|
|
| "unique0" { Unique0 }
|
|
|
|
|
| "priority" { Priority }
|
2019-03-04 20:25:38 +01:00
|
|
|
|
2019-10-01 05:03:55 +02:00
|
|
|
ForInit :: { Either [Decl] [(LHS, Expr)] }
|
|
|
|
|
: ";" { Right [] }
|
|
|
|
|
| DeclTokens(";") { parseDTsAsDeclsOrAsgns $1 }
|
|
|
|
|
|
|
|
|
|
ForCond :: { Expr }
|
2020-07-12 23:06:27 +02:00
|
|
|
: ";" { RawNum 1 }
|
2019-10-01 05:03:55 +02:00
|
|
|
| Expr ";" { $1 }
|
|
|
|
|
|
2019-03-27 06:53:26 +01:00
|
|
|
ForStep :: { [(LHS, AsgnOp, Expr)] }
|
|
|
|
|
: {- empty -} { [] }
|
|
|
|
|
| ForStepNonEmpty { $1 }
|
|
|
|
|
ForStepNonEmpty :: { [(LHS, AsgnOp, Expr)] }
|
|
|
|
|
: ForStepAssignment { [$1] }
|
|
|
|
|
| ForStepNonEmpty "," ForStepAssignment { $1 ++ [$3] }
|
|
|
|
|
ForStepAssignment :: { (LHS, AsgnOp, Expr) }
|
|
|
|
|
: LHS AsgnOp Expr { ($1, $2, $3) }
|
2020-07-12 23:06:27 +02:00
|
|
|
| IncOrDecOperator LHS { ($2, AsgnOp $1, RawNum 1) }
|
|
|
|
|
| LHS IncOrDecOperator { ($1, AsgnOp $2, RawNum 1) }
|
2019-03-27 06:53:26 +01:00
|
|
|
|
2020-06-10 03:18:31 +02:00
|
|
|
IdxVars :: { [Identifier] }
|
2019-09-15 21:49:21 +02:00
|
|
|
: "[" IdxVarsInside "]" { $2 }
|
2020-06-10 03:18:31 +02:00
|
|
|
IdxVarsInside :: { [Identifier] }
|
|
|
|
|
: IdxVar { [$1] }
|
|
|
|
|
| IdxVar "," IdxVarsInside { $1 : $3 }
|
|
|
|
|
IdxVar :: { Identifier }
|
|
|
|
|
: {- empty -} { "" }
|
|
|
|
|
| Identifier { $1 }
|
2019-09-15 21:49:21 +02:00
|
|
|
|
2019-03-04 20:25:38 +01:00
|
|
|
DeclsAndStmts :: { ([Decl], [Stmt]) }
|
2021-05-30 03:55:50 +02:00
|
|
|
: StmtTrace DeclOrStmt DeclsAndStmts {% combineDeclsAndStmts $2 $3 }
|
2020-01-31 04:17:17 +01:00
|
|
|
| StmtTrace StmtNonAsgn Stmts { ([], $1 : $2 : $3) }
|
|
|
|
|
| StmtTrace {- empty -} { ([], []) }
|
2019-03-04 20:25:38 +01:00
|
|
|
DeclOrStmt :: { ([Decl], [Stmt]) }
|
2020-01-31 04:17:17 +01:00
|
|
|
: DeclTokens(";") { parseDTsAsDeclOrStmt $1 }
|
|
|
|
|
| ParameterDecl(";") { ($1, []) }
|
2019-03-30 05:47:37 +01:00
|
|
|
|
2019-10-02 04:02:30 +02:00
|
|
|
ModuleParameterDecl(delim) :: { [Decl] }
|
2021-07-12 02:43:30 +02:00
|
|
|
: ParameterDecl(delim) { $1 }
|
|
|
|
|
| DeclTrace "type" TypeAsgns delim { $1 : map (uncurry $ ParamType Parameter) $3 }
|
2019-08-07 01:53:19 +02:00
|
|
|
ParameterDecl(delim) :: { [Decl] }
|
2020-07-09 01:46:37 +02:00
|
|
|
: ParameterDeclKW DeclAsgns delim { makeParamDecls $1 (Implicit Unspecified []) $2 }
|
|
|
|
|
| ParameterDeclKW ParamType DeclAsgns delim { makeParamDecls $1 $2 $3 }
|
|
|
|
|
| ParameterDeclKW TypeAlias DeclAsgns delim { makeParamDecls $1 $2 $3 }
|
2021-07-12 02:43:30 +02:00
|
|
|
| ParameterDeclKW "type" TypeAsgns delim { makeParamTypeDecls $1 $3 }
|
|
|
|
|
ParameterDeclKW :: { (Position, ParamScope) }
|
|
|
|
|
: "parameter" { withPos $1 Parameter }
|
|
|
|
|
| "localparam" { withPos $1 Localparam }
|
2019-03-30 05:47:37 +01:00
|
|
|
|
2021-01-24 17:55:03 +01:00
|
|
|
TypeAsgns :: { [(Identifier, Type)] }
|
2019-09-07 04:29:14 +02:00
|
|
|
: TypeAsgn { [$1] }
|
|
|
|
|
| TypeAsgns "," TypeAsgn { $1 ++ [$3] }
|
2021-01-24 17:55:03 +01:00
|
|
|
TypeAsgn :: { (Identifier, Type) }
|
|
|
|
|
: Identifier "=" Type { ($1, $3) }
|
|
|
|
|
| Identifier { ($1, UnknownType) }
|
2019-09-07 04:29:14 +02:00
|
|
|
|
2019-03-30 05:47:37 +01:00
|
|
|
-- TODO: This does not allow for @identifier
|
|
|
|
|
ClockingEvent :: { Sense }
|
|
|
|
|
: "@" "(" Senses ")" { $3 }
|
2019-02-08 05:49:12 +01:00
|
|
|
|
2019-03-05 02:58:09 +01:00
|
|
|
TimingControl :: { Timing }
|
2020-02-01 21:52:52 +01:00
|
|
|
: DelayOrEvent { $1 }
|
|
|
|
|
| CycleDelay { Cycle $1 }
|
|
|
|
|
DelayOrEvent :: { Timing }
|
2019-03-26 00:31:06 +01:00
|
|
|
: DelayControl { Delay $1 }
|
|
|
|
|
| EventControl { Event $1 }
|
|
|
|
|
DelayControl :: { Expr }
|
2020-07-09 01:46:37 +02:00
|
|
|
: "#" Number { Number $2 }
|
|
|
|
|
| "#" Time { Time $2 }
|
|
|
|
|
| "#" "(" Expr ")" { $3 }
|
|
|
|
|
| "#" "(" Expr ":" Expr ":" Expr ")" { MinTypMax $3 $5 $7 }
|
|
|
|
|
| "#" Identifier { Ident $2 }
|
|
|
|
|
| "#" Identifier "::" Identifier { PSIdent $2 $4 }
|
|
|
|
|
| "#" Identifier ParamBindings "::" Identifier { CSIdent $2 $3 $5 }
|
2019-03-26 00:31:06 +01:00
|
|
|
CycleDelay :: { Expr }
|
|
|
|
|
: "##" Expr { $2 }
|
|
|
|
|
EventControl :: { Sense }
|
|
|
|
|
: "@" "(" Senses ")" { $3 }
|
|
|
|
|
| "@" "(*)" { SenseStar }
|
|
|
|
|
| "@*" { SenseStar }
|
2019-10-01 05:22:05 +02:00
|
|
|
| "@" Identifier { Sense $ LHSIdent $2 }
|
2019-03-05 02:58:09 +01:00
|
|
|
Senses :: { Sense }
|
|
|
|
|
: Sense { $1 }
|
|
|
|
|
| Senses "or" Sense { SenseOr $1 $3 }
|
2019-03-08 23:29:44 +01:00
|
|
|
| Senses "," Sense { SenseOr $1 $3 }
|
2019-03-05 02:58:09 +01:00
|
|
|
Sense :: { Sense }
|
2019-10-10 03:41:14 +02:00
|
|
|
: "(" Sense ")" { $2 }
|
|
|
|
|
| LHS { Sense $1 }
|
|
|
|
|
| "posedge" LHS { SensePosedge $2 }
|
|
|
|
|
| "negedge" LHS { SenseNegedge $2 }
|
|
|
|
|
| "posedge" "(" LHS ")" { SensePosedge $3 }
|
|
|
|
|
| "negedge" "(" LHS ")" { SenseNegedge $3 }
|
2019-03-05 02:58:09 +01:00
|
|
|
|
2019-02-23 21:10:25 +01:00
|
|
|
CaseKW :: { CaseKW }
|
2019-03-05 00:25:14 +01:00
|
|
|
: "case" { CaseN }
|
|
|
|
|
| "casex" { CaseX }
|
|
|
|
|
| "casez" { CaseZ }
|
2019-02-23 21:10:25 +01:00
|
|
|
|
2019-12-02 05:25:33 +01:00
|
|
|
Cases :: { [Case] }
|
2021-02-17 19:26:13 +01:00
|
|
|
: Case { [$1] }
|
|
|
|
|
| Case Cases { $1 : $2 }
|
|
|
|
|
Case :: { Case }
|
|
|
|
|
: Exprs ":" Stmt { ($1, $3) }
|
|
|
|
|
| "default" opt(":") Stmt { ([], $3) }
|
|
|
|
|
InsideCases :: { [Case] }
|
2019-12-22 01:31:56 +01:00
|
|
|
: InsideCase { [$1] }
|
2021-02-17 19:26:13 +01:00
|
|
|
| InsideCase InsideCases { $1 : $2 }
|
|
|
|
|
InsideCase :: { Case }
|
2021-02-17 22:57:15 +01:00
|
|
|
: OpenRangeList ":" Stmt { ($1, $3) }
|
2019-12-22 01:31:56 +01:00
|
|
|
| "default" opt(":") Stmt { ([], $3) }
|
2019-02-08 05:49:12 +01:00
|
|
|
|
2020-07-12 23:06:27 +02:00
|
|
|
Real :: { String }
|
|
|
|
|
: real { tokenString $1 }
|
|
|
|
|
|
|
|
|
|
Number :: { Number }
|
|
|
|
|
: number { parseNumber $ tokenString $1 }
|
2019-02-08 05:49:12 +01:00
|
|
|
|
|
|
|
|
String :: { String }
|
2019-02-24 09:06:40 +01:00
|
|
|
: string { tail $ init $ tokenString $1 }
|
2019-02-08 05:49:12 +01:00
|
|
|
|
2019-09-12 03:44:57 +02:00
|
|
|
Time :: { String }
|
|
|
|
|
: time { tokenString $1 }
|
|
|
|
|
|
2019-03-30 06:27:48 +01:00
|
|
|
CallArgs :: { Args }
|
2019-10-01 05:03:55 +02:00
|
|
|
: "(" CallArgsInside ")" { $2 }
|
|
|
|
|
CallArgsInside :: { Args }
|
2020-06-14 21:56:09 +02:00
|
|
|
: {- empty -} { Args [ ] [] }
|
|
|
|
|
| NamedCallArgsFollow { Args [ ] $1 }
|
|
|
|
|
| Expr NamedCallArgs { Args [$1 ] $2 }
|
|
|
|
|
| UnnamedCallArgs NamedCallArgs { Args (Nil : $1) $2 }
|
|
|
|
|
| Expr UnnamedCallArgs NamedCallArgs { Args ($1 : $2) $3 }
|
|
|
|
|
UnnamedCallArgs :: { [Expr] }
|
|
|
|
|
: "," ExprOrNil { [$2] }
|
|
|
|
|
| UnnamedCallArgs "," ExprOrNil { $1 ++ [$3] }
|
|
|
|
|
NamedCallArgs :: { [(Identifier, Expr)] }
|
2019-03-30 06:27:48 +01:00
|
|
|
: {- empty -} { [] }
|
|
|
|
|
| "," NamedCallArgsFollow { $2 }
|
2020-06-14 21:56:09 +02:00
|
|
|
NamedCallArgsFollow :: { [(Identifier, Expr)] }
|
2019-03-30 06:27:48 +01:00
|
|
|
: NamedCallArg { [$1] }
|
|
|
|
|
| NamedCallArgsFollow "," NamedCallArg { $1 ++ [$3] }
|
2020-06-14 21:56:09 +02:00
|
|
|
NamedCallArg :: { (Identifier, Expr) }
|
|
|
|
|
: "." Identifier "(" ExprOrNil ")" { ($2, $4) }
|
2019-02-08 05:49:12 +01:00
|
|
|
|
|
|
|
|
Exprs :: { [Expr] }
|
2019-03-23 00:24:45 +01:00
|
|
|
: Expr { [$1] }
|
|
|
|
|
| Exprs "," Expr { $1 ++ [$3] }
|
2019-02-08 05:49:12 +01:00
|
|
|
|
2019-09-09 07:38:14 +02:00
|
|
|
TypeOrExpr :: { TypeOrExpr }
|
2019-04-02 06:16:06 +02:00
|
|
|
: TypeNonIdent { Left $1 }
|
|
|
|
|
| Expr { Right $1 }
|
2019-09-09 07:38:14 +02:00
|
|
|
|
2021-02-17 22:57:15 +01:00
|
|
|
OpenRangeList :: { [Expr] }
|
2019-12-08 23:36:25 +01:00
|
|
|
: ValueRange { [$1] }
|
|
|
|
|
| OpenRangeList "," ValueRange { $1 ++ [$3] }
|
2021-02-17 22:57:15 +01:00
|
|
|
ValueRange :: { Expr }
|
|
|
|
|
: Expr { $1 }
|
|
|
|
|
| Range { Range Nil NonIndexed $1 }
|
2019-12-08 23:36:25 +01:00
|
|
|
|
2019-02-08 05:49:12 +01:00
|
|
|
Expr :: { Expr }
|
2019-03-23 00:24:45 +01:00
|
|
|
: "(" Expr ")" { $2 }
|
|
|
|
|
| String { String $1 }
|
2020-07-12 23:06:27 +02:00
|
|
|
| Real { Real $1 }
|
2019-03-23 00:24:45 +01:00
|
|
|
| Number { Number $1 }
|
2019-10-07 03:21:58 +02:00
|
|
|
| Time { Time $1 }
|
2019-10-19 22:22:39 +02:00
|
|
|
| Expr CallArgs { Call $1 $2 }
|
2019-09-14 18:31:44 +02:00
|
|
|
| DimsFn "(" TypeOrExpr ")" { DimsFn $1 $3 }
|
2020-07-12 23:06:27 +02:00
|
|
|
| DimFn "(" TypeOrExpr ")" { DimFn $1 $3 (RawNum 1) }
|
2019-09-14 18:31:44 +02:00
|
|
|
| DimFn "(" TypeOrExpr "," Expr ")" { DimFn $1 $3 $5 }
|
2021-07-03 19:23:33 +02:00
|
|
|
| Expr PartSelectP { uncurry (Range $1) (snd $2) }
|
2019-03-23 00:24:45 +01:00
|
|
|
| Expr "[" Expr "]" { Bit $1 $3 }
|
2019-09-02 00:42:13 +02:00
|
|
|
| "{" Expr Concat "}" { Repeat $2 $3 }
|
|
|
|
|
| Concat { Concat $1 }
|
2019-03-23 00:24:45 +01:00
|
|
|
| Expr "?" Expr ":" Expr { Mux $1 $3 $5 }
|
|
|
|
|
| Expr "." Identifier { Dot $1 $3 }
|
|
|
|
|
| "'" "{" PatternItems "}" { Pattern $3 }
|
2021-07-19 17:42:36 +02:00
|
|
|
| Expr "'" "{" PatternItems "}"{ Cast (Right $1) (Pattern $4) }
|
2020-02-15 22:40:50 +01:00
|
|
|
| CastingType "'" "(" Expr ")" { Cast (Left $1) $4 }
|
|
|
|
|
| Expr "'" "(" Expr ")" { Cast (Right $1) $4 }
|
2020-07-12 23:06:27 +02:00
|
|
|
| "{" StreamOp StreamSize Concat "}" { Stream $2 $3 $4 }
|
|
|
|
|
| "{" StreamOp Concat "}" { Stream $2 (RawNum 1) $3 }
|
2019-12-08 23:36:25 +01:00
|
|
|
| Expr "inside" "{" OpenRangeList "}" { Inside $1 $4 }
|
2019-10-06 22:13:34 +02:00
|
|
|
| "(" Expr ":" Expr ":" Expr ")" { MinTypMax $2 $4 $6 }
|
2020-07-09 01:46:37 +02:00
|
|
|
| Identifier %prec REDUCE_OP {- defer -} { Ident $1 }
|
|
|
|
|
| Identifier "::" Identifier { PSIdent $1 $3 }
|
|
|
|
|
| Identifier ParamBindings "::" Identifier { CSIdent $1 $2 $4 }
|
2019-03-23 00:24:45 +01:00
|
|
|
-- binary expressions
|
|
|
|
|
| Expr "||" Expr { BinOp LogOr $1 $3 }
|
|
|
|
|
| Expr "&&" Expr { BinOp LogAnd $1 $3 }
|
2019-09-15 19:55:40 +02:00
|
|
|
| Expr "->" Expr { BinOp LogImp $1 $3 }
|
|
|
|
|
| Expr "<->" Expr { BinOp LogEq $1 $3 }
|
2019-03-23 00:24:45 +01:00
|
|
|
| Expr "|" Expr { BinOp BitOr $1 $3 }
|
|
|
|
|
| Expr "^" Expr { BinOp BitXor $1 $3 }
|
|
|
|
|
| Expr "&" Expr { BinOp BitAnd $1 $3 }
|
2019-03-30 06:33:49 +01:00
|
|
|
| Expr "~^" Expr { BinOp BitXnor $1 $3 }
|
|
|
|
|
| Expr "^~" Expr { BinOp BitXnor $1 $3 }
|
2019-03-23 00:24:45 +01:00
|
|
|
| Expr "+" Expr { BinOp Add $1 $3 }
|
|
|
|
|
| Expr "-" Expr { BinOp Sub $1 $3 }
|
|
|
|
|
| Expr "*" Expr { BinOp Mul $1 $3 }
|
|
|
|
|
| Expr "/" Expr { BinOp Div $1 $3 }
|
|
|
|
|
| Expr "%" Expr { BinOp Mod $1 $3 }
|
|
|
|
|
| Expr "**" Expr { BinOp Pow $1 $3 }
|
|
|
|
|
| Expr "==" Expr { BinOp Eq $1 $3 }
|
|
|
|
|
| Expr "!=" Expr { BinOp Ne $1 $3 }
|
|
|
|
|
| Expr "<" Expr { BinOp Lt $1 $3 }
|
|
|
|
|
| Expr "<=" Expr { BinOp Le $1 $3 }
|
|
|
|
|
| Expr ">" Expr { BinOp Gt $1 $3 }
|
|
|
|
|
| Expr ">=" Expr { BinOp Ge $1 $3 }
|
|
|
|
|
| Expr "===" Expr { BinOp TEq $1 $3 }
|
|
|
|
|
| Expr "!==" Expr { BinOp TNe $1 $3 }
|
|
|
|
|
| Expr "==?" Expr { BinOp WEq $1 $3 }
|
|
|
|
|
| Expr "!=?" Expr { BinOp WNe $1 $3 }
|
|
|
|
|
| Expr "<<" Expr { BinOp ShiftL $1 $3 }
|
|
|
|
|
| Expr ">>" Expr { BinOp ShiftR $1 $3 }
|
|
|
|
|
| Expr "<<<" Expr { BinOp ShiftAL $1 $3 }
|
|
|
|
|
| Expr ">>>" Expr { BinOp ShiftAR $1 $3 }
|
|
|
|
|
-- unary expressions
|
|
|
|
|
| "!" Expr { UniOp LogNot $2 }
|
|
|
|
|
| "~" Expr { UniOp BitNot $2 }
|
|
|
|
|
| "+" Expr %prec REDUCE_OP { UniOp UniAdd $2 }
|
|
|
|
|
| "-" Expr %prec REDUCE_OP { UniOp UniSub $2 }
|
|
|
|
|
| "&" Expr %prec REDUCE_OP { UniOp RedAnd $2 }
|
|
|
|
|
| "~&" Expr %prec REDUCE_OP { UniOp RedNand $2 }
|
|
|
|
|
| "|" Expr %prec REDUCE_OP { UniOp RedOr $2 }
|
|
|
|
|
| "~|" Expr %prec REDUCE_OP { UniOp RedNor $2 }
|
|
|
|
|
| "^" Expr %prec REDUCE_OP { UniOp RedXor $2 }
|
|
|
|
|
| "~^" Expr %prec REDUCE_OP { UniOp RedXnor $2 }
|
|
|
|
|
| "^~" Expr %prec REDUCE_OP { UniOp RedXnor $2 }
|
2019-03-02 02:26:44 +01:00
|
|
|
|
2020-06-14 21:56:09 +02:00
|
|
|
ExprOrNil :: { Expr }
|
|
|
|
|
: Expr { $1 }
|
|
|
|
|
| {- empty -} { Nil }
|
|
|
|
|
|
2021-06-20 21:30:21 +02:00
|
|
|
PatternItems :: { [(TypeOrExpr, Expr)] }
|
2019-10-14 01:01:42 +02:00
|
|
|
: PatternNamedItems { $1 }
|
2021-06-20 21:30:21 +02:00
|
|
|
| PatternUnnamedItems { zip (repeat $ Right Nil) $1 }
|
|
|
|
|
PatternNamedItems :: { [(TypeOrExpr, Expr)] }
|
2019-03-02 02:26:44 +01:00
|
|
|
: PatternNamedItem { [$1] }
|
|
|
|
|
| PatternNamedItems "," PatternNamedItem { $1 ++ [$3] }
|
2021-06-20 21:30:21 +02:00
|
|
|
PatternNamedItem :: { (TypeOrExpr, Expr) }
|
|
|
|
|
: PatternName ":" Expr { ($1, $3) }
|
|
|
|
|
PatternName :: { TypeOrExpr }
|
|
|
|
|
: Expr { Right $1 }
|
|
|
|
|
| PartialType { Left $ $1 Unspecified [] }
|
|
|
|
|
| "default" { Left UnknownType }
|
2019-03-02 02:26:44 +01:00
|
|
|
PatternUnnamedItems :: { [Expr] }
|
2019-10-12 04:54:21 +02:00
|
|
|
: PatternUnnamedItem { [$1] }
|
|
|
|
|
| PatternUnnamedItems "," PatternUnnamedItem { $1 ++ [$3] }
|
|
|
|
|
PatternUnnamedItem :: { Expr }
|
|
|
|
|
: Expr { $1 }
|
|
|
|
|
| Expr Concat { Repeat $1 $2 }
|
2019-02-08 05:49:12 +01:00
|
|
|
|
2019-09-02 00:42:13 +02:00
|
|
|
Concat :: { [Expr] }
|
|
|
|
|
: "{" Exprs "}" { $2 }
|
|
|
|
|
|
|
|
|
|
StreamOp :: { StreamOp }
|
|
|
|
|
: "<<" { StreamL }
|
|
|
|
|
| ">>" { StreamR }
|
|
|
|
|
StreamSize :: { Expr }
|
2019-09-14 18:31:44 +02:00
|
|
|
: TypeNonIdent { DimsFn FnBits (Left $1) }
|
2019-09-02 00:42:13 +02:00
|
|
|
| Expr { $1 }
|
|
|
|
|
|
2019-02-18 00:33:20 +01:00
|
|
|
GenItemOrNull :: { GenItem }
|
|
|
|
|
: GenItem { $1 }
|
|
|
|
|
| ";" { GenNull }
|
|
|
|
|
|
|
|
|
|
GenItems :: { [GenItem] }
|
|
|
|
|
: {- empty -} { [] }
|
2020-02-09 02:07:10 +01:00
|
|
|
| GenItems ";" { $1 }
|
2019-02-18 00:33:20 +01:00
|
|
|
| GenItems GenItem { $1 ++ [$2] }
|
|
|
|
|
|
|
|
|
|
GenItem :: { GenItem }
|
2021-07-12 02:43:30 +02:00
|
|
|
: MITrace GenBlock { uncurry GenBlock $2 }
|
|
|
|
|
| MITrace NonGenerateModuleItem { genItemsToGenItem $ map GenModuleItem $ addMITrace $1 $2 }
|
|
|
|
|
| MITrace "generate" GenItems "endgenerate" { genItemsToGenItem $3 }
|
|
|
|
|
| MITrace ConditionalGenerateConstruct { $2 }
|
|
|
|
|
| MITrace LoopGenerateConstruct { $2 }
|
2019-04-23 20:38:44 +02:00
|
|
|
ConditionalGenerateConstruct :: { GenItem }
|
2019-02-18 00:33:20 +01:00
|
|
|
: "if" "(" Expr ")" GenItemOrNull "else" GenItemOrNull { GenIf $3 $5 $7 }
|
|
|
|
|
| "if" "(" Expr ")" GenItemOrNull %prec NoElse { GenIf $3 $5 GenNull }
|
2021-02-17 19:26:13 +01:00
|
|
|
| "case" "(" Expr ")" GenCases "endcase" { GenCase $3 $ validateCases $4 $5 }
|
2019-04-23 20:38:44 +02:00
|
|
|
LoopGenerateConstruct :: { GenItem }
|
2020-02-24 04:30:17 +01:00
|
|
|
: "for" "(" GenvarInitialization ";" Expr ";" GenvarIteration ")" GenItem { $3 $5 $7 $9 }
|
2019-02-18 00:33:20 +01:00
|
|
|
|
2019-10-01 05:03:55 +02:00
|
|
|
GenBlock :: { (Identifier, [GenItem]) }
|
2021-06-15 23:47:32 +02:00
|
|
|
: GenBlockBegin GenItems end StrTag {% checkTag $1 $4 ($1, $2) }
|
|
|
|
|
GenBlockBegin :: { Identifier }
|
|
|
|
|
: "begin" StrTag { $2 }
|
|
|
|
|
| Identifier ":" "begin" { $1 }
|
2019-03-08 22:03:29 +01:00
|
|
|
|
2019-02-18 00:33:20 +01:00
|
|
|
GenCases :: { [GenCase] }
|
2019-12-22 01:31:56 +01:00
|
|
|
: GenCase { [$1] }
|
2021-02-17 19:26:13 +01:00
|
|
|
| GenCase GenCases { $1 : $2 }
|
2019-02-18 00:33:20 +01:00
|
|
|
GenCase :: { GenCase }
|
2019-12-22 01:31:56 +01:00
|
|
|
: Exprs ":" GenItemOrNull { ($1, $3) }
|
|
|
|
|
| "default" opt(":") GenItemOrNull { ([], $3) }
|
2019-02-18 00:33:20 +01:00
|
|
|
|
2020-02-24 04:30:17 +01:00
|
|
|
GenvarInitialization :: { Expr -> (Identifier, AsgnOp, Expr) -> GenItem -> GenItem }
|
2021-06-30 20:24:35 +02:00
|
|
|
: "genvar" Identifier "=" Expr { \a b c -> genItemsToGenItem [GenModuleItem (Genvar $2), GenFor ($2, $4) a b c] }
|
2020-02-24 04:30:17 +01:00
|
|
|
| Identifier "=" Expr { GenFor ($1, $3) }
|
2019-04-23 20:38:44 +02:00
|
|
|
|
2019-03-05 00:25:14 +01:00
|
|
|
GenvarIteration :: { (Identifier, AsgnOp, Expr) }
|
2019-03-07 21:56:03 +01:00
|
|
|
: Identifier AsgnOp Expr { ($1, $2, $3) }
|
2020-07-12 23:06:27 +02:00
|
|
|
| IncOrDecOperator Identifier { ($2, AsgnOp $1, RawNum 1) }
|
|
|
|
|
| Identifier IncOrDecOperator { ($1, AsgnOp $2, RawNum 1) }
|
2019-03-05 00:25:14 +01:00
|
|
|
|
2019-03-07 21:56:03 +01:00
|
|
|
AsgnOp :: { AsgnOp }
|
2020-02-01 21:52:52 +01:00
|
|
|
: "=" { AsgnOpEq }
|
|
|
|
|
| AsgnBinOp { $1 }
|
|
|
|
|
AsgnBinOp :: { AsgnOp }
|
2021-07-03 19:23:33 +02:00
|
|
|
: AsgnBinOpP { snd $1 }
|
|
|
|
|
AsgnBinOpP :: { (Position, AsgnOp) }
|
|
|
|
|
: "+=" { withPos $1 $ AsgnOp Add }
|
|
|
|
|
| "-=" { withPos $1 $ AsgnOp Sub }
|
|
|
|
|
| "*=" { withPos $1 $ AsgnOp Mul }
|
|
|
|
|
| "/=" { withPos $1 $ AsgnOp Div }
|
|
|
|
|
| "%=" { withPos $1 $ AsgnOp Mod }
|
|
|
|
|
| "&=" { withPos $1 $ AsgnOp BitAnd }
|
|
|
|
|
| "|=" { withPos $1 $ AsgnOp BitOr }
|
|
|
|
|
| "^=" { withPos $1 $ AsgnOp BitXor }
|
|
|
|
|
| "<<=" { withPos $1 $ AsgnOp ShiftL }
|
|
|
|
|
| ">>=" { withPos $1 $ AsgnOp ShiftR }
|
|
|
|
|
| "<<<=" { withPos $1 $ AsgnOp ShiftAL }
|
|
|
|
|
| ">>>=" { withPos $1 $ AsgnOp ShiftAR }
|
2019-03-05 00:25:14 +01:00
|
|
|
|
|
|
|
|
IncOrDecOperator :: { BinOp }
|
2021-07-03 19:23:33 +02:00
|
|
|
: IncOrDecOperatorP { snd $1 }
|
|
|
|
|
IncOrDecOperatorP :: { (Position, BinOp) }
|
|
|
|
|
: "++" { withPos $1 Add }
|
|
|
|
|
| "--" { withPos $1 Sub }
|
2019-02-08 05:49:12 +01:00
|
|
|
|
2019-09-14 18:31:44 +02:00
|
|
|
DimsFn :: { DimsFn }
|
|
|
|
|
: "$bits" { FnBits }
|
|
|
|
|
| "$dimensions" { FnDimensions }
|
|
|
|
|
| "$unpacked_dimensions" { FnUnpackedDimensions }
|
|
|
|
|
DimFn :: { DimFn }
|
|
|
|
|
: "$left" { FnLeft }
|
|
|
|
|
| "$right" { FnRight }
|
|
|
|
|
| "$low" { FnLow }
|
|
|
|
|
| "$high" { FnHigh }
|
|
|
|
|
| "$increment" { FnIncrement }
|
|
|
|
|
| "$size" { FnSize }
|
|
|
|
|
|
2020-01-31 04:17:17 +01:00
|
|
|
MITrace :: { ModuleItem }
|
|
|
|
|
: PITrace { MIPackageItem $1 }
|
|
|
|
|
PITrace :: { PackageItem }
|
2021-07-12 02:43:30 +02:00
|
|
|
: DeclTrace { Decl $1 }
|
2021-06-25 06:15:46 +02:00
|
|
|
CITrace :: { ClassItem }
|
|
|
|
|
: PITrace { (QNone, $1) }
|
2021-07-12 02:43:30 +02:00
|
|
|
DeclTrace :: { Decl }
|
|
|
|
|
: Trace { CommentDecl $1 }
|
2020-01-31 04:17:17 +01:00
|
|
|
StmtTrace :: { Stmt }
|
|
|
|
|
: Trace { CommentStmt $1 }
|
|
|
|
|
Trace :: { String }
|
|
|
|
|
: position { "Trace: " ++ show $1 }
|
|
|
|
|
position :: { Position }
|
2021-04-21 01:47:55 +02:00
|
|
|
: {- empty -} {% gets pPosition }
|
2020-01-31 04:17:17 +01:00
|
|
|
|
2021-03-06 21:03:04 +01:00
|
|
|
end : "end" {} | error {% missingToken "end" }
|
2021-03-23 01:01:38 +01:00
|
|
|
endclass : "endclass" {} | error {% missingToken "endclass" }
|
2021-03-06 21:03:04 +01:00
|
|
|
endfunction : "endfunction" {} | error {% missingToken "endfunction" }
|
|
|
|
|
endgenerate : "endgenerate" {} | error {% missingToken "endgenerate" }
|
|
|
|
|
endinterface : "endinterface" {} | error {% missingToken "endinterface" }
|
|
|
|
|
endmodule : "endmodule" {} | error {% missingToken "endmodule" }
|
|
|
|
|
endpackage : "endpackage" {} | error {% missingToken "endpackage" }
|
|
|
|
|
endtask : "endtask" {} | error {% missingToken "endtask" }
|
|
|
|
|
join : "join" {} | error {% missingToken "join" }
|
|
|
|
|
|
2019-02-08 05:49:12 +01:00
|
|
|
{
|
2019-03-04 08:58:00 +01:00
|
|
|
|
2021-04-21 01:47:55 +02:00
|
|
|
data ParseData = ParseData
|
|
|
|
|
{ pPosition :: Position
|
|
|
|
|
, pTokens :: [Token]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ParseState = StateT ParseData (ExceptT String IO)
|
|
|
|
|
|
|
|
|
|
parse :: [Token] -> ExceptT String IO AST
|
|
|
|
|
parse [] = return []
|
|
|
|
|
parse tokens =
|
|
|
|
|
evalStateT parseMain initialState
|
|
|
|
|
where
|
|
|
|
|
position = tokenPosition $ head tokens
|
|
|
|
|
initialState = ParseData position tokens
|
2020-01-31 04:17:17 +01:00
|
|
|
|
|
|
|
|
positionKeep :: (Token -> ParseState a) -> ParseState a
|
|
|
|
|
positionKeep cont = do
|
2021-04-21 01:47:55 +02:00
|
|
|
tokens <- gets pTokens
|
2020-01-31 04:17:17 +01:00
|
|
|
case tokens of
|
|
|
|
|
[] -> cont TokenEOF
|
|
|
|
|
tok : toks -> do
|
2021-04-21 01:47:55 +02:00
|
|
|
put $ ParseData (tokenPosition tok) toks
|
2020-01-31 04:17:17 +01:00
|
|
|
cont tok
|
|
|
|
|
|
2021-07-03 19:23:33 +02:00
|
|
|
parseErrorTok :: Token -> ParseState a
|
|
|
|
|
parseErrorTok a = case a of
|
2021-03-06 21:03:04 +01:00
|
|
|
TokenEOF -> do
|
2021-04-21 01:47:55 +02:00
|
|
|
p <- gets pPosition
|
2021-07-03 19:23:33 +02:00
|
|
|
parseErrorM p "unexpected end of file"
|
|
|
|
|
Token t s p ->
|
|
|
|
|
parseErrorM p $ "unexpected token '" ++ s ++ "' (" ++ show t ++ ")"
|
|
|
|
|
|
|
|
|
|
parseErrorM :: Position -> String -> ParseState a
|
|
|
|
|
parseErrorM pos msg = throwError $ show pos ++ ": Parse error: " ++ msg
|
|
|
|
|
|
|
|
|
|
parseError :: Position -> String -> a
|
|
|
|
|
parseError pos msg = error $ show pos ++ ": Parse error: " ++ msg
|
2019-02-08 05:49:12 +01:00
|
|
|
|
2019-02-18 00:33:20 +01:00
|
|
|
genItemsToGenItem :: [GenItem] -> GenItem
|
|
|
|
|
genItemsToGenItem [x] = x
|
2021-06-30 20:24:35 +02:00
|
|
|
genItemsToGenItem xs = GenModuleItem $ Generate xs
|
2019-02-18 00:33:20 +01:00
|
|
|
|
2021-05-30 03:55:50 +02:00
|
|
|
combineDeclsAndStmts :: ([Decl], [Stmt]) -> ([Decl], [Stmt]) ->
|
|
|
|
|
ParseState ([Decl], [Stmt])
|
|
|
|
|
combineDeclsAndStmts (a1, b1) (a2, b2) =
|
|
|
|
|
if not (null b1) && not (null a2)
|
|
|
|
|
then do
|
|
|
|
|
p <- gets pPosition
|
2021-07-03 19:23:33 +02:00
|
|
|
parseErrorM p
|
|
|
|
|
"procedural block contains a declaration after a statement"
|
2021-05-30 03:55:50 +02:00
|
|
|
else return (a1 ++ a2, b1 ++ b2)
|
2019-03-04 20:25:38 +01:00
|
|
|
|
|
|
|
|
makeInput :: Decl -> Decl
|
2020-06-14 21:56:09 +02:00
|
|
|
makeInput (Variable Local t x a e) = Variable Input t x a e
|
|
|
|
|
makeInput (Variable Input t x a e) = Variable Input t x a e
|
2020-01-31 04:17:17 +01:00
|
|
|
makeInput (CommentDecl c) = CommentDecl c
|
2019-09-23 05:29:02 +02:00
|
|
|
makeInput other =
|
|
|
|
|
error $ "unexpected non-var or non-input decl: " ++ (show other)
|
2019-03-04 20:25:38 +01:00
|
|
|
|
2021-06-15 23:47:32 +02:00
|
|
|
checkTag :: String -> String -> a -> ParseState a
|
|
|
|
|
checkTag _ "" x = return x
|
|
|
|
|
checkTag "" b _ = do
|
|
|
|
|
p <- gets pPosition
|
2021-07-03 19:23:33 +02:00
|
|
|
parseErrorM p $ "block has only end label " ++ show b
|
2021-06-15 23:47:32 +02:00
|
|
|
checkTag a b x =
|
2019-03-18 19:41:09 +01:00
|
|
|
if a == b
|
2021-06-15 23:47:32 +02:00
|
|
|
then return x
|
|
|
|
|
else do
|
|
|
|
|
p <- gets pPosition
|
2021-07-03 19:23:33 +02:00
|
|
|
parseErrorM p $ "element " ++ show a
|
2021-06-15 23:47:32 +02:00
|
|
|
++ " has mismatched end label " ++ show b
|
2019-03-18 19:41:09 +01:00
|
|
|
|
2019-04-23 02:44:35 +02:00
|
|
|
toLHS :: Expr -> LHS
|
|
|
|
|
toLHS expr =
|
|
|
|
|
case exprToLHS expr of
|
|
|
|
|
Just lhs -> lhs
|
|
|
|
|
Nothing -> error $ "Parse error: cannot convert expression to LHS: "
|
|
|
|
|
++ show expr
|
2019-08-30 02:52:01 +02:00
|
|
|
|
2021-07-12 02:43:30 +02:00
|
|
|
traceCommentDecl :: Position -> Decl
|
|
|
|
|
traceCommentDecl = CommentDecl . ("Trace: " ++) . show
|
|
|
|
|
|
2019-08-30 02:52:01 +02:00
|
|
|
makeParamDecls
|
2021-07-12 02:43:30 +02:00
|
|
|
:: (Position, ParamScope)
|
2019-08-30 02:52:01 +02:00
|
|
|
-> Type
|
|
|
|
|
-> [(Identifier, Expr, [Range])]
|
|
|
|
|
-> [Decl]
|
2021-07-12 02:43:30 +02:00
|
|
|
makeParamDecls (p, s) t items =
|
|
|
|
|
traceCommentDecl p :
|
2019-08-30 02:52:01 +02:00
|
|
|
map mapper items
|
|
|
|
|
where
|
|
|
|
|
(tf, rs) = typeRanges t
|
2019-09-07 04:29:14 +02:00
|
|
|
mapper (x, e, a) = Param s (tf $ a ++ rs) x e
|
2019-08-30 02:52:01 +02:00
|
|
|
|
2021-07-12 02:43:30 +02:00
|
|
|
makeParamTypeDecls :: (Position, ParamScope) -> [(Identifier, Type)] -> [Decl]
|
|
|
|
|
makeParamTypeDecls (p, s) items =
|
|
|
|
|
traceCommentDecl p :
|
|
|
|
|
map (uncurry $ ParamType s) items
|
|
|
|
|
|
2019-10-14 05:59:21 +02:00
|
|
|
fieldDecl :: Type -> (Identifier, [Range]) -> (Type, Identifier)
|
|
|
|
|
fieldDecl t (x, rs2) =
|
|
|
|
|
(tf $ rs2 ++ rs1, x)
|
|
|
|
|
where (tf, rs1) = typeRanges t
|
|
|
|
|
|
2021-02-17 19:26:13 +01:00
|
|
|
validateCases :: Token -> [([Expr], a)] -> [([Expr], a)]
|
|
|
|
|
validateCases tok items =
|
|
|
|
|
if length (filter (null . fst) items) <= 1
|
2019-12-22 01:31:56 +01:00
|
|
|
then items
|
2021-07-03 19:23:33 +02:00
|
|
|
else parseError (tokenPosition tok) "case has multiple defaults"
|
2021-02-17 19:26:13 +01:00
|
|
|
|
|
|
|
|
caseInsideKW :: Token -> CaseKW -> CaseKW
|
|
|
|
|
caseInsideKW _ CaseN = CaseInside
|
|
|
|
|
caseInsideKW tok kw =
|
2021-07-03 19:23:33 +02:00
|
|
|
parseError (tokenPosition tok) $ "cannot use inside with " ++ show kw
|
2021-02-17 19:26:13 +01:00
|
|
|
|
2021-02-17 19:35:10 +01:00
|
|
|
addMIAttr :: Attr -> ModuleItem -> ModuleItem
|
|
|
|
|
addMIAttr _ (item @ (MIPackageItem (Decl CommentDecl{}))) = item
|
|
|
|
|
addMIAttr attr item = MIAttr attr item
|
|
|
|
|
|
2021-03-06 21:03:04 +01:00
|
|
|
missingToken :: String -> ParseState a
|
|
|
|
|
missingToken expected = do
|
2021-04-21 01:47:55 +02:00
|
|
|
p <- gets pPosition
|
2021-07-03 19:23:33 +02:00
|
|
|
parseErrorM p $ "missing expected `" ++ expected ++ "`"
|
2021-03-06 21:03:04 +01:00
|
|
|
|
2021-04-29 21:32:54 +02:00
|
|
|
checkPortBindings :: [PortBinding] -> ParseState [PortBinding]
|
2021-05-21 20:02:29 +02:00
|
|
|
checkPortBindings [] = return []
|
|
|
|
|
checkPortBindings bindings =
|
|
|
|
|
checkBindings "port connections" $
|
|
|
|
|
if last bindings == ("", Nil)
|
|
|
|
|
then init bindings
|
|
|
|
|
else bindings
|
2021-04-29 21:32:54 +02:00
|
|
|
|
|
|
|
|
checkParamBindings :: [ParamBinding] -> ParseState [ParamBinding]
|
|
|
|
|
checkParamBindings = checkBindings "parameter overrides"
|
|
|
|
|
|
|
|
|
|
checkBindings :: String -> [(Identifier, a)] -> ParseState [(Identifier, a)]
|
|
|
|
|
checkBindings kind bindings =
|
|
|
|
|
if all null bindingNames || all (not . null) bindingNames then
|
|
|
|
|
return bindings
|
|
|
|
|
else do
|
|
|
|
|
p <- gets pPosition
|
2021-07-03 19:23:33 +02:00
|
|
|
parseErrorM p $ "illegal mix of ordered and named " ++ kind
|
2021-04-29 21:32:54 +02:00
|
|
|
where bindingNames = map fst bindings
|
|
|
|
|
|
2021-07-03 19:23:33 +02:00
|
|
|
withPos :: Token -> a -> (Position, a)
|
|
|
|
|
withPos tok = (tokenPosition tok, )
|
|
|
|
|
|
|
|
|
|
type PartialType = Signing -> [Range] -> Type
|
|
|
|
|
|
|
|
|
|
unexpectedPackedRanges :: Position -> String -> a
|
|
|
|
|
unexpectedPackedRanges pos typ =
|
|
|
|
|
parseError pos $ "unexpected packed range(s) applied to " ++ typ
|
|
|
|
|
|
|
|
|
|
unexpectedSigning :: Position -> Signing -> String -> a
|
|
|
|
|
unexpectedSigning pos sg typ =
|
|
|
|
|
parseError pos $ "unexpected " ++ show sg ++ " applied to " ++ typ
|
|
|
|
|
|
|
|
|
|
makeIntegerVector :: (Position, IntegerVectorType) -> PartialType
|
|
|
|
|
makeIntegerVector (_, typ) = IntegerVector typ
|
|
|
|
|
|
|
|
|
|
makeIntegerAtom :: (Position, IntegerAtomType) -> PartialType
|
|
|
|
|
makeIntegerAtom (_, typ) sg [] = IntegerAtom typ sg
|
|
|
|
|
makeIntegerAtom (pos, typ) _ _ = unexpectedPackedRanges pos (show typ)
|
|
|
|
|
|
|
|
|
|
makeNonInteger :: (Position, NonIntegerType) -> PartialType
|
|
|
|
|
makeNonInteger (_, typ) Unspecified [] = NonInteger typ
|
|
|
|
|
makeNonInteger (pos, typ) sg [] = unexpectedSigning pos sg (show typ)
|
|
|
|
|
makeNonInteger (pos, typ) Unspecified _ = unexpectedPackedRanges pos (show typ)
|
|
|
|
|
|
|
|
|
|
makeComplex :: Token -> ([Range] -> Type) -> (Position, PartialType)
|
|
|
|
|
makeComplex (Token _ str pos) tf = (pos, check)
|
|
|
|
|
where
|
|
|
|
|
check Unspecified = tf
|
|
|
|
|
check sg = unexpectedSigning pos sg str
|
|
|
|
|
|
|
|
|
|
makeTypeOf :: Token -> Expr -> (Position, PartialType)
|
|
|
|
|
makeTypeOf (Token _ _ pos) expr = (pos, check)
|
|
|
|
|
where
|
|
|
|
|
typ = TypeOf expr
|
|
|
|
|
check Unspecified [] = typ
|
|
|
|
|
check Unspecified _ = unexpectedPackedRanges pos (show typ)
|
|
|
|
|
check sg [] = unexpectedSigning pos sg (show typ)
|
|
|
|
|
|
2021-07-12 02:43:30 +02:00
|
|
|
addMITrace :: ModuleItem -> [ModuleItem] -> [ModuleItem]
|
|
|
|
|
addMITrace _ items @ (MIPackageItem (Decl CommentDecl{}) : _) = items
|
|
|
|
|
addMITrace trace items = trace : items
|
|
|
|
|
|
|
|
|
|
addPITrace :: PackageItem -> [PackageItem] -> [PackageItem]
|
|
|
|
|
addPITrace _ items @ (Decl CommentDecl{} : _) = items
|
|
|
|
|
addPITrace trace items = trace : items
|
|
|
|
|
|
|
|
|
|
addCITrace :: ClassItem -> [ClassItem] -> [ClassItem]
|
|
|
|
|
addCITrace _ items @ ((_, Decl CommentDecl{}) : _) = items
|
|
|
|
|
addCITrace trace items = trace : items
|
|
|
|
|
|
2021-07-14 21:50:12 +02:00
|
|
|
makeFor :: Either [Decl] [(LHS, Expr)] -> Expr -> [(LHS, AsgnOp, Expr)] -> Stmt -> Stmt
|
|
|
|
|
makeFor (Left inits) cond incr stmt =
|
|
|
|
|
Block Seq "" decls
|
|
|
|
|
[ CommentStmt msg
|
|
|
|
|
, For (catMaybes maybeAsgns) cond incr stmt
|
|
|
|
|
]
|
|
|
|
|
where
|
|
|
|
|
(decls, maybeAsgns) = unzip $ map splitInit inits
|
|
|
|
|
CommentDecl msg : _ = inits
|
|
|
|
|
makeFor (Right asgns) cond incr stmt = For asgns cond incr stmt
|
|
|
|
|
|
|
|
|
|
splitInit :: Decl -> (Decl, Maybe (LHS, Expr))
|
|
|
|
|
splitInit decl@CommentDecl{} = (decl, Nothing)
|
|
|
|
|
splitInit decl =
|
|
|
|
|
(Variable d t ident a Nil, Just (LHSIdent ident, e))
|
|
|
|
|
where Variable d t ident a e = decl
|
|
|
|
|
|
2019-02-08 05:49:12 +01:00
|
|
|
}
|