litex/build/sim: rename c functions from lambdasim to litex_sim (since integrated in litex)

This commit is contained in:
Florent Kermarrec 2017-06-28 16:28:45 +02:00
parent ab6f4de521
commit 4a0a431119
13 changed files with 82 additions and 82 deletions

View File

@ -16,7 +16,7 @@
static struct ext_module_list_s *modlist=NULL; static struct ext_module_list_s *modlist=NULL;
int lambdasim_register_ext_module(struct ext_module_s *mod) int litex_sim_register_ext_module(struct ext_module_s *mod)
{ {
int ret=RC_OK; int ret=RC_OK;
struct ext_module_list_s *ml=NULL; struct ext_module_list_s *ml=NULL;
@ -43,13 +43,13 @@ out:
return ret; return ret;
} }
int lambdasim_load_ext_modules(struct ext_module_list_s **mlist) int litex_sim_load_ext_modules(struct ext_module_list_s **mlist)
{ {
int ret = RC_OK; int ret = RC_OK;
tinydir_dir dir; tinydir_dir dir;
tinydir_file file; tinydir_file file;
dylib_ref lib; dylib_ref lib;
int (*lambdasim_ext_module_init)(int (*reg)(struct ext_module_s *)); int (*litex_sim_ext_module_init)(int (*reg)(struct ext_module_s *));
char name[100]; char name[100];
if (tinydir_open(&dir, "./modules/") == -1) if (tinydir_open(&dir, "./modules/") == -1)
{ {
@ -82,20 +82,20 @@ int lambdasim_load_ext_modules(struct ext_module_list_s **mlist)
goto out; goto out;
} }
if(!libdylib_find(lib, "lambdasim_ext_module_init")) if(!libdylib_find(lib, "litex_sim_ext_module_init"))
{ {
ret = RC_ERROR; ret = RC_ERROR;
eprintf("Module has no lambdasim_ext_module_init function\n"); eprintf("Module has no litex_sim_ext_module_init function\n");
goto out; goto out;
} }
LIBDYLIB_BINDNAME(lib, lambdasim_ext_module_init); LIBDYLIB_BINDNAME(lib, litex_sim_ext_module_init);
if(!lambdasim_ext_module_init) if(!litex_sim_ext_module_init)
{ {
ret = RC_ERROR; ret = RC_ERROR;
eprintf("Can't bind %s\n", libdylib_last_error()); eprintf("Can't bind %s\n", libdylib_last_error());
goto out; goto out;
} }
ret = lambdasim_ext_module_init(lambdasim_register_ext_module); ret = litex_sim_ext_module_init(litex_sim_register_ext_module);
if(RC_OK != ret) if(RC_OK != ret)
{ {
goto out; goto out;
@ -114,7 +114,7 @@ out:
return ret; return ret;
} }
int lambdasim_find_ext_module(struct ext_module_list_s *first, char *name , struct ext_module_list_s **found) int litex_sim_find_ext_module(struct ext_module_list_s *first, char *name , struct ext_module_list_s **found)
{ {
struct ext_module_list_s *list = NULL; struct ext_module_list_s *list = NULL;
int ret=RC_OK; int ret=RC_OK;
@ -136,7 +136,7 @@ out:
return ret; return ret;
} }
int lambdasim_find_module(struct module_s *first, char *name , struct module_s **found) int litex_sim_find_module(struct module_s *first, char *name , struct module_s **found)
{ {
struct module_s *list = NULL; struct module_s *list = NULL;
int ret=RC_OK; int ret=RC_OK;

View File

@ -33,8 +33,8 @@ struct ext_module_list_s {
struct ext_module_list_s *next; struct ext_module_list_s *next;
}; };
int lambdasim_file_to_module_list(char *filename, struct module_s **mod); int litex_sim_file_to_module_list(char *filename, struct module_s **mod);
int lambdasim_load_ext_modules(struct ext_module_list_s **mlist); int litex_sim_load_ext_modules(struct ext_module_list_s **mlist);
int lambdasim_find_ext_module(struct ext_module_list_s *first, char *name , struct ext_module_list_s **found); int litex_sim_find_ext_module(struct ext_module_list_s *first, char *name , struct ext_module_list_s **found);
#endif #endif

View File

@ -8,7 +8,7 @@ struct session_s {
char *sys_clk; char *sys_clk;
}; };
static int lambdasim_module_pads_get( struct pad_s *pads, char *name, void **signal) static int litex_sim_module_pads_get( struct pad_s *pads, char *name, void **signal)
{ {
int ret; int ret;
void *sig=NULL; void *sig=NULL;
@ -80,7 +80,7 @@ static int clocker_add_pads(void *sess, struct pad_list_s *plist)
if(!strcmp(plist->name, "sys_clk")) if(!strcmp(plist->name, "sys_clk"))
{ {
lambdasim_module_pads_get(pads, "sys_clk", (void**)&s->sys_clk); litex_sim_module_pads_get(pads, "sys_clk", (void**)&s->sys_clk);
} }
*s->sys_clk=0; *s->sys_clk=0;
@ -104,7 +104,7 @@ static struct ext_module_s ext_mod = {
clocker_tick clocker_tick
}; };
int lambdasim_ext_module_init(int (*register_module)(struct ext_module_s *)) int litex_sim_ext_module_init(int (*register_module)(struct ext_module_s *))
{ {
int ret=RC_OK; int ret=RC_OK;
ret = register_module(&ext_mod); ret = register_module(&ext_mod);

View File

@ -37,7 +37,7 @@ struct session_s {
static struct event_base *base=NULL; static struct event_base *base=NULL;
int lambdasim_module_get_args( char *args, char *arg, char **val) int litex_sim_module_get_args( char *args, char *arg, char **val)
{ {
int ret=RC_OK; int ret=RC_OK;
json_object *jsobj=NULL; json_object *jsobj=NULL;
@ -73,7 +73,7 @@ out:
return ret; return ret;
} }
static int lambdasim_module_pads_get( struct pad_s *pads, char *name, void **signal) static int litex_sim_module_pads_get( struct pad_s *pads, char *name, void **signal)
{ {
int ret; int ret;
void *sig=NULL; void *sig=NULL;
@ -159,14 +159,14 @@ static int ethernet_new(void **sess, char *args)
} }
memset(s, 0, sizeof(struct session_s)); memset(s, 0, sizeof(struct session_s));
ret = lambdasim_module_get_args(args, "interface", &c_tap); ret = litex_sim_module_get_args(args, "interface", &c_tap);
{ {
if(RC_OK != ret) if(RC_OK != ret)
{ {
goto out; goto out;
} }
} }
ret = lambdasim_module_get_args(args, "ip", &c_tap_ip); ret = litex_sim_module_get_args(args, "ip", &c_tap_ip);
{ {
if(RC_OK != ret) if(RC_OK != ret)
{ {
@ -206,17 +206,17 @@ static int ethernet_add_pads(void *sess, struct pad_list_s *plist)
pads = plist->pads; pads = plist->pads;
if(!strcmp(plist->name, "eth")) if(!strcmp(plist->name, "eth"))
{ {
lambdasim_module_pads_get(pads, "sink_data", (void**)&s->rx); litex_sim_module_pads_get(pads, "sink_data", (void**)&s->rx);
lambdasim_module_pads_get(pads, "sink_valid", (void**)&s->rx_valid); litex_sim_module_pads_get(pads, "sink_valid", (void**)&s->rx_valid);
lambdasim_module_pads_get(pads, "sink_ready", (void**)&s->rx_ready); litex_sim_module_pads_get(pads, "sink_ready", (void**)&s->rx_ready);
lambdasim_module_pads_get(pads, "source_data", (void**)&s->tx); litex_sim_module_pads_get(pads, "source_data", (void**)&s->tx);
lambdasim_module_pads_get(pads, "source_valid", (void**)&s->tx_valid); litex_sim_module_pads_get(pads, "source_valid", (void**)&s->tx_valid);
lambdasim_module_pads_get(pads, "source_ready", (void**)&s->tx_ready); litex_sim_module_pads_get(pads, "source_ready", (void**)&s->tx_ready);
} }
if(!strcmp(plist->name, "sys_clk")) if(!strcmp(plist->name, "sys_clk"))
{ {
lambdasim_module_pads_get(pads, "sys_clk", (void**)&s->sys_clk); litex_sim_module_pads_get(pads, "sys_clk", (void**)&s->sys_clk);
} }
out: out:
@ -302,7 +302,7 @@ static struct ext_module_s ext_mod = {
ethernet_tick ethernet_tick
}; };
int lambdasim_ext_module_init(int (*register_module)(struct ext_module_s *)) int litex_sim_ext_module_init(int (*register_module)(struct ext_module_s *))
{ {
int ret=RC_OK; int ret=RC_OK;
ret = register_module(&ext_mod); ret = register_module(&ext_mod);

View File

@ -25,7 +25,7 @@ struct session_s {
}; };
struct event_base *base; struct event_base *base;
static int lambdasim_module_pads_get( struct pad_s *pads, char *name, void **signal) static int litex_sim_module_pads_get( struct pad_s *pads, char *name, void **signal)
{ {
int ret; int ret;
void *sig=NULL; void *sig=NULL;
@ -134,17 +134,17 @@ static int serial2console_add_pads(void *sess, struct pad_list_s *plist)
pads = plist->pads; pads = plist->pads;
if(!strcmp(plist->name, "serial")) if(!strcmp(plist->name, "serial"))
{ {
lambdasim_module_pads_get(pads, "sink_data", (void**)&s->rx); litex_sim_module_pads_get(pads, "sink_data", (void**)&s->rx);
lambdasim_module_pads_get(pads, "sink_valid", (void**)&s->rx_valid); litex_sim_module_pads_get(pads, "sink_valid", (void**)&s->rx_valid);
lambdasim_module_pads_get(pads, "sink_ready", (void**)&s->rx_ready); litex_sim_module_pads_get(pads, "sink_ready", (void**)&s->rx_ready);
lambdasim_module_pads_get(pads, "source_data", (void**)&s->tx); litex_sim_module_pads_get(pads, "source_data", (void**)&s->tx);
lambdasim_module_pads_get(pads, "source_valid", (void**)&s->tx_valid); litex_sim_module_pads_get(pads, "source_valid", (void**)&s->tx_valid);
lambdasim_module_pads_get(pads, "source_ready", (void**)&s->tx_ready); litex_sim_module_pads_get(pads, "source_ready", (void**)&s->tx_ready);
} }
if(!strcmp(plist->name, "sys_clk")) if(!strcmp(plist->name, "sys_clk"))
{ {
lambdasim_module_pads_get(pads, "sys_clk", (void**)&s->sys_clk); litex_sim_module_pads_get(pads, "sys_clk", (void**)&s->sys_clk);
} }
@ -195,7 +195,7 @@ static struct ext_module_s ext_mod = {
serial2console_tick serial2console_tick
}; };
int lambdasim_ext_module_init(int (*register_module)(struct ext_module_s *)) int litex_sim_ext_module_init(int (*register_module)(struct ext_module_s *))
{ {
int ret=RC_OK; int ret=RC_OK;
ret = register_module(&ext_mod); ret = register_module(&ext_mod);

View File

@ -27,7 +27,7 @@ struct session_s {
struct event_base *base; struct event_base *base;
int lambdasim_module_get_args( char *args, char *arg, char **val) int litex_sim_module_get_args( char *args, char *arg, char **val)
{ {
int ret=RC_OK; int ret=RC_OK;
json_object *jsobj=NULL; json_object *jsobj=NULL;
@ -63,7 +63,7 @@ out:
return ret; return ret;
} }
static int lambdasim_module_pads_get( struct pad_s *pads, char *name, void **signal) static int litex_sim_module_pads_get( struct pad_s *pads, char *name, void **signal)
{ {
int ret; int ret;
void *sig=NULL; void *sig=NULL;
@ -156,7 +156,7 @@ static int serial2tcp_new(void **sess, char *args)
goto out; goto out;
} }
ret = lambdasim_module_get_args(args, "port", &cport); ret = litex_sim_module_get_args(args, "port", &cport);
{ {
if(RC_OK != ret) if(RC_OK != ret)
{ {
@ -214,17 +214,17 @@ static int serial2tcp_add_pads(void *sess, struct pad_list_s *plist)
pads = plist->pads; pads = plist->pads;
if(!strcmp(plist->name, "serial")) if(!strcmp(plist->name, "serial"))
{ {
lambdasim_module_pads_get(pads, "sink_data", (void**)&s->rx); litex_sim_module_pads_get(pads, "sink_data", (void**)&s->rx);
lambdasim_module_pads_get(pads, "sink_valid", (void**)&s->rx_valid); litex_sim_module_pads_get(pads, "sink_valid", (void**)&s->rx_valid);
lambdasim_module_pads_get(pads, "sink_ready", (void**)&s->rx_ready); litex_sim_module_pads_get(pads, "sink_ready", (void**)&s->rx_ready);
lambdasim_module_pads_get(pads, "source_data", (void**)&s->tx); litex_sim_module_pads_get(pads, "source_data", (void**)&s->tx);
lambdasim_module_pads_get(pads, "source_valid", (void**)&s->tx_valid); litex_sim_module_pads_get(pads, "source_valid", (void**)&s->tx_valid);
lambdasim_module_pads_get(pads, "source_ready", (void**)&s->tx_ready); litex_sim_module_pads_get(pads, "source_ready", (void**)&s->tx_ready);
} }
if(!strcmp(plist->name, "sys_clk")) if(!strcmp(plist->name, "sys_clk"))
{ {
lambdasim_module_pads_get(pads, "sys_clk", (void**)&s->sys_clk); litex_sim_module_pads_get(pads, "sys_clk", (void**)&s->sys_clk);
} }
@ -277,7 +277,7 @@ static struct ext_module_s ext_mod = {
serial2tcp_tick serial2tcp_tick
}; };
int lambdasim_ext_module_init(int (*register_module)(struct ext_module_s *)) int litex_sim_ext_module_init(int (*register_module)(struct ext_module_s *))
{ {
int ret=RC_OK; int ret=RC_OK;
ret = register_module(&ext_mod); ret = register_module(&ext_mod);

View File

@ -8,7 +8,7 @@
static struct pad_list_s *padlist=NULL; static struct pad_list_s *padlist=NULL;
int lambdasim_register_pads(struct pad_s *pads, char *interface_name, int index) int litex_sim_register_pads(struct pad_s *pads, char *interface_name, int index)
{ {
int ret = RC_OK; int ret = RC_OK;
@ -41,7 +41,7 @@ out:
return ret; return ret;
} }
int lambdasim_pads_get_list(struct pad_list_s **plist) int litex_sim_pads_get_list(struct pad_list_s **plist)
{ {
int ret=RC_OK; int ret=RC_OK;
@ -58,7 +58,7 @@ out:
return ret; return ret;
} }
int lambdasim_pads_find(struct pad_list_s *first, char *name, int index, struct pad_list_s **found) int litex_sim_pads_find(struct pad_list_s *first, char *name, int index, struct pad_list_s **found)
{ {
struct pad_list_s *list = NULL; struct pad_list_s *list = NULL;
int ret=RC_OK; int ret=RC_OK;

View File

@ -16,13 +16,13 @@ struct pad_list_s {
struct pad_list_s *next; struct pad_list_s *next;
}; };
int lambdasim_pads_get_list(struct pad_list_s **plist); int litex_sim_pads_get_list(struct pad_list_s **plist);
int lambdasim_pads_find(struct pad_list_s *first, char *name, int index, struct pad_list_s **found); int litex_sim_pads_find(struct pad_list_s *first, char *name, int index, struct pad_list_s **found);
#ifdef __cplusplus #ifdef __cplusplus
extern "C" int lambdasim_register_pads(struct pad_s *pads, char *interface_name, int index); extern "C" int litex_sim_register_pads(struct pad_s *pads, char *interface_name, int index);
#else #else
int lambdasim_register_pads(struct pad_s *pads, char *interface_name, int index); int litex_sim_register_pads(struct pad_s *pads, char *interface_name, int index);
#endif #endif
#endif #endif

View File

@ -299,7 +299,7 @@ out:
return ret; return ret;
} }
int lambdasim_file_to_module_list(char *filename, struct module_s **mod) int litex_sim_file_to_module_list(char *filename, struct module_s **mod)
{ {
struct module_s *m=NULL; struct module_s *m=NULL;
json_object *obj=NULL; json_object *obj=NULL;

View File

@ -21,7 +21,7 @@
#include <event2/util.h> #include <event2/util.h>
#include <event2/event.h> #include <event2/event.h>
void lambdasim_init(void **out); void litex_sim_init(void **out);
struct session_list_s { struct session_list_s {
void *session; void *session;
@ -32,7 +32,7 @@ struct session_list_s {
struct session_list_s *sesslist=NULL; struct session_list_s *sesslist=NULL;
static int lambdasim_initialize_all(void **dut, void *base) static int litex_sim_initialize_all(void **dut, void *base)
{ {
struct module_s *ml=NULL; struct module_s *ml=NULL;
struct module_s *mli=NULL; struct module_s *mli=NULL;
@ -47,7 +47,7 @@ static int lambdasim_initialize_all(void **dut, void *base)
int ret = RC_OK; int ret = RC_OK;
/* Load external modules */ /* Load external modules */
ret = lambdasim_load_ext_modules(&mlist); ret = litex_sim_load_ext_modules(&mlist);
if(RC_OK != ret) if(RC_OK != ret)
{ {
goto out; goto out;
@ -61,16 +61,16 @@ static int lambdasim_initialize_all(void **dut, void *base)
} }
/* Load configuration */ /* Load configuration */
ret = lambdasim_file_to_module_list("sim_config.js", &ml); ret = litex_sim_file_to_module_list("sim_config.js", &ml);
if(RC_OK != ret) if(RC_OK != ret)
{ {
goto out; goto out;
} }
/* Init generated */ /* Init generated */
lambdasim_init(&vdut); litex_sim_init(&vdut);
/* Get pads from generated */ /* Get pads from generated */
ret = lambdasim_pads_get_list(&plist); ret = litex_sim_pads_get_list(&plist);
if(RC_OK != ret) if(RC_OK != ret)
{ {
goto out; goto out;
@ -81,7 +81,7 @@ static int lambdasim_initialize_all(void **dut, void *base)
/* Find the module in the external module */ /* Find the module in the external module */
pmlist = NULL; pmlist = NULL;
ret = lambdasim_find_ext_module(mlist, mli->name, &pmlist ); ret = litex_sim_find_ext_module(mlist, mli->name, &pmlist );
if(RC_OK != ret) if(RC_OK != ret)
{ {
goto out; goto out;
@ -115,7 +115,7 @@ static int lambdasim_initialize_all(void **dut, void *base)
{ {
/*Find the pads */ /*Find the pads */
pplist=NULL; pplist=NULL;
ret = lambdasim_pads_find(plist, mli->iface[i].name, mli->iface[i].index, &pplist); ret = litex_sim_pads_find(plist, mli->iface[i].name, mli->iface[i].index, &pplist);
if(RC_OK != ret) if(RC_OK != ret)
{ {
goto out; goto out;
@ -137,7 +137,7 @@ out:
return ret; return ret;
} }
int lambdasim_sort_session() int litex_sim_sort_session()
{ {
struct session_list_s *s; struct session_list_s *s;
struct session_list_s *sprev=sesslist; struct session_list_s *sprev=sesslist;
@ -175,7 +175,7 @@ static void cb(int sock, short which, void *arg)
int i; int i;
//lambdasim_eval(vdut); //litex_sim_eval(vdut);
for(i = 0; i < 1000; i++) for(i = 0; i < 1000; i++)
{ {
for(s = sesslist; s; s=s->next) for(s = sesslist; s; s=s->next)
@ -183,14 +183,14 @@ static void cb(int sock, short which, void *arg)
if(s->tickfirst) if(s->tickfirst)
s->module->tick(s->session); s->module->tick(s->session);
} }
lambdasim_eval(vdut); litex_sim_eval(vdut);
for(s = sesslist; s; s=s->next) for(s = sesslist; s; s=s->next)
{ {
if(!s->tickfirst) if(!s->tickfirst)
s->module->tick(s->session); s->module->tick(s->session);
} }
} }
//lambdasim_eval(vdut); //litex_sim_eval(vdut);
if (!evtimer_pending(ev, NULL)) { if (!evtimer_pending(ev, NULL)) {
@ -221,12 +221,12 @@ int main()
goto out; goto out;
} }
if(RC_OK != (ret = lambdasim_initialize_all(&vdut, base))) if(RC_OK != (ret = litex_sim_initialize_all(&vdut, base)))
{ {
goto out; goto out;
} }
if(RC_OK != (ret = lambdasim_sort_session())) if(RC_OK != (ret = litex_sim_sort_session()))
{ {
goto out; goto out;
} }

View File

@ -11,13 +11,13 @@
VerilatedVcdC* tfp; VerilatedVcdC* tfp;
extern "C" void lambdasim_eval(void *vdut) extern "C" void litex_sim_eval(void *vdut)
{ {
Vdut *dut = (Vdut*)vdut; Vdut *dut = (Vdut*)vdut;
dut->eval(); dut->eval();
} }
extern "C" void lambdasim_init_tracer(void *vdut) extern "C" void litex_sim_init_tracer(void *vdut)
{ {
Vdut *dut = (Vdut*)vdut; Vdut *dut = (Vdut*)vdut;
Verilated::traceEverOn(true); Verilated::traceEverOn(true);
@ -26,7 +26,7 @@ extern "C" void lambdasim_init_tracer(void *vdut)
tfp->open("dut.vcd"); tfp->open("dut.vcd");
} }
extern "C" void lambdasim_tracer_dump() extern "C" void litex_sim_tracer_dump()
{ {
static unsigned int ticks=0; static unsigned int ticks=0;
tfp->dump(ticks++); tfp->dump(ticks++);

View File

@ -4,13 +4,13 @@
#define __VERIL_H_ #define __VERIL_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" void lambdasim_eval(void *vdut); extern "C" void litex_sim_eval(void *vdut);
extern "C" void lambdasim_init_tracer(void *vdut); extern "C" void litex_sim_init_tracer(void *vdut);
extern "C" void lambdasim_tracer_dump(); extern "C" void litex_sim_tracer_dump();
#else #else
void lambdasim_eval(void *vdut); void litex_sim_eval(void *vdut);
void lambdasim_init_tracer(void *vdut); void litex_sim_init_tracer(void *vdut);
void lambdasim_tracer_dump(); void litex_sim_tracer_dump();
#endif #endif
#endif #endif

View File

@ -38,7 +38,7 @@ def _generate_sim_h(platform):
content += """\ content += """\
#ifndef __cplusplus #ifndef __cplusplus
void lambdasim_init(void **out); void litex_sim_init(void **out);
#endif #endif
#endif /* __SIM_CORE_H_ */ #endif /* __SIM_CORE_H_ */
@ -53,7 +53,7 @@ def _generate_sim_cpp_struct(name, index, siglist):
content += ' {}{}[{}].signal = &dut->{};\n'.format(name, index, i, sigfname) content += ' {}{}[{}].signal = &dut->{};\n'.format(name, index, i, sigfname)
idx_int = 0 if not index else int(index) idx_int = 0 if not index else int(index)
content += ' lambdasim_register_pads({}{}, (char*)"{}", {});\n\n'.format(name, index, name, idx_int) content += ' litex_sim_register_pads({}{}, (char*)"{}", {});\n\n'.format(name, index, name, idx_int)
return content return content
@ -67,7 +67,7 @@ def _generate_sim_cpp(platform):
#include <verilated.h> #include <verilated.h>
#include "dut_header.h" #include "dut_header.h"
extern "C" void lambdasim_init(void **out) extern "C" void litex_sim_init(void **out)
{ {
Vdut *dut; Vdut *dut;