Skip to content

Commit 96d5018

Browse files
authored
Merge pull request #790 from diffblue/multiplexer1
Verilog: grammar for combinational UDPs
2 parents 76c9657 + 127e639 commit 96d5018

File tree

3 files changed

+140
-19
lines changed

3 files changed

+140
-19
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
multiplexer1.sv
3+
--bound 0 --module main
4+
^no properties$
5+
^EXIT=10$
6+
^SIGNAL=0$
7+
--
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// 1800-2017 29.4
2+
primitive multiplexer (mux, control, dataA, dataB);
3+
output mux;
4+
input control, dataA, dataB;
5+
table
6+
// control dataA dataB mux
7+
0 1 0 : 1 ;
8+
0 1 1 : 1 ;
9+
0 1 x : 1 ;
10+
0 0 0 : 0 ;
11+
0 0 1 : 0 ;
12+
0 0 x : 0 ;
13+
1 0 1 : 1 ;
14+
1 1 1 : 1 ;
15+
1 x 1 : 1 ;
16+
1 0 0 : 0 ;
17+
1 1 0 : 0 ;
18+
1 x 0 : 0 ;
19+
x 0 0 : 0 ;
20+
x 1 1 : 1 ;
21+
endtable
22+
endprimitive
23+
24+
module main;
25+
endmodule

src/verilog/parser.y

Lines changed: 108 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,12 @@ parameter_port_list_opt:
771771
{ init($$); }
772772
;
773773

774+
list_of_ports_opt:
775+
/* Optional */
776+
{ make_nil($$); }
777+
| list_of_ports
778+
;
779+
774780
list_of_ports: '(' port_brace ')' { $$ = $2; }
775781
;
776782

@@ -2770,14 +2776,34 @@ constant_expression: expression;
27702776
// System Verilog standard 1800-2017
27712777
// A.5.1 UDP declaration
27722778

2773-
udp_declaration: attribute_instance_brace TOK_PRIMITIVE udp_identifier
2774-
'(' udp_port_list ')' ';' udp_port_declaration_brace
2775-
udp_body TOK_ENDPRIMITIVE
2776-
| attribute_instance_brace TOK_PRIMITIVE udp_identifier
2777-
'(' udp_declaration_port_list ')' ';'
2778-
udp_body TOK_ENDPRIMITIVE
2779+
udp_nonansi_declaration:
2780+
attribute_instance_brace
2781+
TOK_PRIMITIVE udp_identifier '(' udp_port_list ')' ';'
27792782
;
27802783

2784+
udp_ansi_declaration:
2785+
attribute_instance_brace
2786+
TOK_PRIMITIVE udp_identifier '(' udp_declaration_port_list ')' ';'
2787+
;
2788+
2789+
udp_declaration:
2790+
udp_nonansi_declaration
2791+
udp_port_declaration
2792+
udp_port_declaration_brace
2793+
udp_body
2794+
TOK_ENDPRIMITIVE
2795+
| udp_ansi_declaration
2796+
udp_body
2797+
TOK_ENDPRIMITIVE
2798+
| TOK_EXTERN udp_nonansi_declaration
2799+
| TOK_EXTERN udp_ansi_declaration
2800+
| attribute_instance_brace
2801+
TOK_PRIMITIVE udp_identifier '(' ')' ';'
2802+
udp_port_declaration_brace
2803+
udp_body
2804+
TOK_ENDPRIMITIVE
2805+
;
2806+
27812807
// System Verilog standard 1800-2017
27822808
// A.5.2 UDP ports
27832809

@@ -2823,31 +2849,94 @@ port_identifier_brace:
28232849
// System Verilog standard 1800-2017
28242850
// A.5.3 UDP body
28252851

2826-
udp_body: udp_initial_statement_opt TOK_TABLE table_entry_brace TOK_ENDTABLE
2852+
udp_body: combinational_body ;
2853+
2854+
combinational_body:
2855+
TOK_TABLE
2856+
combinational_entry_brace
2857+
TOK_ENDTABLE
2858+
;
2859+
2860+
combinational_entry_brace:
2861+
combinational_entry
2862+
| combinational_entry_brace combinational_entry
2863+
;
2864+
2865+
combinational_entry:
2866+
level_input_list TOK_COLON output_symbol ';'
2867+
;
2868+
2869+
sequential_body:
2870+
udp_initial_statement_opt
2871+
TOK_TABLE sequential_entry_brace TOK_ENDTABLE
28272872
;
28282873

28292874
udp_initial_statement_opt:
2875+
/* Optional */
2876+
| udp_initial_statement
28302877
;
28312878

2832-
table_entry_brace:
2833-
table_entry
2834-
| table_entry_brace table_entry
2879+
udp_initial_statement:
2880+
TOK_INITIAL output_port_identifier '=' init_val ';'
28352881
;
28362882

2837-
table_entry: input_list TOK_COLON output_or_level_symbol ';'
2838-
| input_list TOK_COLON output_or_level_symbol TOK_COLON next_state ';'
2883+
output_port_identifier: new_identifier
28392884
;
28402885

2841-
input_list:;
2886+
init_val:
2887+
// Really 1'b0 | 1'b1 | 1'bx | 1'bX | 1'B0 | 1'B1 | 1'Bx | 1'BX | 1 | 0
2888+
TOK_NUMBER
2889+
| new_identifier
2890+
;
28422891

2843-
output_or_level_symbol:;
2892+
sequential_entry_brace:
2893+
sequential_entry
2894+
| sequential_entry_brace sequential_entry
2895+
;
28442896

2845-
next_state:;
2897+
sequential_entry:
2898+
seq_input_list TOK_COLON current_state TOK_COLON next_state
2899+
;
28462900

2847-
list_of_ports_opt:
2848-
/* Optional */
2849-
{ make_nil($$); }
2850-
| list_of_ports
2901+
seq_input_list: level_input_list | edge_input_list
2902+
;
2903+
2904+
edge_indicator:
2905+
'(' level_symbol level_symbol ')' | edge_symbol
2906+
;
2907+
2908+
current_state: level_symbol ;
2909+
2910+
next_state: output_symbol | '-' ;
2911+
2912+
level_input_list:
2913+
level_symbol
2914+
| level_input_list level_symbol
2915+
;
2916+
2917+
edge_input_list: level_symbol_brace edge_indicator level_symbol_brace ;
2918+
2919+
output_symbol:
2920+
// Really 0 | 1 | x | X
2921+
TOK_NUMBER
2922+
| new_identifier
2923+
;
2924+
2925+
level_symbol_brace:
2926+
level_symbol
2927+
| level_symbol_brace level_symbol
2928+
;
2929+
2930+
level_symbol:
2931+
// Really 0 | 1 | x | X | ? | b | B
2932+
TOK_NUMBER
2933+
| new_identifier
2934+
;
2935+
2936+
edge_symbol:
2937+
// Really r | R | f | F | p | P | n | N | *
2938+
TOK_NUMBER
2939+
| new_identifier
28512940
;
28522941

28532942
// System Verilog standard 1800-2017

0 commit comments

Comments
 (0)