diff --git a/.gitignore b/.gitignore index c436960..a131738 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ phi *.exe *.stackdump -./*.phi \ No newline at end of file +./*.phi +Examples/*.v \ No newline at end of file diff --git a/Examples/d_ff.v b/Examples/d_ff.v index b1eb2f9..3e02638 100644 --- a/Examples/d_ff.v +++ b/Examples/d_ff.v @@ -1,7 +1,7 @@ /* - Automatically generated by the Phi Compiler 0.0.1-dev (caef566) + Automatically generated by the Phi Compiler 0.0.1-dev (a8a7bc2) Do not modify. - Generated on: 2018-10-28 10:58:56 + Generated on: 2018-10-28 18:20:16 */ module dFlipFlop( @@ -11,8 +11,9 @@ module dFlipFlop( input reset ); +wire [64'd31:64'd0] v=x; reg [64'd31:64'd0] store; -always @ (posedge clock|negedge reset) begin // Cannot change to or as Verilog demands. +always @ (posedge clock|negedge reset) begin if (reset) begin @@ -22,6 +23,6 @@ end else begin store <= a; end end -b = store; // Cannot add assign here due to noncontextual translation. +b = store; endmodule diff --git a/Grammar/phi.yy b/Grammar/phi.yy index 915f9e5..4b108dc 100644 --- a/Grammar/phi.yy +++ b/Grammar/phi.yy @@ -254,9 +254,6 @@ statement: | block_based { $$ = $1; } - | error ';' { - $$ = err_placeholder; - } ; /* Blocks */ @@ -615,7 +612,7 @@ mux_block: ; labeled_expression_list: { $$ = ε; } - | KEYWORD_CASE number ':' expression ';' labeled_expression_list { + | KEYWORD_CASE expression ':' expression ';' labeled_expression_list { cst; stream << $2 << ": " << std::endl; stream << "__PHI__MUX__LAST = " << $4 << ';' << std::endl; stream << "break; " << std::endl; diff --git a/Makefile b/Makefile index 47a8150..8f7b561 100644 --- a/Makefile +++ b/Makefile @@ -91,3 +91,6 @@ $(BINARY): $(OBJECTS) $(CPP_OBJECTS) $(CPP_LY_OBJECTS) clean: rm -rf $(BUILD_DIR) rm -f $(BINARY) + rm -f Examples/*.v + rm -f ./*.phi + rm -f *.exe *.stackdump # MSYS2/Windows diff --git a/Specifications/1. Organization.md b/Specifications/1. Organization.md index e677d5a..ff1352b 100644 --- a/Specifications/1. Organization.md +++ b/Specifications/1. Organization.md @@ -30,13 +30,13 @@ In Phi, it looks very similar, just with a different syntax: ```phi module Counter( - clock: Clock, - reset: ResetAsyncLow, + clock: Input, + reset: @resetLow Input, output: Output[31..0] ) { Register[31..0] store = 32b0; - @ clock.posedge { + @ posedge clock { store.next = store + 1; } @@ -44,6 +44,4 @@ module Counter( } ``` -## Interfaces - -## Namespaces \ No newline at end of file +### TBC \ No newline at end of file diff --git a/Specifications/A. Lexemes.md b/Specifications/A. Lexemes.md index b1bffed..2f9f687 100644 --- a/Specifications/A. Lexemes.md +++ b/Specifications/A. Lexemes.md @@ -24,9 +24,6 @@ * **Wire** * **Register** -*annotation*: -* **@** *identifier* - *identifier*: * *starter* *ender* @@ -60,7 +57,7 @@ * **z** **x** *digit* *digit*: any of -* **0 1 2 3 4 5 6 7 8 9** +* **0 1 2 3 4 5 6 7 8 9 A B C D E F** *punctuator*: any of * **@ $ ! ~ + - * < > / % | & ^ ? : ; , = . { } [ ] ( ) >= <= &+ &- &> &< &>= &<=** \ No newline at end of file diff --git a/Specifications/B. Grammar.md b/Specifications/B. Grammar.md index 47bcd7b..5363fc7 100644 --- a/Specifications/B. Grammar.md +++ b/Specifications/B. Grammar.md @@ -1,124 +1,151 @@ # Draft: Grammar +## Top Level + *description*: * *declaration* *description* +* **namespace** *identifier* **{** *description* **}** * ε *declaration*: -* **module** *identifier* *template_declaration* **(** *port_declaration_list* **)** *inheritance* *block* -* **interface** *identifier* *template_declaration* **(** *port_declaration_list* **)** *inheritance* **;** +* **module** *identifier* *template-declaration* **(** *port-declaration-list* **)** *inheritance* *block* +* **interface** *identifier* *template-declaration* **(** *port-declaration-list* **)** *inheritance* **;** + -*port_declaration_list*: -* *populated_port_declaration_list* +## Ports + +*port-declaration-list*: +* *populated-port-declaration-list* * ε -*populated_port_declaration_list*: -* *identifier* **:** *expression* **,** *populated_port_declaration_list* +*populated-port-declaration-list*: +* *identifier* **:** *expression* **,** *populated-port-declaration-list* * *identifier* **:** *expression* -*port_declaration*: -* *port_polarity* -* *annotation* *port_polarity* -* **@resetLow** *port_polarity* +*port-declaration*: +* *port-polarity* +* **@** *identifier* *port-polarity* -*port_polarity*: -* **input** *optional_array_subscript* -* **output** *optional_array_subscript* +*port-polarity*: +* **Input** *optional-array-subscript* +* **Output** *optional-array-subscript* -*template_declaration*: -* **<** *template_declaration_list* **>** +## Templating +*template-declaration*: +* **<** *template-declaration-list* **>** -*template_declaration_list*: -* *identifier* *optional_template_assignment* *template_declaration_list* -* *identifier* *optional_template_assignment* +*template-declaration-list*: +* *identifier* *optional-template-assignment* *template-declaration-list* +* *identifier* *optional-template-assignment* -*optional_template_assignment*: -* **=** (*expression*) +*optional-template-assignment*: +* **=** **(** *expression* **)** * ε - +## Inheritance *inheritance*: -* **:** *inheritance_list* +* **:** *inheritance-list* * ε -*inheritance_list*: -* *lh_expression* **,** *inheritance_list* -* *lh_expression* - -*block*: -* **{** statement_list **}** - -*statement_list*: -* *statement_list* *statement* -* ε +*inheritance-list*: +* *lh-expression* **,** *inheritance-list* +* *lh-expression* +## Statements *statement*: * *subdeclaration* **;** -* *nondeclarative_statement* **;** -* *block_based* +* *nondeclarative-statement* **;** +* *block-based* -*block_based*: +*block-based*: +* *if* +* **for** *identifer* **in** *range* *block* * **namespace** *identifier* *block* +* **switch** *expression* *switch-block* * **@** *expression* *block* * **async** *block* -* *if* *if*: * **if** *expression* *block* *else* *else*: * **else** *if* -* **else** *expression* *block* +* **else** *block* * ε -*subdeclaration*: -* *subscriptable_dynamic_width* *declaration_list* -* *probable_template* *identifier* *ports* +*switch-block*: +* **{** *labeled-statement-list* **}** + +*labeled-statement-list*: +* **case** *expression* **:** *statement_list* *labeled_statement_list* +* **default** *expression* **:** *statement_list* +* ε + +*block*: +* **{** statement-list **}** + +*statement-list*: +* *statement_list* *statement* +* ε -*subscriptable_dynamic_width*: -* *dynamic_width* *optional_array_subscript* +## Subdeclarations +*subdeclaration*: +* *dynamic-width* *optional-array-subscript* *declaration-list* +* *probable-template* *identifier* *ports* -*dynamic_width*: +*dynamic-width*: * **Var** * **Wire** * **Register** -*declaration_list*: -* *identifier* *optional_array_subscript* *optional_assignment* **,** *declaration_list* -* *identifier* *optional_array_subscript* *optional_assignment* +*optional-array-subscript*: +* **[** *expression* **]** +* ε -*optional_assignment*: +*optional-ports*: +* *ports* +* ε + +*declaration-list*: +* *identifier* *optional-array-subscript* *optional-assignment* **,** *declaration-list* +* *identifier* *optional-array-subscript* *optional-assignment* + +*optional-assignment*: * **=** *expression* * ε -*probable_template*: +*probable-template*: * *expression* -* *expression* **<** *template_list* **>** +* *expression* **<** *template-list* **>** -*template_list*: -* *identifier* **:** **(** *expression* **)** **,** *template_list* +*template-list*: +* *identifier* **:** **(** *expression* **)** **,** *template-list* * *identifier* **:** **(** *expression* **)** * ε *ports*: * **(** **)** -* **(** *port_list* **)** +* **(** *port-list* **)** -*port_list*: -* *identifier* **:** *expression* **,** *port_list* +*port-list*: +* *identifier* **:** *expression* **,** *port-list* * *identifier* **:** *expression* -*nondeclarative_statement*: +## Nondeclarative Statements + +*nondeclarative-statement*: * *expression* **=** *expression* -*switch_block*: -* **{** *labeled_statement_list* **}** +*switch-block*: +* **{** *labeled-statement-list* **}** -*labeled_statement_list*: -* **case** number **:** *statement_list* *labeled_statement_list* -* **default** **:** *statement_list* +*labeled-statement-list*: +* **case** number **:** *statement-list* *labeled-statement-list* +* **default** **:** *statement-list* * ε +## Expressions + *expression*: * *expression* **?** *expression* **:** *expression* * *expression* **||** *expression* @@ -146,24 +173,27 @@ * *expression* **<<** *expression* * *expression* **>>>** *expression* * *expression* **>>** *expression* -* *expression* **..** *expression* +* *range* * *expression* **.** *expression* * *expression* **[** *expression* **]** * **&** *expression* * **|** *expression* * **~** *expression* * **[** *concatenation* **]** -* **mux** *expression* *mux_block* -* **$** *identifier* **(** *procedural_call* **)** +* **mux** *expression* *mux-block* +* **$** *identifier* **(** *procedural-call* **)** * **(** *expression* **)** * *identifier* * *number* -*mux_block*: -* **{** *labeled_expression_list* **}** +*range*: +* *expression* **..** *expression* + +*mux-block*: +* **{** *labeled-expression-list* **}** -*labeled_expression_list*: -* **case** *number* **:** *expression* **;** *labeled_expression_list* +*labeled-expression-list*: +* **case** *expression* **:** *expression* **;** *labeled-expression-list* * **default** **:** *expression* **;** * ε @@ -173,17 +203,17 @@ *concatenatable*: * *expression* -* *expression* **[[** expression **]]** +* *expression* **[[** *expression* **]]** -*procedural_call*: -* *procedural_call_list* +*procedural-call*: +* *procedural-call-list* * ε -*procedural_call_list*: -* *expression* **,** *procedural_call_list* +*procedural-call-list*: +* *expression* **,** *procedural-call-list* * *expression* -*array_subscript*: +*array-subscript*: * **[** *expression* **]** * ε diff --git a/Specifications/Readme.md b/Specifications/Readme.md index 0f743ff..8331ec2 100644 --- a/Specifications/Readme.md +++ b/Specifications/Readme.md @@ -1,3 +1,2 @@ -# NOTE: None of these are guaranteed to be up to date. - -I update these sporadically. \ No newline at end of file +## Documentation +Up to date as of tag 0.0.2 \ No newline at end of file diff --git a/run_tests.rb b/run_tests.rb index e7b6a1e..a8ec26d 100755 --- a/run_tests.rb +++ b/run_tests.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -Dir["Examples/*"].map do |item| +Dir["Examples/*.phi"].map do |item| puts "Testing #{item}..." testable = item testable += '/*' if File.directory?(item);