From 4a0a43111933fef230be4353c482329623144c1e Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Wed, 28 Jun 2017 16:28:45 +0200 Subject: [PATCH] litex/build/sim: rename c functions from lambdasim to litex_sim (since integrated in litex) --- litex/build/sim/core/modules.c | 20 ++++++------- litex/build/sim/core/modules.h | 6 ++-- .../build/sim/core/modules/clocker/clocker.c | 6 ++-- .../sim/core/modules/ethernet/ethernet.c | 24 ++++++++-------- .../modules/serial2console/serial2console.c | 18 ++++++------ .../sim/core/modules/serial2tcp/serial2tcp.c | 22 +++++++-------- litex/build/sim/core/pads.c | 6 ++-- litex/build/sim/core/pads.h | 8 +++--- litex/build/sim/core/parse.c | 2 +- litex/build/sim/core/sim.c | 28 +++++++++---------- litex/build/sim/core/veril.cpp | 6 ++-- litex/build/sim/core/veril.h | 12 ++++---- litex/build/sim/verilator.py | 6 ++-- 13 files changed, 82 insertions(+), 82 deletions(-) diff --git a/litex/build/sim/core/modules.c b/litex/build/sim/core/modules.c index a5c57d9cc..f8d66da7a 100644 --- a/litex/build/sim/core/modules.c +++ b/litex/build/sim/core/modules.c @@ -16,7 +16,7 @@ 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; struct ext_module_list_s *ml=NULL; @@ -43,13 +43,13 @@ out: 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; tinydir_dir dir; tinydir_file file; 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]; if (tinydir_open(&dir, "./modules/") == -1) { @@ -82,20 +82,20 @@ int lambdasim_load_ext_modules(struct ext_module_list_s **mlist) goto out; } - if(!libdylib_find(lib, "lambdasim_ext_module_init")) + if(!libdylib_find(lib, "litex_sim_ext_module_init")) { 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; } - LIBDYLIB_BINDNAME(lib, lambdasim_ext_module_init); - if(!lambdasim_ext_module_init) + LIBDYLIB_BINDNAME(lib, litex_sim_ext_module_init); + if(!litex_sim_ext_module_init) { ret = RC_ERROR; eprintf("Can't bind %s\n", libdylib_last_error()); 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) { goto out; @@ -114,7 +114,7 @@ out: 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; int ret=RC_OK; @@ -136,7 +136,7 @@ out: 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; int ret=RC_OK; diff --git a/litex/build/sim/core/modules.h b/litex/build/sim/core/modules.h index d6ab8a02c..ea83d9ebd 100644 --- a/litex/build/sim/core/modules.h +++ b/litex/build/sim/core/modules.h @@ -33,8 +33,8 @@ struct ext_module_list_s { struct ext_module_list_s *next; }; -int lambdasim_file_to_module_list(char *filename, struct module_s **mod); -int lambdasim_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_file_to_module_list(char *filename, struct module_s **mod); +int litex_sim_load_ext_modules(struct ext_module_list_s **mlist); +int litex_sim_find_ext_module(struct ext_module_list_s *first, char *name , struct ext_module_list_s **found); #endif diff --git a/litex/build/sim/core/modules/clocker/clocker.c b/litex/build/sim/core/modules/clocker/clocker.c index 3681e1606..3543534aa 100644 --- a/litex/build/sim/core/modules/clocker/clocker.c +++ b/litex/build/sim/core/modules/clocker/clocker.c @@ -8,7 +8,7 @@ struct session_s { 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; 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")) { - 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; @@ -104,7 +104,7 @@ static struct ext_module_s ext_mod = { 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; ret = register_module(&ext_mod); diff --git a/litex/build/sim/core/modules/ethernet/ethernet.c b/litex/build/sim/core/modules/ethernet/ethernet.c index 90601668a..00882fa67 100644 --- a/litex/build/sim/core/modules/ethernet/ethernet.c +++ b/litex/build/sim/core/modules/ethernet/ethernet.c @@ -37,7 +37,7 @@ struct session_s { 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; json_object *jsobj=NULL; @@ -73,7 +73,7 @@ out: 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; void *sig=NULL; @@ -159,14 +159,14 @@ static int ethernet_new(void **sess, char *args) } 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) { 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) { @@ -206,17 +206,17 @@ static int ethernet_add_pads(void *sess, struct pad_list_s *plist) pads = plist->pads; if(!strcmp(plist->name, "eth")) { - lambdasim_module_pads_get(pads, "sink_data", (void**)&s->rx); - lambdasim_module_pads_get(pads, "sink_valid", (void**)&s->rx_valid); - lambdasim_module_pads_get(pads, "sink_ready", (void**)&s->rx_ready); - lambdasim_module_pads_get(pads, "source_data", (void**)&s->tx); - lambdasim_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, "sink_data", (void**)&s->rx); + litex_sim_module_pads_get(pads, "sink_valid", (void**)&s->rx_valid); + litex_sim_module_pads_get(pads, "sink_ready", (void**)&s->rx_ready); + litex_sim_module_pads_get(pads, "source_data", (void**)&s->tx); + litex_sim_module_pads_get(pads, "source_valid", (void**)&s->tx_valid); + litex_sim_module_pads_get(pads, "source_ready", (void**)&s->tx_ready); } 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: @@ -302,7 +302,7 @@ static struct ext_module_s ext_mod = { 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; ret = register_module(&ext_mod); diff --git a/litex/build/sim/core/modules/serial2console/serial2console.c b/litex/build/sim/core/modules/serial2console/serial2console.c index 26813f8d1..ebdffe147 100644 --- a/litex/build/sim/core/modules/serial2console/serial2console.c +++ b/litex/build/sim/core/modules/serial2console/serial2console.c @@ -25,7 +25,7 @@ struct session_s { }; 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; void *sig=NULL; @@ -134,17 +134,17 @@ static int serial2console_add_pads(void *sess, struct pad_list_s *plist) pads = plist->pads; if(!strcmp(plist->name, "serial")) { - lambdasim_module_pads_get(pads, "sink_data", (void**)&s->rx); - lambdasim_module_pads_get(pads, "sink_valid", (void**)&s->rx_valid); - lambdasim_module_pads_get(pads, "sink_ready", (void**)&s->rx_ready); - lambdasim_module_pads_get(pads, "source_data", (void**)&s->tx); - lambdasim_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, "sink_data", (void**)&s->rx); + litex_sim_module_pads_get(pads, "sink_valid", (void**)&s->rx_valid); + litex_sim_module_pads_get(pads, "sink_ready", (void**)&s->rx_ready); + litex_sim_module_pads_get(pads, "source_data", (void**)&s->tx); + litex_sim_module_pads_get(pads, "source_valid", (void**)&s->tx_valid); + litex_sim_module_pads_get(pads, "source_ready", (void**)&s->tx_ready); } 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 }; -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; ret = register_module(&ext_mod); diff --git a/litex/build/sim/core/modules/serial2tcp/serial2tcp.c b/litex/build/sim/core/modules/serial2tcp/serial2tcp.c index 181f35005..8e8eaf9e5 100644 --- a/litex/build/sim/core/modules/serial2tcp/serial2tcp.c +++ b/litex/build/sim/core/modules/serial2tcp/serial2tcp.c @@ -27,7 +27,7 @@ struct session_s { 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; json_object *jsobj=NULL; @@ -63,7 +63,7 @@ out: 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; void *sig=NULL; @@ -156,7 +156,7 @@ static int serial2tcp_new(void **sess, char *args) goto out; } - ret = lambdasim_module_get_args(args, "port", &cport); + ret = litex_sim_module_get_args(args, "port", &cport); { if(RC_OK != ret) { @@ -214,17 +214,17 @@ static int serial2tcp_add_pads(void *sess, struct pad_list_s *plist) pads = plist->pads; if(!strcmp(plist->name, "serial")) { - lambdasim_module_pads_get(pads, "sink_data", (void**)&s->rx); - lambdasim_module_pads_get(pads, "sink_valid", (void**)&s->rx_valid); - lambdasim_module_pads_get(pads, "sink_ready", (void**)&s->rx_ready); - lambdasim_module_pads_get(pads, "source_data", (void**)&s->tx); - lambdasim_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, "sink_data", (void**)&s->rx); + litex_sim_module_pads_get(pads, "sink_valid", (void**)&s->rx_valid); + litex_sim_module_pads_get(pads, "sink_ready", (void**)&s->rx_ready); + litex_sim_module_pads_get(pads, "source_data", (void**)&s->tx); + litex_sim_module_pads_get(pads, "source_valid", (void**)&s->tx_valid); + litex_sim_module_pads_get(pads, "source_ready", (void**)&s->tx_ready); } 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 }; -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; ret = register_module(&ext_mod); diff --git a/litex/build/sim/core/pads.c b/litex/build/sim/core/pads.c index 336dbce76..225a34c3b 100644 --- a/litex/build/sim/core/pads.c +++ b/litex/build/sim/core/pads.c @@ -8,7 +8,7 @@ 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; @@ -41,7 +41,7 @@ out: 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; @@ -58,7 +58,7 @@ out: 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; int ret=RC_OK; diff --git a/litex/build/sim/core/pads.h b/litex/build/sim/core/pads.h index 8385cb2ef..6d6f7ea94 100644 --- a/litex/build/sim/core/pads.h +++ b/litex/build/sim/core/pads.h @@ -16,13 +16,13 @@ struct pad_list_s { struct pad_list_s *next; }; -int lambdasim_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_get_list(struct pad_list_s **plist); +int litex_sim_pads_find(struct pad_list_s *first, char *name, int index, struct pad_list_s **found); #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 -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 diff --git a/litex/build/sim/core/parse.c b/litex/build/sim/core/parse.c index a969f1f13..29d483d0d 100644 --- a/litex/build/sim/core/parse.c +++ b/litex/build/sim/core/parse.c @@ -299,7 +299,7 @@ out: 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; json_object *obj=NULL; diff --git a/litex/build/sim/core/sim.c b/litex/build/sim/core/sim.c index bee87f58d..0291883e0 100644 --- a/litex/build/sim/core/sim.c +++ b/litex/build/sim/core/sim.c @@ -21,7 +21,7 @@ #include #include -void lambdasim_init(void **out); +void litex_sim_init(void **out); struct session_list_s { void *session; @@ -32,7 +32,7 @@ struct session_list_s { 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 *mli=NULL; @@ -47,7 +47,7 @@ static int lambdasim_initialize_all(void **dut, void *base) int ret = RC_OK; /* Load external modules */ - ret = lambdasim_load_ext_modules(&mlist); + ret = litex_sim_load_ext_modules(&mlist); if(RC_OK != ret) { goto out; @@ -61,16 +61,16 @@ static int lambdasim_initialize_all(void **dut, void *base) } /* 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) { goto out; } /* Init generated */ - lambdasim_init(&vdut); + litex_sim_init(&vdut); /* Get pads from generated */ - ret = lambdasim_pads_get_list(&plist); + ret = litex_sim_pads_get_list(&plist); if(RC_OK != ret) { goto out; @@ -81,7 +81,7 @@ static int lambdasim_initialize_all(void **dut, void *base) /* Find the module in the external module */ 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) { goto out; @@ -115,7 +115,7 @@ static int lambdasim_initialize_all(void **dut, void *base) { /*Find the pads */ 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) { goto out; @@ -137,7 +137,7 @@ out: return ret; } -int lambdasim_sort_session() +int litex_sim_sort_session() { struct session_list_s *s; struct session_list_s *sprev=sesslist; @@ -175,7 +175,7 @@ static void cb(int sock, short which, void *arg) int i; - //lambdasim_eval(vdut); + //litex_sim_eval(vdut); for(i = 0; i < 1000; i++) { for(s = sesslist; s; s=s->next) @@ -183,14 +183,14 @@ static void cb(int sock, short which, void *arg) if(s->tickfirst) s->module->tick(s->session); } - lambdasim_eval(vdut); + litex_sim_eval(vdut); for(s = sesslist; s; s=s->next) { if(!s->tickfirst) s->module->tick(s->session); } } - //lambdasim_eval(vdut); + //litex_sim_eval(vdut); if (!evtimer_pending(ev, NULL)) { @@ -221,12 +221,12 @@ int main() goto out; } - if(RC_OK != (ret = lambdasim_initialize_all(&vdut, base))) + if(RC_OK != (ret = litex_sim_initialize_all(&vdut, base))) { goto out; } - if(RC_OK != (ret = lambdasim_sort_session())) + if(RC_OK != (ret = litex_sim_sort_session())) { goto out; } diff --git a/litex/build/sim/core/veril.cpp b/litex/build/sim/core/veril.cpp index 677d6ff89..cf5db23b5 100644 --- a/litex/build/sim/core/veril.cpp +++ b/litex/build/sim/core/veril.cpp @@ -11,13 +11,13 @@ VerilatedVcdC* tfp; -extern "C" void lambdasim_eval(void *vdut) +extern "C" void litex_sim_eval(void *vdut) { Vdut *dut = (Vdut*)vdut; dut->eval(); } -extern "C" void lambdasim_init_tracer(void *vdut) +extern "C" void litex_sim_init_tracer(void *vdut) { Vdut *dut = (Vdut*)vdut; Verilated::traceEverOn(true); @@ -26,7 +26,7 @@ extern "C" void lambdasim_init_tracer(void *vdut) tfp->open("dut.vcd"); } -extern "C" void lambdasim_tracer_dump() +extern "C" void litex_sim_tracer_dump() { static unsigned int ticks=0; tfp->dump(ticks++); diff --git a/litex/build/sim/core/veril.h b/litex/build/sim/core/veril.h index ce27a32ca..b780793bf 100644 --- a/litex/build/sim/core/veril.h +++ b/litex/build/sim/core/veril.h @@ -4,13 +4,13 @@ #define __VERIL_H_ #ifdef __cplusplus -extern "C" void lambdasim_eval(void *vdut); -extern "C" void lambdasim_init_tracer(void *vdut); -extern "C" void lambdasim_tracer_dump(); +extern "C" void litex_sim_eval(void *vdut); +extern "C" void litex_sim_init_tracer(void *vdut); +extern "C" void litex_sim_tracer_dump(); #else -void lambdasim_eval(void *vdut); -void lambdasim_init_tracer(void *vdut); -void lambdasim_tracer_dump(); +void litex_sim_eval(void *vdut); +void litex_sim_init_tracer(void *vdut); +void litex_sim_tracer_dump(); #endif #endif diff --git a/litex/build/sim/verilator.py b/litex/build/sim/verilator.py index 594eaa857..312d51e3f 100644 --- a/litex/build/sim/verilator.py +++ b/litex/build/sim/verilator.py @@ -38,7 +38,7 @@ def _generate_sim_h(platform): content += """\ #ifndef __cplusplus -void lambdasim_init(void **out); +void litex_sim_init(void **out); #endif #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) 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 @@ -67,7 +67,7 @@ def _generate_sim_cpp(platform): #include #include "dut_header.h" -extern "C" void lambdasim_init(void **out) +extern "C" void litex_sim_init(void **out) { Vdut *dut;