项目作者: Paebbels

项目描述 :
用VHDL实现的JSON库。
高级语言: VHDL
项目地址: git://github.com/Paebbels/JSON-for-VHDL.git
创建时间: 2015-09-01T16:41:25Z
项目社区:https://github.com/Paebbels/JSON-for-VHDL

开源协议:Other

下载


JSON-for-VHDL

CLA assistant

JSON-for-VHDL is a library to parse and query JSON data structures in VHDL. The
complete functionality is hosted in a single VHDL package, without special
dependencies.

Table of Content:

  1. Overview
  2. JSON - JavaScript Object Notation
  3. Short Example
  4. Download

1 Overview

The JSON-for-VHDL library can be used to parse and query JSON data structures, which
are read from disk. The data structure is read via VHDL file I/O functions and
procedures and parsed into a internal compressed representation. While the parsing is
done, a lightwight index is created to ease the navigation on the data structure.

Values can be selected by simple path expressions.

2 JSON - JavaScript Object Notation

JavaScript Object Notation (JSON) Data Interchange Format is specified in
RFC 7159.

3 Short Example

Here is a short example *.json file, which describes two common FPGA boards.

  1. { "ML505": {
  2. "FPGA": "XC5VLX50T-1FF1136",
  3. "Eth": [{
  4. "PHY-Int": "GMII",
  5. "Device": "MARVEL_88E1111",
  6. "Address": "0x74"
  7. }]
  8. },
  9. "KC705": {
  10. "FPGA": "XC7K325T-2FFG900C",
  11. "Eth": [{
  12. "PHY-Int": "GMII",
  13. "Device": "MARVEL_88E1111",
  14. "Address": "0x74"
  15. }],
  16. "IIC": [{
  17. "Type": "Switch",
  18. "Adr": "0x85",
  19. "Devices": [{
  20. "Name": "Si570",
  21. "Address": "0x3A"
  22. }]
  23. }]
  24. }
  25. }

Reference the JSON package in VHDL:

  1. use work.json.all;

Load a external *.json file, parse the data structure and select a value:

  1. architecture rtl of Test is
  2. constant ConfigFile : STRING := "Boards.json";
  3. constant JSONContent : T_JSON := jsonLoad(ConfigFile);
  4. begin
  5. assert (JSONContent.Error(1) = C_JSON_NUL)
  6. report "Error: " & JSONContent.Error
  7. severity ERROR;
  8. assert FALSE
  9. report "Query='KC705/Eth/0/Address' Value='" & jsonGetString(JSONContent, "KC705/Eth/0/Address") & "'"
  10. severity NOTE;
  11. -- print the compressed file content
  12. -- assert FALSE
  13. -- report "JSON: " & JSONContent.Content severity NOTE;
  14. end architecture;

4 Download

The library can be downloaded as a zip-file (latest ‘master’ branch) or
cloned with git from GitHub. GitHub offers HTTPS and SSH as transfer protocols.

For SSH protocol use the URL ssh://git@github.com:Paebbels/JSON-for-VHDL.git or command
line instruction:

  1. cd <GitRoot>
  2. git clone ssh://git@github.com:Paebbels/JSON-for-VHDL.git JSON

For HTTPS protocol use the URL https://github.com/Paebbels/JSON-for-VHDL.git or command
line instruction:

  1. cd <GitRoot>
  2. git clone https://github.com/Paebbels/JSON-for-VHDL.git JSON