A SystemRDL 2.0 front-end for Ruby. It parses SystemRDL source, elaborates the described register model, and exposes it as plain Ruby objects so that back-end tools can generate RTL, documentation, software headers, and so on.
SystemRDL is a register description language standardized by Accellera. This gem targets the SystemRDL 2.0 specification.
Install the gem and add it to the application's Gemfile by executing:
bundle add systemrdlIf bundler is not being used to manage dependencies, install the gem by executing:
gem install systemrdlUse the methods below to compile SystemRDL into an elaborated model. Each method returns a list of the top-level address maps.
- Compile SystemRDL read from the given file path(s)
SystemRDL.compile
- Compile SystemRDL read from the given input stream(s)
SystemRDL.compile_streams
- Compile the given SystemRDL source string
SystemRDL.compile_source
SystemRDL.compile and SystemRDL.compile_streams accept multiple inputs.
The inputs are compiled in the given order and share their component definitions, so a component defined in an earlier input can be instantiated in a later one.
Note that this sharing is one-directional; an earlier input cannot refer to a component defined in a later one.
require 'systemrdl'
# Compile files
address_maps = SystemRDL.compile('gpio.rdl', 'pwm.rdl')
# Compile a source string
address_maps = SystemRDL.compile_source(<<~'RDL')
addrmap my_map {
reg {
field { sw = rw; hw = r; reset = 0x0; } value[32];
} data;
};
RDLAn elaborated model is a tree of address maps, registers, and fields. Each element carries the properties assigned to it in the source.
require 'systemrdl'
address_map = SystemRDL.compile_source(<<~'RDL').first
addrmap gpio {
name = "GPIO";
desc = "Simple general purpose I/O controller";
default sw = rw;
default hw = r;
reg {
name = "Port Direction";
field { desc = "0: input, 1: output"; reset = 0x0; } dir[32];
} direction;
reg {
name = "Input Data";
field { sw = r; hw = w; } value[32];
} data_in;
};
RDL
# GPIO: Simple general purpose I/O controller
puts "#{address_map.display_name}: #{address_map.desc}"
address_map.regs.each do |reg|
# direction @ 0x0
# data_in @ 0x4
puts "#{reg.name} @ 0x#{reg.address.to_s(16)}"
reg.fields.each do |field|
# dir [31:0] sw=rw hw=r
# value [31:0] sw=r hw=w
puts " #{field.name} [#{field.msb}:#{field.lsb}] sw=#{field.sw} hw=#{field.hw}"
end
endThe following SystemRDL 2.0 language features are supported (parsed and evaluated).
- The
addrmap,regfile,reg,field, andmemcomponents - Definitive and anonymous component definitions/instances
- Arrays of instances
- Address allocation operators (
@,+=,%=) internal/externalinstance types- Component parameters
- Most built-in properties of the supported components, except the
counterandinterruptproperty groups (see below) - Property assignment in all three forms: direct assignment, default assignment (
default), and dynamic assignment (->) - Property references and instance references as property values
Verilog-style compiler directives are supported:
- Text macros:
`define,`undef- Token concatenation with
``, string literal wrapped with`", and default values for macro arguments are not supported.
- Token concatenation with
- Conditional compilation:
`ifdef,`ifndef,`elsif,`else,`endif - File inclusion:
`include, with include search directories and a configurable nesting limit
The following features are not supported. Some of their keywords are recognized by the lexer (reserved), but they are not evaluated.
signalcomponent- User-defined properties (
propertydefinitions) - Enumerations (
enum) andencode structtypesconstraintaliasregisters- Counter field properties
- Interrupt field properties
- Embedded Perl preprocessing
- The
`linedirective
The design decisions behind this implementation, along with their rationale, are documented under two directories.
The spec_notes directory focuses on parts of the SystemRDL specification that are open to interpretation or left unspecified, and explains how this implementation resolves them.
The design_notes directory covers implementation design decisions.
Bug reports and pull requests are welcome on GitHub at https://github.com/taichi-ishitani/systemrdl.
Copyright © 2026 Taichi Ishitani. SystemRDL is licensed under the terms of the MIT License, see LICENSE.txt for further details.