Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework codec #822

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
e3590cd
Add new package for data_type with useful and common constants/functions
dalex78 Apr 28, 2022
37f9793
Redefine the API for the user, the advanced user and the VUnit develo…
dalex78 Apr 28, 2022
31b17af
Add the body of the functions code_length_type functions and document…
dalex78 Apr 28, 2022
929d3e2
Add the body of the encode/decode procedures for each predefined type…
dalex78 Apr 28, 2022
735e399
Add the body of the encode/decode procedures for each predefined type…
dalex78 Apr 28, 2022
3f90937
Add the body of the encode/decode functions for each predefined types…
dalex78 Apr 28, 2022
b963424
Add the body of the encode/decode functions for each predefined types…
dalex78 Apr 28, 2022
8b8c2db
Add the body of the decrecated functions. Test launch for data_type (…
dalex78 Apr 28, 2022
11d1139
Update the codec_2008 package declaration
dalex78 Apr 28, 2022
82e65e3
Test launch for data_type (125 tests) and com (132 tests) with Models…
dalex78 Apr 28, 2022
6776690
Update the generation of user created types (enumerated types only)
dalex78 Apr 28, 2022
7399e73
Update the generation of user created types (records types only)
dalex78 Apr 28, 2022
4b1dc95
Update the generation of user created types (array types only)
dalex78 Apr 28, 2022
6046a42
Update the generation of user created types.
dalex78 Apr 28, 2022
e2de513
Add documentation for https://vunit.github.i. There is a new page wh…
dalex78 Apr 28, 2022
4e7fd60
Corrected sources for compilation on Modelsim and elaboration with GH…
dalex78 Apr 30, 2022
7515a1f
Correct errors when compiling with GHDL. Add some tests without modif…
dalex78 Apr 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/data_types/codec.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.. _codec_pkg:

*codec* package
---------------

.. literalinclude:: ../../vunit/vhdl/data_types/src/codec.vhd
:language: vhdl
:lines: 22-229

.. literalinclude:: ../../vunit/vhdl/data_types/src/codec-2008p.vhd
:language: vhdl
:lines: 24-71
5 changes: 5 additions & 0 deletions docs/data_types/user_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ VUnit comes with a number of convenient data types included:
append and reshape operations, and reading/writing data to/from
*.csv* or *.raw* byte files.

VUnit **queue_t** (:ref:`Queue API <queue_pkg>`) functionality is built
on top of the **codec** (:ref:`Codec API <codec_pkg>`) package. The
codec (:ref:`Codec API <codec_pkg>`) package enable to encode any
predefined type into a unique type (each type is encoded into a string).

.. toctree::
:hidden:

Expand Down
44 changes: 28 additions & 16 deletions vunit/com/codec_datatype_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,40 @@ class DatatypeCodecTemplate(object):

to_string_declarations = Template(
"""\
function to_string (
constant data : $type)
return string;
-- Printing function for the type $type
function to_string(data : $type) return string;

"""
)

codec_declarations = Template(
"""\
function encode (
constant data : $type)
return string;
alias encode_$type is encode[$type return string];
function decode (
constant code : string)
return $type;
alias decode_$type is decode[string return $type];
procedure decode (
constant code : string;
variable index : inout positive;
variable result : out $type);
alias decode_$type is decode[string, positive, $type];
-----------------------------------------------------------------------------
-- Codec package extension for the type $type
-----------------------------------------------------------------------------

function encode_$type(data : $type) return code_t;
function decode_$type(code : code_t) return $type;
alias encode is encode_$type[$type return code_t];
alias decode is decode_$type[code_t return $type];
procedure encode_$type(
constant data : in $type;
variable index : inout code_index_t;
variable code : inout code_t
);
procedure decode_$type(
constant code : in code_t;
variable index : inout code_index_t;
variable result : out $type
);
alias encode is encode_$type[$type, code_index_t, code_t];
alias decode is decode_$type[code_t, code_index_t, $type];


-----------------------------------------------------------------------------
-- Queue package extension for the type $type
-----------------------------------------------------------------------------

procedure push(queue : queue_t; value : $type);
impure function pop(queue : queue_t) return $type;
alias push_$type is push[queue_t, $type];
Expand Down
1 change: 1 addition & 0 deletions vunit/com/codec_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def generate_codecs(
library vunit_lib;
use vunit_lib.string_ops.all;
context vunit_lib.com_context;
use vunit_lib.common_pkg.all;
use vunit_lib.queue_pkg.all;
use vunit_lib.queue_2008p_pkg.all;

Expand Down