| Crates.io | oak-verilog |
| lib.rs | oak-verilog |
| version | 0.0.1 |
| created_at | 2025-10-21 17:41:03.444679+00 |
| updated_at | 2026-01-23 05:21:29.190683+00 |
| description | Verilog language parser with support for modern Verilog syntax and features. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1894200 |
| size | 80,171 |
High-performance incremental Verilog parser for the oak ecosystem with flexible configuration, optimized for hardware description and verification.
Oak Verilog is a robust parser for Verilog, designed to handle complete Verilog syntax including modern features. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for hardware description and verification.
Basic example:
use oak_verilog::{Parser, VerilogLanguage, SourceText};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = Parser::new();
let source = SourceText::new(r#"
module counter (
input wire clk,
input wire reset,
output reg [3:0] count
);
always @(posedge clk or posedge reset) begin
if (reset)
count <= 4'b0000;
else
count <= count + 1;
end
endmodule
"#);
let result = parser.parse(&source);
println!("Parsed Verilog successfully.");
Ok(())
}
use oak_verilog::{Parser, VerilogLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
module full_adder (
input a, b, cin,
output sum, cout
);
assign sum = a ^ b ^ cin;
assign cout = (a & b) | (b & cin) | (a & cin);
endmodule
"#);
let result = parser.parse(&source);
println!("Module parsed successfully.");
use oak_verilog::{Parser, VerilogLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
module d_flip_flop (
input wire clk,
input wire d,
output reg q
);
always @(posedge clk) begin
q <= d;
end
endmodule
"#);
let result = parser.parse(&source);
println!("Sequential logic parsed successfully.");
use oak_verilog::{Parser, VerilogLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new("module test(); endmodule");
let result = parser.parse(&source);
println!("Token parsing completed.");
use oak_verilog::{Parser, VerilogLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
module broken_module (
input wire clk,
// Missing closing parenthesis
output reg [3:0] count
);
always @(posedge clk begin
count <= count + 1;
end
endmodule
"#);
let result = parser.parse(&source);
if let Some(errors) = result.result.err() {
println!("Parse errors found: {:?}", errors);
} else {
println!("Parsed successfully.");
}
The parser generates a comprehensive AST with the following main structures:
Oak Verilog integrates seamlessly with:
Check out the examples directory for comprehensive examples:
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.