/srm_rgen

Ruby gem for generating simple register model.

Primary LanguageRuby

This is a Ruby gem that is used for generating simple_register_model files.

Requires Ruby 2.0+ since it uses keyword arguments.

Overview

The gem provides a script srm_rgen takes a JSON format of the attirbutes of the register model. It then uses the ruby template engine "erb" to generate the simple_reg_model register description. By using a standard JSON file as the input, it allows easier integration with other register description languages like SystemRDL or other register generation tools.

The gem also provides Ruby library for creating the JSON format. Similar bindings for other OOP languages like Python can be created. [TBD]. The script srm_rb will evaluate the register description in ruby and generate the JSON file. This file can then be fed to srm_rgen to create the srm register model.

Run Sample Test

Clone this git repo and navigate to the tests directory.

Step 1: Ruby To JSON

The tests directory contains "cpu_reg32.rb" that describes a single 32b register, having 2 16b fields "field0" and "field1".

tests> ../bin/srm_rb -s cpu_reg32.rb
Creating "srm_regmodel.json" output file for register block "top"

The output JSON file is created as "srm_regmodel.json" by default.

Step2: JSON To SRM

The JSON file output can now be used to generate the SRM description.

tests>../bin/srm_spec -j srm_regmode.json 
Creating "srm_regmodel.sv" output file for register block