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

PatternBurst before MacroDefs? #52

Open
danbodoh opened this issue Jun 28, 2022 · 6 comments · Fixed by #57
Open

PatternBurst before MacroDefs? #52

danbodoh opened this issue Jun 28, 2022 · 6 comments · Fixed by #57
Assignees

Comments

@danbodoh
Copy link
Contributor

Is this really part of the spec? I have a stil written from a industry standard tool that has MacroDefs prior to PatternBurst. But the Pattern block is after the PatternBurst

lark.exceptions.VisitError: Error trying to process rule "b_macrodefs__OPEN_MACRO_DEFS_BLOCK":

Expected PatternBurst block before any MacroDefs block

@seimit seimit self-assigned this Jun 28, 2022
@seimit
Copy link
Collaborator

seimit commented Jun 28, 2022

Hi Dan,
Here is the long answer. The short answer is after that :-).
Probably you are aware of "7.1 Top-level statements and required ordering" in IEEE 1450.0 standard.
There are few exception in the "define before use" rule. One of this is the Pattern block reference in the PatternBurst, because the pattern blocks must be the last blocks in the file. The other is related to MacroDefs and Procedures. According the standard they "may or may not be forward references". For me this means that they can be before the PatternBurst/Exec block as well.
According Table 7, the MacroDefs and Procedures are between the PatternExec and Pattern block. The semantic analyzer was built based the information on this table. This was the most easy way to implement, because:

  • If the MacroDefs and Procedures are before the PatternBurst blocks, it is unknown which SignalGroups block will be used. This means that the code must wait PatternBurst appearance to process the MacroDefs and Procedures block.
  • If the MacroDefs and Procedures are before the PatternExec blocks, it is unknown which Timing block will be used. This means that the code must wait PatternExec appearance to process the MacroDefs and Procedures block.

So the short answer is : yes, it is part of the spec. However the MacroDefs and Procedures before PatternBurst/Exec is allowed as well, but not implemented in the current version of the library.

I can check what efforts are needed to implement it, but for sure I can not make it in the next 2 weeks.
Kind Regards,
Seimit

@danbodoh
Copy link
Contributor Author

Just doing some reading about Lark, which I've never used. Can you hack the Tree to move MacroDefs and Procedures after PatternBurst/Exec?

@seimit
Copy link
Collaborator

seimit commented Jun 28, 2022

The problem is not in the Lark. You can see in the stil.lark file that all blocks are with "|" which means that the order of all blocks is not important.
The problem is in the semantic analyzer. I can easy remove this restriction in the MacroDefsBlockParser.py , method "b_macrodefs__OPEN_MACRO_DEFS_BLOCK", but I have to remove also all semantic checks for signals/timings inside Macro/Procs.

@danbodoh
Copy link
Contributor Author

danbodoh commented Jun 28, 2022 via email

@seimit
Copy link
Collaborator

seimit commented Jul 1, 2022

Hi Dan,
I removed the semantic check for order of Procedure and MacroDefs blocks.
Note, that Semi-ATE STIL project covers only the syntax parser and semantic analyzer. The STILDumpCompiler is a "bonus" and is not primary goal of this project. It is used as test bed and example for users of the STIL parser library to make own compiler.
The STILDumpCompiler is a single pass compiler and in order to work properly he relies on the exact order in table 7 in the IEEE 1450.0 standard. Because of this, the removed code was moved into the STILDumpCompiler. This means that your STIL file still cannot dump the vector data as you planned.
If you want to dump expanded vectors, you have to write own double pass compiler which should collect the used SignalGroups and Timings in the PatternExec/Burst in the first pass and to expand the vectors from the MacrDefs/Procedure blocks in the second pass based on collected data in the first pass.
I do not have time to make double pass compiler.
Kind Regards,
Seimit

@seimit seimit linked a pull request Jul 1, 2022 that will close this issue
@seimit seimit closed this as completed in #57 Jul 1, 2022
@seimit seimit reopened this Jul 2, 2022
@seimit
Copy link
Collaborator

seimit commented Jul 2, 2022

I reopen the issue, because now I have idea how to implement PatternBurst before MacroDefs/Procedure without writing double pass compiler. If I have more free time I will try to implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants