Skip to content

Commit f8f2351

Browse files
committed
fix(examples/vhdl/external_buffer): use the reference C sources
* add sigabrt.md
1 parent dc8b154 commit f8f2351

2 files changed

Lines changed: 8 additions & 46 deletions

File tree

examples/vhdl/external_buffer/run.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@
2828
from vunit import VUnit
2929
from os import popen
3030
from os.path import join, dirname
31+
import inspect
3132

3233
src_path = join(dirname(__file__), 'src')
34+
ext_srcs = join(dirname(inspect.getfile(VUnit)), 'vhdl', 'data_types', 'src', 'external')
3335

3436
# Compile C applications to an objects
3537
c_iobj = join(src_path, 'imain.o')
@@ -38,13 +40,15 @@
3840
print(popen(' '.join([
3941
'gcc', '-fPIC',
4042
'-DTYPE=int32_t',
43+
'-I', ext_srcs,
4144
'-c', join(src_path, 'main.c'),
4245
'-o', c_iobj
4346
])).read())
4447

4548
print(popen(' '.join([
4649
'gcc', '-fPIC',
4750
'-DTYPE=uint8_t',
51+
'-I', ext_srcs,
4852
'-c', join(src_path, 'main.c'),
4953
'-o', c_bobj
5054
])).read())
@@ -58,8 +62,8 @@
5862

5963
# Add the C object to the elaboration of GHDL
6064
for tb in lib.get_test_benches(pattern='*tb_ext*', allow_empty=False):
61-
tb.set_sim_option('ghdl.elab_flags', ['-Wl,' + c_bobj], overwrite=True)
65+
tb.set_sim_option('ghdl.elab_flags', ['-Wl,' + c_bobj, '-Wl,-Wl,--version-script=' + join(ext_srcs, 'grt.ver')], overwrite=True)
6266
for tb in lib.get_test_benches(pattern='*tb_ext*_integer*', allow_empty=False):
63-
tb.set_sim_option('ghdl.elab_flags', ['-Wl,' + c_iobj], overwrite=True)
67+
tb.set_sim_option('ghdl.elab_flags', ['-Wl,' + c_iobj, '-Wl,-Wl,--version-script=' + join(ext_srcs, 'grt.ver')], overwrite=True)
6468

6569
vu.main()

examples/vhdl/external_buffer/src/main.c

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ or tb_ext_integer_vector.vhd
2121
#include <stdio.h>
2222
#include <stdlib.h>
2323
#include <stdint.h>
24+
#include "vhpidirect_user.h"
2425

25-
extern int ghdl_main (int argc, char **argv);
26-
27-
uint8_t *D[1];
2826
const uint32_t length = 5;
2927

3028
/*
@@ -34,7 +32,7 @@ const uint32_t length = 5;
3432
[2/3, 3/3), while incrementing each value by two.
3533
*/
3634
static void exit_handler(void) {
37-
uint i, j, z, k;
35+
unsigned i, j, z, k;
3836
TYPE expected, got;
3937
k = 0;
4038
for (j=0; j<3; j++) {
@@ -80,43 +78,3 @@ int main(int argc, char **argv) {
8078
// Start the simulation
8179
return ghdl_main(argc, argv);
8280
}
83-
84-
// External string/byte_vector through access (mode = extacc)
85-
86-
void set_string_ptr(uint8_t id, uint8_t *p) {
87-
D[id] = p;
88-
}
89-
90-
uintptr_t get_string_ptr(uint8_t id) {
91-
return (uintptr_t)D[id];
92-
}
93-
94-
// External string/byte_vector through functions (mode = extfnc)
95-
96-
void write_char(uint8_t id, uint32_t i, uint8_t v ) {
97-
D[id][i] = v;
98-
}
99-
100-
uint8_t read_char(uint8_t id, uint32_t i) {
101-
return D[id][i];
102-
}
103-
104-
// External integer_vector through access (mode = extacc)
105-
106-
void set_intvec_ptr(uint8_t id, uintptr_t *p) {
107-
D[id] = (uint8_t*)p;
108-
}
109-
110-
uintptr_t get_intvec_ptr(uint8_t id) {
111-
return (uintptr_t)D[id];
112-
}
113-
114-
// External integer_vector through functions (mode = extfnc)
115-
116-
void write_integer(uint8_t id, uint32_t i, int32_t v) {
117-
((int32_t*)D[id])[i] = v;
118-
}
119-
120-
int32_t read_integer(uint8_t id, uint32_t i) {
121-
return ((int32_t*)D[id])[i];
122-
}

0 commit comments

Comments
 (0)