Skip to content

Commit 9cdcfa8

Browse files
committed
Remove TCL elaborate/vsim command
1 parent 9a853a3 commit 9cdcfa8

File tree

9 files changed

+79
-187
lines changed

9 files changed

+79
-187
lines changed

src/rt/shell.c

+9-112
Original file line numberDiff line numberDiff line change
@@ -161,29 +161,15 @@ static void shell_printf(tcl_shell_t *sh, const char *fmt, ...)
161161
static bool shell_has_model(tcl_shell_t *sh)
162162
{
163163
if (sh->model == NULL) {
164-
tcl_error(sh, "no simulation loaded, try the $bold$elaborate$$ "
165-
"command first");
164+
tcl_error(sh, "no simulation loaded, elaborate first with the "
165+
"$bold$-e$$ command or pass the top-level design unit "
166+
"as a command line argument");
166167
return false;
167168
}
168169

169170
return true;
170171
}
171172

172-
static void shell_clear_model(tcl_shell_t *sh)
173-
{
174-
if (sh->model == NULL)
175-
return;
176-
177-
model_free(sh->model);
178-
hash_free(sh->namemap);
179-
180-
sh->model = NULL;
181-
sh->namemap = NULL;
182-
183-
if (sh->handler.quit_sim != NULL)
184-
(*sh->handler.quit_sim)(sh->handler.context);
185-
}
186-
187173
static void shell_next_time_step(rt_model_t *m, void *user)
188174
{
189175
tcl_shell_t *sh = user;
@@ -496,67 +482,15 @@ static int shell_cmd_find(ClientData cd, Tcl_Interp *interp,
496482
}
497483

498484
static const char elaborate_help[] =
499-
"Elaborate a design hierarchy\n"
500-
"\n"
501-
"Syntax:\n"
502-
" elaborate [options] <toplevel>\n"
503-
"\n"
504-
"Note \"vsim\" is an alias of this command.\n"
505-
"\n"
506-
"Options:\n"
507-
"\n"
508-
"Examples:\n"
509-
" elaborate toplevel\n"
510-
" vsim toplevel\n";
485+
"Obsolete command which does nothing.\n";
511486

512487
static int shell_cmd_elaborate(ClientData cd, Tcl_Interp *interp,
513488
int objc, Tcl_Obj *const objv[])
514489
{
515490
tcl_shell_t *sh = cd;
516-
LOCAL_TEXT_BUF tb = tb_new();
517-
518-
int pos = 1;
519-
for (const char *opt; (opt = Tcl_GetString(objv[pos]))[0] == '-'; pos++)
520-
goto usage;
521-
522-
if (pos + 1 != objc)
523-
goto usage;
524-
525-
lib_t work = lib_work();
526-
527-
tb_istr(tb, lib_name(work));
528-
tb_append(tb, '.');
529-
tb_cat(tb, Tcl_GetString(objv[pos]));
530-
tb_upcase(tb);
531-
532-
tree_t unit = lib_get(lib_work(), ident_new(tb_get(tb)));
533-
if (unit == NULL)
534-
return tcl_error(sh, "cannot find unit %s in library %s",
535-
Tcl_GetString(objv[pos]), istr(lib_name(work)));
536-
537-
shell_clear_model(sh);
538-
539-
reset_error_count();
540-
541-
// Recreate the JIT instance and unit registry as it may have
542-
// references to stale code
543-
jit_free(sh->jit);
544-
unit_registry_free(sh->registry);
545-
sh->registry = unit_registry_new();
546-
sh->jit = (*sh->make_jit)(sh->registry);
547-
548-
rt_model_t *m = model_new(sh->jit, NULL);
549-
tree_t top = elab(tree_to_object(unit), sh->jit, sh->registry,
550-
NULL, NULL, m);
551-
model_free(m); // XXX: reuse
552-
if (top == NULL)
553-
return TCL_ERROR;
554-
555-
shell_reset(sh, top);
556-
return TCL_OK;
557-
558-
usage:
559-
return syntax_error(sh, objv);
491+
return tcl_error(sh, "the elaborate/vsim command has been removed, "
492+
"elaborate the design first with \"nvc -e top --do ...\" "
493+
"or \"nvc -e top -i\"");
560494
}
561495

562496
static const char examine_help[] =
@@ -914,48 +848,13 @@ static int shell_cmd_add(ClientData cd, Tcl_Interp *interp,
914848
}
915849

916850
static const char quit_help[] =
917-
"Exit the simulator or unload the current design\n"
918-
"\n"
919-
"Syntax:\n"
920-
" quit [-sim]\n"
921-
"\n"
922-
"Options:\n"
923-
" -sim\t\tUnload the current simulation but do not exit the program.\n";
851+
"Obsolete command which does nothing.\n";
924852

925853
static int shell_cmd_quit(ClientData cd, Tcl_Interp *interp,
926854
int objc, Tcl_Obj *const objv[])
927855
{
928856
tcl_shell_t *sh = cd;
929-
930-
bool quit_sim = false;
931-
int pos = 1;
932-
for (const char *opt; (opt = next_option(&pos, objc, objv)); ) {
933-
if (strcmp(opt, "-sim") == 0)
934-
quit_sim = true;
935-
else
936-
goto usage;
937-
}
938-
939-
if (pos != objc)
940-
goto usage;
941-
942-
if (quit_sim) {
943-
if (!shell_has_model(sh))
944-
return TCL_ERROR;
945-
else
946-
shell_clear_model(sh);
947-
}
948-
else {
949-
sh->quit = true;
950-
951-
if (sh->handler.exit != NULL)
952-
(*sh->handler.exit)(0, sh->handler.context);
953-
}
954-
955-
return TCL_OK;
956-
957-
usage:
958-
return syntax_error(sh, objv);
857+
return tcl_error(sh, "the quit command has been removed");
959858
}
960859

961860
static const char exit_help[] =
@@ -1373,8 +1272,6 @@ static void recurse_objects(tcl_shell_t *sh, rt_scope_t *scope,
13731272

13741273
void shell_reset(tcl_shell_t *sh, tree_t top)
13751274
{
1376-
shell_clear_model(sh);
1377-
13781275
jit_reset(sh->jit);
13791276

13801277
sh->top = top;

src/rt/shell.h

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ typedef struct {
3131
void (*backchannel_write)(const char *buf, size_t nchars, void *ctx);
3232
void (*start_sim)(ident_t top, void *ctx);
3333
void (*restart_sim)(void *ctx);
34-
void (*quit_sim)(void *ctx);
3534
void (*exit)(int status, void *ctx);
3635
void (*next_time_step)(uint64_t now, void *ctx);
3736
void *context;

src/server.c

-10
Original file line numberDiff line numberDiff line change
@@ -714,15 +714,6 @@ static void restart_sim_handler(void *user)
714714
ws_send_packet(http->websocket, pb);
715715
}
716716

717-
static void quit_sim_handler(void *user)
718-
{
719-
http_server_t *http = container_of(user, http_server_t, server);
720-
721-
packet_buf_t *pb = fresh_packet_buffer(&(http->server));
722-
pb_pack_u8(pb, S2C_QUIT_SIM);
723-
ws_send_packet(http->websocket, pb);
724-
}
725-
726717
static void next_time_step_handler(uint64_t now, void *user)
727718
{
728719
http_server_t *http = container_of(user, http_server_t, server);
@@ -1445,7 +1436,6 @@ void start_server(server_kind_t kind, jit_factory_t make_jit,
14451436
.backchannel_write = tunnel_backchannel,
14461437
.start_sim = start_sim_handler,
14471438
.restart_sim = restart_sim_handler,
1448-
.quit_sim = quit_sim_handler,
14491439
.next_time_step = next_time_step_handler,
14501440
.context = server
14511441
};

src/server.h

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ typedef enum {
3535
S2C_INIT_CMD = 0x02,
3636
S2C_START_SIM = 0x03,
3737
S2C_RESTART_SIM = 0x04,
38-
S2C_QUIT_SIM = 0x05,
3938
S2C_NEXT_TIME_STEP = 0x06,
4039
S2C_BACKCHANNEL = 0x07,
4140
} s2c_opcode_t;

test/regress/tcl1.tcl

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ proc assert condition {
66

77
set testdir [file dirname [file normalize [info script]]]
88

9-
vsim tcl1
10-
119
puts "$now +$deltas"
1210
assert {expr $now == 0}
1311
assert {expr $deltas == 0}

test/regress/tcl2.tcl

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ proc assert condition {
66

77
set testdir [file dirname [file normalize [info script]]]
88

9-
vsim tcl2
10-
119
set sigs [find signals /*]
1210
puts $sigs
1311

test/test_server.c

+2-7
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,6 @@ static void wave_binary_frame(web_socket_t *ws, const void *data, size_t len,
346346
ck_assert_int_eq(bytes[0], S2C_RESTART_SIM);
347347
break;
348348

349-
case 7:
350-
ck_assert_int_eq(len, 1);
351-
ck_assert_int_eq(bytes[0], S2C_QUIT_SIM);
352-
break;
353-
354349
default:
355350
ck_abort_msg("unexpected call to binary_frame in state %d", *state - 1);
356351
}
@@ -386,15 +381,15 @@ START_TEST(test_wave)
386381

387382
ck_assert_int_eq(state, 6);
388383

389-
ws_send_text(ws, "restart; quit -sim");
384+
ws_send_text(ws, "restart");
390385
ws_flush(ws);
391386

392387
ws_poll(ws);
393388

394389
shutdown_server(ws);
395390
ws_free(ws);
396391

397-
ck_assert_int_eq(state, 8);
392+
ck_assert_int_eq(state, 7);
398393

399394
close(sock);
400395
join_server(pid);

0 commit comments

Comments
 (0)