VERILOG parser

The header <lorina/verilog.hpp> implements methods to parse a very simplistic version of the VERILOG format.

The class lorina::verilog_reader provides the following public member functions.

Function Description
on_module_header(module_name, inouts) Callback method for parsed module header
on_inputs(inputs) Callback method for parsed input declarations
on_outputs(outputs) Callback method for parsed output declarations
on_wires(wires) Callback method for parsed wire declarations
on_assign(lhs, rhs) Callback method for parsed immediate assignment
on_and(lhs, op1, op2) Callback method for parsed AND assignment (with 2 operands)
on_or(lhs, op1, op2) Callback method for parsed OR assignment (with 2 operands)
on_xor(lhs, op1, op2) Callback method for parsed XOR assignment (with 2 operands)
on_and3(lhs, op1, op2, op3) Callback method for parsed AND assignment (with 3 operands)
on_or3(lhs, op1, op2, op3) Callback method for parsed OR assignment (with 3 operands)
on_xor3(lhs, op1, op2, op3) Callback method for parsed XOR assignment (with 3 operands)
on_maj3(lhs, op1, op2, op3) Callback method for parsed MAJ3 assignment
on_endmodule Callback method for parsed end of module

The following reader functions are available.

Function
Description
read_verilog
Reader function for VERILOG format.
read_verilog
Reader function for VERILOG format.
return_code lorina::read_verilog(const std::string &filename, const verilog_reader &reader, diagnostic_engine *diag = nullptr)

Reader function for VERILOG format.

Reads a simplistic VERILOG format from a file and invokes a callback method for each parsed primitive and each detected parse error.

Return
Success if parsing have been successful, or parse error if parsing have failed
Parameters
  • filename: Name of the file
  • reader: A VERILOG reader with callback methods invoked for parsed primitives
  • diag: An optional diagnostic engine with callback methods for parse errors

return_code lorina::read_verilog(std::istream &in, const verilog_reader &reader, diagnostic_engine *diag = nullptr)

Reader function for VERILOG format.

Reads a simplistic VERILOG format from a stream and invokes a callback method for each parsed primitive and each detected parse error.

Return
Success if parsing have been successful, or parse error if parsing have failed
Parameters
  • in: Input stream
  • reader: A VERILOG reader with callback methods invoked for parsed primitives
  • diag: An optional diagnostic engine with callback methods for parse errors