-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
193 additions
and
71 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,18 @@ | ||
include("../../../SoCMakeConfig.cmake") | ||
cmake_minimum_required(VERSION 3.25) | ||
project(vhpidirect_customc C) | ||
|
||
add_ip(tb) | ||
|
||
ip_sources(tb VHDL | ||
./tb.vhd | ||
) | ||
|
||
add_library(customc STATIC | ||
./main.c | ||
) | ||
|
||
ip_link(${IP} | ||
customc) | ||
ghdl(${IP}) | ||
|
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,17 @@ | ||
#include <stdio.h> | ||
|
||
void custom_procedure (void) { | ||
printf("Hello from custom_procedure!\n"); | ||
} | ||
|
||
void custom_procedure_withargs (int x) { | ||
printf("Hello from custom_procedure '%d'!\n", x); | ||
} | ||
|
||
int custom_function (void) { | ||
return 3; | ||
} | ||
|
||
int custom_function_withargs (int x) { | ||
return x+5; | ||
} |
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,33 @@ | ||
entity tb is | ||
end tb; | ||
|
||
architecture arch of tb is | ||
|
||
procedure cproc is | ||
begin report "VHPIDIRECT custom_procedure" severity failure; end; | ||
attribute foreign of cproc : procedure is "VHPIDIRECT custom_procedure"; | ||
|
||
procedure cproc_wargs ( x: integer ) is | ||
begin report "VHPIDIRECT custom_procedure_withargs" severity failure; end; | ||
attribute foreign of cproc_wargs : procedure is "VHPIDIRECT custom_procedure_withargs"; | ||
|
||
function cfunc return integer is | ||
begin report "VHPIDIRECT custom_function" severity failure; end; | ||
attribute foreign of cfunc : function is "VHPIDIRECT custom_function"; | ||
|
||
function cfunc_wargs ( x: integer ) return integer is | ||
begin report "VHPIDIRECT custom_function_withargs" severity failure; end; | ||
attribute foreign of cfunc_wargs : function is "VHPIDIRECT custom_function_withargs"; | ||
|
||
begin | ||
|
||
process | ||
begin | ||
cproc; | ||
cproc_wargs(17); | ||
report "cfunc: " & integer'image( cfunc ) severity note; | ||
report "cfunc_wargs: " & integer'image( cfunc_wargs(21) ) severity note; | ||
wait; | ||
end process; | ||
|
||
end; |