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

Are std_logic_vectors not supported? #13

Open
Brandon-Valley opened this issue Nov 12, 2020 · 2 comments
Open

Are std_logic_vectors not supported? #13

Brandon-Valley opened this issue Nov 12, 2020 · 2 comments

Comments

@Brandon-Valley
Copy link

Greetings,

Python I am using:

vhdl_file_path = "C:\\projects\\auto_wapper\\example\\demo.vhd"

# Open a source file
with open(vhdl_file_path, 'r') as fileHandle:
    content = fileHandle.read()


from pyVHDLParser.Token.Parser      import Tokenizer
from pyVHDLParser.Blocks            import TokenToBlockParser
from pyVHDLParser.Base              import ParserException

# get a token generator
tokenStream = Tokenizer.GetVHDLTokenizer(content)
# get a block generator
blockStream = TokenToBlockParser.Transform(tokenStream)



from pyVHDLParser.Blocks            import MetaBlock
for block in MetaBlock.BLOCKS:
        try:
            block.__cls_init__()
        except AttributeError:
            pass

try:
    for block in blockStream:
        print("{block!s}".format(block=block))
    for token in block:
        print("  {token!s}".format(token=token))
except ParserException as ex:
    print("ERROR: {0!s}".format(ex))
except NotImplementedError as ex:
    print("NotImplementedError: {0!s}".format(ex))    

When run on this .vhd file, everything works fine:

entity demo is
    port (
        a    : in  std_logic;
        -- b    : out std_logic_vector( 15 downto 0 );
        c    : out std_logic
    );
end entity demo;

But when I uncomment the line with the std_logic_vector as shown below, I receive the following error.

entity demo is
    port (
        a    : in  std_logic;
        b    : out std_logic_vector( 15 downto 0 );
        c    : out std_logic
    );
end entity demo;
pydev debugger: starting (pid: 18620)
[StartOfDocumentBlock]
[LinebreakBlock                                                                                                    at (line:   1, col:  1) .. (line:   1, col:  1)]
[Entity.NameBlock                                   'entity demo is'                                               at (line:   2, col:  1) .. (line:   2, col: 15)]
[LinebreakBlock                                                                                                    at (line:   2, col: 15) .. (line:   2, col: 15)]
[IndentationBlock                                    length=4 (4)                                                  at (line:   3, col:  1) .. (line:   3, col:  4)]
[PortList.OpenBlock                                 'port ('                                                       at (line:   3, col:  5) .. (line:   3, col: 10)]
[LinebreakBlock                                                                                                    at (line:   3, col: 11) .. (line:   3, col: 11)]
[IndentationBlock                                    length=8 (8)                                                  at (line:   4, col:  1) .. (line:   4, col:  8)]
[PortList.PortListInterfaceSignalBlock              'a    : in  std_logic'                                         at (line:   4, col:  9) .. (line:   4, col: 29)]
[PortList.DelimiterBlock                            ';'                                                            at (line:   4, col: 29) .. (line:   4, col: 29)]
[LinebreakBlock                                                                                                    at (line:   4, col: 30) .. (line:   4, col: 30)]
[IndentationBlock                                    length=8 (8)                                                  at (line:   5, col:  1) .. (line:   5, col:  8)]
ERROR: Expected ';', ':=' or whitespace after subtype indication.

Am I doing something wrong? Any recomendations on how I should proceed? Any and all assistance is greatly appreciated! :)

@Paebbels
Copy link
Owner

The log shows the following:

  • it consumed everything until semicolon after the lins of signal a
  • after semicolon it consumes a linebreak → OK
  • before character b it consumes an indentation of 8 space characters (because it reports 8 (8)) - for tabs the numbers would differ :) → OK

in the state where the parser currently is, it expects either a semicolon or := to assign a default value to a port. This means, the parser lost the information, it already consumed a ; before the linebreak and/or the indentation. That's why it asks again as if it would still stand in the line of a.

Please try this:

entity demo is
    port (
        a    : in  std_logic; -- dummy
        b    : out std_logic_vector( 15 downto 0 ); -- dummy
        c    : out std_logic
    );
end entity demo;

@Paebbels
Copy link
Owner

Paebbels commented Nov 15, 2020

I added a first set of test cases for port lists in a087e04.
The second test shows a Last token is not connected to the current token. error when checking the linked data structures.

The test case could pass with:
port1 : bit;port2 : boolean
but fails with
port1 : bit; port2 : boolean
note the space after ; between two ports.

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

No branches or pull requests

2 participants