-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic DPI-C firmware for xsim & verilator
- Loading branch information
Aba
committed
Aug 26, 2023
1 parent
a203b4d
commit 38f9b33
Showing
7 changed files
with
105 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,8 @@ asic/* | |
*.pickle | ||
test/vectors | ||
test/xsim | ||
test/c | ||
test/oldc | ||
test/xsc* | ||
test/obj_dir | ||
test/models | ||
|
||
|
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,5 @@ | ||
#include "runtime.h" | ||
|
||
int example_main (){ | ||
return 0; | ||
} |
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,10 @@ | ||
const int N_BUNDLES = 6; | ||
|
||
Bundle_t bundles [] = { | ||
{.w_wpt=2368, .w_wpt_p0=2368, .x_wpt=424, .x_wpt_p0=424, .y_wpt=16, .y_wpt_last=96, .y_nl=4, .y_w=3, .n_it=8, .n_p=3 }, | ||
{.w_wpt=2208, .w_wpt_p0=2208, .x_wpt=840, .x_wpt_p0=840, .y_wpt=24, .y_wpt_last=96, .y_nl=4, .y_w=5, .n_it=6, .n_p=8 }, | ||
{.w_wpt=1568, .w_wpt_p0=608, .x_wpt=1256, .x_wpt_p0=424, .y_wpt=32, .y_wpt_last=96, .y_nl=4, .y_w=6, .n_it=4, .n_p=6 }, | ||
{.w_wpt=1176, .w_wpt_p0=312, .x_wpt=2088, .x_wpt_p0=424, .y_wpt=64, .y_wpt_last=128, .y_nl=4, .y_w=7, .n_it=3, .n_p=4 }, | ||
{.w_wpt=1176, .w_wpt_p0=744, .x_wpt=6248, .x_wpt_p0=3752, .y_wpt=192, .y_wpt_last=192, .y_nl=4, .y_w=8, .n_it=3, .n_p=2 }, | ||
{.w_wpt=392, .w_wpt_p0=272, .x_wpt=398, .x_wpt_p0=268, .y_wpt=192, .y_wpt_last=192, .y_nl=2, .y_w=1, .n_it=1, .n_p=427 } | ||
}; |
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,49 @@ | ||
typedef struct { | ||
const int w_wpt, w_wpt_p0; // words per transfer | ||
const int x_wpt, x_wpt_p0; | ||
const int y_wpt, y_wpt_last; | ||
const int y_nl, y_w; | ||
const int n_it, n_p; | ||
} Bundle_t; | ||
|
||
#include "model.h" | ||
#include <svdpi.h> | ||
|
||
#ifdef VERILATOR | ||
#define EXT_C "C" | ||
#else | ||
#define EXT_C | ||
#endif | ||
|
||
|
||
extern EXT_C void load_x (svBit* done, int* ib_out, int* ip_out) { | ||
|
||
static int ib=0, ip=0, it=0; | ||
*done =0; | ||
|
||
// Nested for loop [for ib: for ip: for it: {}] inverted to increment once per call | ||
++ it; if (it >= bundles[ib].n_it) { it = 0; | ||
++ ip; if (ip >= bundles[ib].n_p) { ip = 0; | ||
++ ib; if (ib >= N_BUNDLES) { ib = 0; | ||
*done =1; | ||
}}} | ||
*ib_out = ib; | ||
*ip_out = ip; | ||
} | ||
|
||
|
||
extern EXT_C void load_w (svBit* done, int* ib_out, int* ip_out, int* it_out) { | ||
|
||
static int ib=0, ip=0, it=0; | ||
*done =0; | ||
|
||
// Nested for loop [for ib: for ip: for it: {}] inverted to increment once per call | ||
++ it; if (it >= bundles[ib].n_it) { it = 0; | ||
++ ip; if (ip >= bundles[ib].n_p) { ip = 0; | ||
++ ib; if (ib >= N_BUNDLES) { ib = 0; | ||
*done =1; | ||
}}} | ||
*ib_out = ib; | ||
*ip_out = ip; | ||
*it_out = it; | ||
} |
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
localparam N_BUNDLES = 6; | ||
|
||
Bundle_t bundles [N_BUNDLES] = '{ | ||
'{w_wpt:2368, w_wpt_p0:2368, x_wpt:424, x_wpt_p0:424, y_wpt:16, y_wpt_last:96, y_nl:4, y_w:3, n_it:8, n_p:3 }, | ||
'{w_wpt:2208, w_wpt_p0:2208, x_wpt:840, x_wpt_p0:840, y_wpt:24, y_wpt_last:96, y_nl:4, y_w:5, n_it:6, n_p:8 }, | ||
'{w_wpt:1568, w_wpt_p0:608, x_wpt:1256, x_wpt_p0:424, y_wpt:32, y_wpt_last:96, y_nl:4, y_w:6, n_it:4, n_p:6 }, | ||
'{w_wpt:1176, w_wpt_p0:312, x_wpt:2088, x_wpt_p0:424, y_wpt:64, y_wpt_last:128, y_nl:4, y_w:7, n_it:3, n_p:4 }, | ||
'{w_wpt:1176, w_wpt_p0:744, x_wpt:6248, x_wpt_p0:3752, y_wpt:192, y_wpt_last:192, y_nl:4, y_w:8, n_it:3, n_p:2 }, | ||
'{w_wpt:392, w_wpt_p0:272, x_wpt:398, x_wpt_p0:268, y_wpt:192, y_wpt_last:192, y_nl:2, y_w:1, n_it:1, n_p:427 } | ||
'{ w_wpt:2368, w_wpt_p0:2368, x_wpt:424, x_wpt_p0:424, y_wpt:16, y_wpt_last:96, y_nl:4, y_w:3, n_it:8, n_p:3 }, | ||
'{ w_wpt:2208, w_wpt_p0:2208, x_wpt:840, x_wpt_p0:840, y_wpt:24, y_wpt_last:96, y_nl:4, y_w:5, n_it:6, n_p:8 }, | ||
'{ w_wpt:1568, w_wpt_p0:608, x_wpt:1256, x_wpt_p0:424, y_wpt:32, y_wpt_last:96, y_nl:4, y_w:6, n_it:4, n_p:6 }, | ||
'{ w_wpt:1176, w_wpt_p0:312, x_wpt:2088, x_wpt_p0:424, y_wpt:64, y_wpt_last:128, y_nl:4, y_w:7, n_it:3, n_p:4 }, | ||
'{ w_wpt:1176, w_wpt_p0:744, x_wpt:6248, x_wpt_p0:3752, y_wpt:192, y_wpt_last:192, y_nl:4, y_w:8, n_it:3, n_p:2 }, | ||
'{ w_wpt:392, w_wpt_p0:272, x_wpt:398, x_wpt_p0:268, y_wpt:192, y_wpt_last:192, y_nl:2, y_w:1, n_it:1, n_p:427 } | ||
}; |