forked from ghdl/ghdl-cosim
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vhpidirect: add 'quickstart/package'
- Loading branch information
1 parent
d394448
commit 95a760d
Showing
7 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#include<stdio.h> | ||
void printInt(int var){ | ||
printf("C-side print of int: %d\n", var); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use work.pkg.all; | ||
|
||
entity ent is | ||
end ent; | ||
|
||
architecture rtl_A of ent is | ||
begin | ||
process | ||
begin | ||
report "Entity1 calling c_print(1)." severity note; | ||
c_printInt(1); | ||
wait; | ||
end process; | ||
end rtl_A; | ||
|
||
architecture rtl_B of ent is | ||
begin | ||
process | ||
begin | ||
report "Entity2 calling c_print(2)." severity note; | ||
c_printInt(2); | ||
wait; | ||
end process; | ||
end rtl_B; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package pkg is | ||
procedure c_printInt(val: integer); | ||
attribute foreign of c_printInt : procedure is "VHPIDIRECT printInt"; | ||
end package pkg; | ||
|
||
package body pkg is | ||
procedure c_printInt(val: integer) is | ||
begin | ||
assert false report "c_printInt VHPI" severity failure; | ||
end; | ||
end package body pkg; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -e | ||
|
||
cd $(dirname "$0") | ||
|
||
echo "Analyze pkg.vhd ent.vhd tb.vhd" | ||
ghdl -a pkg.vhd ent.vhd tb.vhd | ||
|
||
echo "Build tb with caux.c" | ||
ghdl -e -Wl,caux.c tb | ||
|
||
echo "Execute tb" | ||
./tb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
entity tb is | ||
end tb; | ||
|
||
architecture arch of tb is | ||
begin | ||
|
||
entA : entity work.ent(rtl_A); | ||
entB : entity work.ent(rtl_B); | ||
|
||
process | ||
begin | ||
report "Testbench." severity note; | ||
wait; | ||
end process; | ||
end; |