{"action":"created","issue":{"url":"https://api.github.com/repos/tgingold/ghdl/issues/97","repository_url":"https://api.github.com/repos/tgingold/ghdl","labels_url":"https://api.github.com/repos/tgingold/ghdl/issues/97/labels{/name}","comments_url":"https://api.github.com/repos/tgingold/ghdl/issues/97/comments","events_url":"https://api.github.com/repos/tgingold/ghdl/issues/97/events","html_url":"https://github.com/tgingold/ghdl/issues/97","id":162189600,"number":97,"title":"Accessing VHDL generics of DUT via VPI (Cocotb)","user":{"login":"mzabeltud","id":10209894,"avatar_url":"https://avatars.githubusercontent.com/u/10209894?v=3","gravatar_id":"","url":"https://api.github.com/users/mzabeltud","html_url":"https://github.com/mzabeltud","followers_url":"https://api.github.com/users/mzabeltud/followers","following_url":"https://api.github.com/users/mzabeltud/following{/other_user}","gists_url":"https://api.github.com/users/mzabeltud/gists{/gist_id}","starred_url":"https://api.github.com/users/mzabeltud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzabeltud/subscriptions","organizations_url":"https://api.github.com/users/mzabeltud/orgs","repos_url":"https://api.github.com/users/mzabeltud/repos","events_url":"https://api.github.com/users/mzabeltud/events{/privacy}","received_events_url":"https://api.github.com/users/mzabeltud/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-06-24T17:04:29Z","updated_at":"2016-07-06T19:46:33Z","closed_at":"2016-07-06T13:58:07Z","body":"**Feature request**\r\n\r\nHello,\r\n\r\nthanks for fixing my last issue, now I triggered the next one. My Cocotb testbenches access the VHDL \"generic\" parameters of the DUT (design under test) via VPI to parametrize the golden model. Within the Python code, it is done the same way as accessing signal values. This works nice in QuestaSim. But in GHDL, VHDL generics could not be resolved during this access.\r\n\r\nIt would be nice, if this feature is also added to GHDL. An error log can be found below. Just let me know, if a minimal example is required.\r\n\r\nThanks, Martin\r\n\r\nError log from console:\r\n```\r\n  0.00ns INFO     cocotb.gpi                                  gpi_embed.c:248  in embed_sim_init                  Running on GHDL version 0.1\r\n  0.00ns INFO     cocotb.gpi                                  gpi_embed.c:249  in embed_sim_init                  Python interpreter initialised and cocotb loaded!\r\n  0.00ns INFO     cocotb                                      __init__.py:115  in _initialise_testbench           Running tests with Cocotb v1.0 from /home/zabel/git/poc/lib/cocotb\r\n  0.00ns INFO     cocotb                                      __init__.py:131  in _initialise_testbench           Seeding Python random module with 1466786675\r\n  0.00ns INFO     cocotb.regression                         regression.py:161  in initialise                      Found test sort_lru_cache_cocotb.run_test_001\r\n  0.00ns INFO     cocotb.regression                         regression.py:262  in execute                         Running test 1/1: run_test_001\r\n  0.00ns INFO     ..coroutine._my_test.0x7fb3f7ec2910       decorators.py:189  in send                            Starting test: \"run_test_001\"\r\n                                                                                                                            Description: Automatically generated test\r\n                                                                                                                            \r\n                                                                                                                            \r\n  0.00ns ERROR    ..coroutine.run_test.0x7fb3f7c52350           result.py:51   in raise_error                     Send raised exception: sort_lru_cache contains no object named ELEMENTS\r\n                                                                                                                              File \"/home/zabel/git/poc/lib/cocotb/cocotb/decorators.py\", line 114, in send\r\n                                                                                                                                return self._coro.send(value)\r\n                                                                                                                              File \"/home/zabel/git/poc/temp/cocotb/sort_lru_cache_cocotb.py\", line 175, in run_test\r\n                                                                                                                                tb = Testbench(dut)\r\n                                                                                                                              File \"/home/zabel/git/poc/temp/cocotb/sort_lru_cache_cocotb.py\", line 104, in __init__\r\n                                                                                                                                elements = dut.ELEMENTS.value;\r\n                                                                                                                              File \"/home/zabel/git/poc/lib/cocotb/cocotb/handle.py\", line 261, in __getattr__\r\n                                                                                                                                raise AttributeError(\"%s contains no object named %s\" % (self._name, name))\r\n                                                                                                                            \r\n  1.00ns ERROR    cocotb.regression                         regression.py:246  in handle_result                   Test Failed: run_test_001 (result was TestError)\r\n  1.00ns ERROR    cocotb.regression                         regression.py:167  in tear_down                       Failed 1 out of 1 tests (0 skipped)\r\n  1.00ns INFO     cocotb.regression                         regression.py:176  in tear_down                       Shutting down...\r\n```\r\n\r\nHere `ELEMENTS` is a VHDL generic. This is the entity declaration of the DUT:\r\n```\r\nentity sort_lru_cache is\r\n\tgeneric (\r\n\t\tELEMENTS\t\t\t : positive\t\t\t\t\t:= 32\r\n\t);\r\n\tport (\r\n\t\tClock \t: in std_logic;\r\n\t\tReset \t: in std_logic;\r\n\r\n\t\tInsert \t: in  std_logic;\r\n\t\tFree \t\t: in  std_logic;\r\n\t\tKeyIn\t \t: in  std_logic_vector(log2ceilnz(ELEMENTS) - 1 downto 0);\r\n\r\n\t\tKeyOut \t: out std_logic_vector(log2ceilnz(ELEMENTS) - 1 downto 0)\r\n\t);\r\nend entity;\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/tgingold/ghdl/issues/comments/230885291","html_url":"https://github.com/tgingold/ghdl/issues/97#issuecomment-230885291","issue_url":"https://api.github.com/repos/tgingold/ghdl/issues/97","id":230885291,"user":{"login":"tgingold","id":13433645,"avatar_url":"https://avatars.githubusercontent.com/u/13433645?v=3","gravatar_id":"","url":"https://api.github.com/users/tgingold","html_url":"https://github.com/tgingold","followers_url":"https://api.github.com/users/tgingold/followers","following_url":"https://api.github.com/users/tgingold/following{/other_user}","gists_url":"https://api.github.com/users/tgingold/gists{/gist_id}","starred_url":"https://api.github.com/users/tgingold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgingold/subscriptions","organizations_url":"https://api.github.com/users/tgingold/orgs","repos_url":"https://api.github.com/users/tgingold/repos","events_url":"https://api.github.com/users/tgingold/events{/privacy}","received_events_url":"https://api.github.com/users/tgingold/received_events","type":"User","site_admin":false},"created_at":"2016-07-06T19:46:33Z","updated_at":"2016-07-06T19:46:33Z","body":"On 06/07/16 15:58, mzabeltud wrote:\n> Thank you very much.\n>\n>     So currently, you will have to slightly adjust your cocotb test to\n>     convert N into an integer. Is that possible ?\n>\n> Yes. I have updated the code in the above mentioned branch to include a\n> type check. The binary string returned when using VPI is converted to an\n> integer.\n>\n> The minimal example now works with GHDL and Questa.\n\nGreat!  Thank you for the status update.\n\n"}}
{"actor":{"display_login":"tgingold"}}