Comments (3)
on my foreign branch,
$ cat ext.c
#include <stdint.h>
int32_t ext_add_int32_t(int32_t l, int32_t r) { return l + r; }
int32_t ext_sub_int32_t(int32_t l, int32_t r) { return l - r; }
int32_t ext_mul_int32_t(int32_t l, int32_t r) { return l * r; }
int32_t ext_div_int32_t(int32_t l, int32_t r) { return l / r; }
double ext_add_double(double l, double r) { return l + r; }
double ext_sub_double(double l, double r) { return l - r; }
double ext_mul_double(double l, double r) { return l * r; }
double ext_div_double(double l, double r) { return l / r; }
$ cat ext.vhd
package ext is
pure function ext_add(l : integer; r : integer) return integer;
pure function ext_sub(l : integer; r : integer) return integer;
pure function ext_mul(l : integer; r : integer) return integer;
pure function ext_div(l : integer; r : integer) return integer;
attribute foreign of ext_add : function is "ext_add_int32_t";
attribute foreign of ext_sub : function is "ext_sub_int32_t";
attribute foreign of ext_mul : function is "ext_mul_int32_t";
attribute foreign of ext_div : function is "ext_div_int32_t";
end package ext;
use work.ext.all;
entity test is
begin
end entity test;
architecture a of test is
begin
process
constant w : integer range 1 to integer'high := 4;
begin
for l in 0 to 2**w-1 loop
for r in 0 to 2**w-1 loop
assert (ext_add(l, r) = l + r);
assert (ext_sub(l, r) = l - r);
assert (ext_mul(l, r) = l * r);
if (r /= 0) then
assert (ext_div(l, r) = l / r);
end if;
end loop;
end loop;
wait;
end process;
end architecture a;
$ NVC_LIBPATH=./lib/std:./lib/ieee:./lib/nvc NVC_CYG_LIB=./src ./src/nvc.exe -a ext.vhd
$ NVC_LIBPATH=./lib/std:./lib/ieee:./lib/nvc NVC_CYG_LIB=./src NVC_FOREIGN_OBJ=./ext.o ./src/nvc.exe -e --native test
/usr/bin/opt -O2 -o /home/hiyuh/git-repos/nvc/work/_WORK.TEST.final.bc /home/hiyuh/git-repos/nvc/work/_WORK.TEST.elab.bc
/usr/bin/llc -relocation-model=pic /home/hiyuh/git-repos/nvc/work/_WORK.TEST.final.bc
/usr/bin/gcc -shared -Wl,--export-all-symbols -Wl,--out-implib=/home/hiyuh/git-repos/nvc/work/_WORK.TEST.elab.a -o /home/hiyuh/git-repos/nvc/work/_WORK.TEST.final.so /home/hiyuh/git-repos/nvc/work/_WORK.TEST.final.s ./ext.o -L./src -lnvcimp
$ NVC_LIBPATH=./lib/std:./lib/ieee:./lib/nvc NVC_CYG_LIB=./src ./src/nvc.exe -r test
[no assertion faulure]
it looks ok to me, except NVC does not support signature in attribute_specification currently, which is required to handle attribute_specification properly for overloaded ones.
from nvc.
naming is improved.
from nvc.
I think this is fine for now: merged it.
In the future it would probably be best to have an option --load <so>
to -r
that loads shared libraries with user code. This is more similar to how Modelsim, etc. work and will work with JIT.
from nvc.
Related Issues (20)
- UVVM-based testbenches and coverage
- External name and redeclared type definition HOT 2
- nvc elaboration error (SIGABRT) HOT 6
- nvc segfaults while generating the coverage report HOT 1
- PSL cover sequence split accross multiple lines
- PSL braces around sub-expression causing crash
- PSL sequence implication parsing error
- PSL property analysis fails when braces around it are missing
- PSL - Assert Never not supported
- generic package with impure function method. HOT 1
- generic package with impure function method. HOT 3
- Regression with alias of external name? HOT 4
- Compliance-Tests: tb_garbage_collection.all failed to suspend thread HOT 4
- OsvvmLibraries RunAllTests SetVHDLVersion 2019 SIGSEGV HOT 2
- 2008: Generic Package fails with signed type, but not integer HOT 1
- nvc crashes with generic package passed to generic map in entity instantiation HOT 1
- Generic Type resolving fails when using functions for range HOT 1
- Generic package instantiation with type from package HOT 4
- Crash related to unconstrained vector as a parameter in a procedure HOT 1
- Wrong value in generic constant when using slice name
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nvc.