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

Account for nested records #4

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.PHONY: test
test:
for tb in $$(find ./test -name "*_tc.vhd"); do python3 -m vhdeps -i vhlib -i component -i test ghdl $$(basename -s .vhd $${tb}); done
testnest:
for tb in $$(find ./test -name "*ested*_tc.vhd"); do python3 -m vhdeps -i vhlib -i component -i test ghdl $$(basename -s .vhd $${tb}); done
28 changes: 21 additions & 7 deletions component/JsonRecordParser.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ begin
variable nesting_inner : std_logic_vector(INNER_NESTING_LEVEL downto 1) := (others => '0');

variable nesting_origo : std_logic;
variable is_top_record : std_logic;

begin

Expand Down Expand Up @@ -173,6 +174,7 @@ begin

nesting_inner := nesting_level_th(nesting_level_th'high downto 1);
nesting_origo := not or_reduce(nesting_inner);
is_top_record := nesting_level_th(0);

case state is
when STATE_IDLE =>
Expand Down Expand Up @@ -228,13 +230,25 @@ begin
end if;
when X"7D" => -- '}'
if nesting_origo = '1' then
state := STATE_IDLE;
od(idx).last(0) := '1';
od(idx).last(1) := '1';
od(idx).strb := '0';
if end_req_i = '1' then
end_ack_i := '1';
od(idx).last(2) := '1';
-- If this is still within the top record
-- E.g. { "key": { ... } }
-- ^
-- This will simply be treated as part of the value
if is_top_record = '1' then
state := STATE_VALUE;
-- Otherwise:
-- E.g. { "key": { ... } }
-- ^
-- This signals the end of the record.
else
state := STATE_IDLE;
od(idx).last(0) := '1';
od(idx).last(1) := '1';
od(idx).strb := '0';
if end_req_i = '1' then
end_ack_i := '1';
od(idx).last(2) := '1';
end if;
end if;
end if;
when others =>
Expand Down
Loading