Created
August 7, 2025 06:05
-
-
Save Arathi/f8aab3394b0a73a0a8f86f62caf6c1f0 to your computer and use it in GitHub Desktop.
MHRD的硬件设计语言
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| grammar Microhard; | |
| design: input_section output_section part_section wire_section; | |
| input_section: 'Inputs:' input (CM input)* SC; | |
| output_section: 'Outputs:' output (CM output)* SC; | |
| part_section: 'Parts:' part (CM part)* SC; | |
| wire_section: 'Wires:' wire (CM wire)* SC; | |
| input | |
| : input_pin_id | |
| | input_bus_id bus_size | |
| ; | |
| output | |
| : output_pin_id | |
| | output_bus_id bus_size | |
| ; | |
| input_pin_id: id; | |
| output_pin_id: id; | |
| input_bus_id: id; | |
| output_bus_id: id; | |
| id: ID; | |
| digit: DIGIT | PIN_VALUE; | |
| bus_size: BL number BR; | |
| number: digit+; | |
| part: part_id part_type; | |
| part_id: id; | |
| part_type: PART_TYPE; | |
| wire: start TO end; | |
| start | |
| : pin_value | |
| | input_pin | |
| | input_bus | |
| | part_id DT output_pin | |
| | part_id DT output_bus | |
| ; | |
| end | |
| : output_pin | |
| | output_bus | |
| | part_id DT input_pin | |
| | part_id DT input_bus | |
| ; | |
| pin_value: PIN_VALUE; | |
| input_pin | |
| : input_pin_id | |
| | input_bus_id pin_selection | |
| ; | |
| output_pin | |
| : output_pin_id | |
| | output_bus_id pin_selection | |
| ; | |
| pin_selection: BL number BR; | |
| input_bus | |
| : input_bus_id | |
| | input_bus_id bus_selection | |
| ; | |
| output_bus | |
| : output_bus_id | |
| | output_bus_id bus_selection | |
| ; | |
| bus_selection: BL number CL number BR; | |
| ID: [a-z][0-9A-Za-z]*; | |
| PART_TYPE: [A-Z][0-9A-Z]*; | |
| DIGIT: [0-9]; | |
| PIN_VALUE: [01]; | |
| CM: ','; | |
| SC: ';'; | |
| BL: '['; | |
| BR: ']'; | |
| TO: '->'; | |
| DT: '.'; | |
| CL: ':'; | |
| COMMENT: '//' (~[\n])* EOL -> skip; | |
| EOL: CR? LF -> skip; | |
| CR: '\r'; | |
| LF: '\n'; | |
| WS: [ \t\r\n] -> skip; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment