-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcommand.c
67 lines (61 loc) · 1.58 KB
/
command.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (c) 2023 - The University of Texas at Austin
// This work was produced under contract #2317831 to National Technology and
// Engineering Solutions of Sandia, LLC which is under contract
// No. DE-NA0003525 with the U.S. Department of Energy.
// command.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "print.h"
#include "arch.h"
#include "network.h"
#include "command.h"
#include "sim.h"
int command_parse_input_spikes(struct network *const net,
char fields[][MAX_FIELD_LEN], const int field_count)
{
double val;
int ret, input_count;
input_count = field_count - 1;
if (input_count > net->external_input_count)
{
INFO("Error: Too many inputs given.\n");
return RET_FAIL;
}
for (int i = 0; i < input_count; i++)
{
struct input *in = &(net->external_inputs[i]);
ret = sscanf(fields[i + 1], "%lf", &val);
if (ret < 1)
{
INFO("Error: Couldn't parse input value (%s)\n",
fields[i + 1]);
return RET_FAIL;
}
else if (val < 0)
{
INFO("Warning: id:%d input rate < 0 (%lf)\n", in->id,
in->spike_val);
}
//else if (val > 1.0)
//{
// INFO("Warning: id:%d input rate > 1 (%lf)\n",
// in->id, in->spike_val);
//}
network_set_input(net, i, val);
INFO("Parsed input %d=%lf\n", in->id, in->spike_val);
}
return RET_OK;
}
int command_parse_step_sim(struct network *const net,
struct architecture *const arch,
// char fields[][MAX_FIELD_LEN],
// const int field_count,
struct simulation *sim)
{
INFO("not implemented\n");
exit(1);
//sim_timestep(sim, net, arch, scheduler);
return RET_OK;
}