Compare commits

...

6 commits

Author SHA1 Message Date
Stephan I. Böttcher
f9cafce309 Merge branch 'master' of forge.bexus.org:Stephan/irena-arm 2025-02-24 17:48:18 +01:00
Stephan I. Böttcher
94b0583750 dorn_l*: how parameter 2025-02-24 17:47:03 +01:00
Stephan I. Böttcher
c84569a7c2 altera_set_reg: remove unnecessary condition 2025-02-24 17:45:58 +01:00
Stephan I. Böttcher
60d3d37f86 dorn: force write to mem registers 2025-02-24 17:15:10 +01:00
Stephan I. Böttcher
87930f06d8 parse_index: initialize a 2025-02-24 16:59:57 +01:00
stephan
e4ba650d5c i2c_addr: fix parse
git-svn-id: svn+ssh://asterix.ieap.uni-kiel.de/home/subversion/stephan/solo/eda/arm@9280 bc5caf13-1734-44f8-af43-603852e9ee25
2025-02-24 15:44:08 +00:00
3 changed files with 28 additions and 21 deletions

View file

@ -483,7 +483,7 @@ int altera_set_register(struct command *cmd, const struct command_par *par,
} }
if (e) if (e)
return parser_error_message(cmd, e); return parser_error_message(cmd, e);
if (!e && how & alt_cmd_save) if (how & alt_cmd_save)
ssp_response = r.u; ssp_response = r.u;
const char *fmt; const char *fmt;
int ccsize = cc&0xffff4000 ? 8 : 4; int ccsize = cc&0xffff4000 ? 8 : 4;

45
dorn.c
View file

@ -37,30 +37,34 @@ static const struct keywords dorn_trigger_kw[] = {
int dorn_trigger(struct command *cmd, const struct command_par *par) int dorn_trigger(struct command *cmd, const struct command_par *par)
{ {
unsigned int a = (unsigned int)par->par; unsigned int a = (unsigned int)par->par;
error_msg_t e = parse_index(cmd, &a, 3, 11, 1); error_msg_t e = parse_index(cmd, &a, 3, 11, optional_expression | optional_in_brackets);
if (e) if (e)
return parser_error_message(cmd, e); return parser_error_message(cmd, e);
return altera_set_register(cmd, par, dorn_trigger_kw, 0, a, "trigger"); return altera_set_register(cmd, par, dorn_trigger_kw, 0, a, "trigger");
} }
static static inline
error_msg_t parse_channel(struct command *cmd, unsigned int *a, int c, int m, int b) error_msg_t parse_channel(struct command *cmd, unsigned int *a, int c, int m, int b)
{ {
error_msg_t e = parse_index(cmd, a, 3, 11, 1); error_msg_t e = parse_index(cmd, a, 3, 11,
optional_expression | optional_close | optional_in_brackets);
if (!e) if (!e)
e = parse_index(cmd, a, 63, c, 2); e = parse_index(cmd, a, 63, c,
optional_brackets | (m ? optional_close : 0) | optional_open);
if (!e && m) if (!e && m)
e = parse_index(cmd, a, m, b, 2); e = parse_index(cmd, a, m, b,
optional_brackets | optional_open);
return e; return e;
} }
int dorn_l1(struct command *cmd, const struct command_par *par) int dorn_l1(struct command *cmd, const struct command_par *par)
{ {
unsigned int a = (unsigned int)par->par; unsigned int how = (unsigned int)par->par;
unsigned int a = how & 0xffff;
error_msg_t e = parse_channel(cmd, &a, 0, 0, 0); error_msg_t e = parse_channel(cmd, &a, 0, 0, 0);
if (e) if (e)
return parser_error_message(cmd, e); return parser_error_message(cmd, e);
return altera_set_register(cmd, par, 0, alt_cmd_inj, a, "thres"); return altera_set_register(cmd, par, 0, how, a, "thres");
} }
static const static const
@ -72,33 +76,36 @@ struct keywords dorn_l2_kw[] = {
int dorn_l2(struct command *cmd, const struct command_par *par) int dorn_l2(struct command *cmd, const struct command_par *par)
{ {
unsigned int a = (unsigned int)par->par; unsigned int how = (unsigned int)par->par;
unsigned int a = how & 0xffff;
error_msg_t e = parse_channel(cmd, &a, 4, 7, 1); error_msg_t e = parse_channel(cmd, &a, 4, 7, 1);
if (e) if (e)
return parser_error_message(cmd, e); return parser_error_message(cmd, e);
return altera_set_register(cmd, par, dorn_l2_kw, alt_cmd_inj, a, "filter"); return altera_set_register(cmd, par, dorn_l2_kw, how, a, "filter");
} }
int dorn_l3(struct command *cmd, const struct command_par *par) int dorn_l3(struct command *cmd, const struct command_par *par)
{ {
unsigned int a = (unsigned int)par->par; unsigned int how = (unsigned int)par->par;
unsigned int a = how & 0xffff;
error_msg_t e = parse_channel(cmd, &a, 2, 3, 0); error_msg_t e = parse_channel(cmd, &a, 2, 3, 0);
if (e) if (e)
return parser_error_message(cmd, e); return parser_error_message(cmd, e);
return altera_set_register(cmd, par, 0, alt_cmd_inj, a, "banana"); return altera_set_register(cmd, par, 0, how, a, "banana");
} }
static const struct keywords dorn_commands[] = { static const struct keywords dorn_commands[] = {
CMD_KW("fifo", dorn_fifo, 255, (void*)(0xa080)), CMD_KW("fifo", dorn_fifo, 255, (void*)(0xa080)),
CMD_KW("enable", dorn_trigger, 255, (void*)(0xa008)), CMD_KW("enable", dorn_trigger, 255, (void*)(0xa008)),
CMD_KW("thres", dorn_l1, 255, (void*)(0xa040)), CMD_KW("thres", dorn_l1, 255, (void*)(0xe040|alt_cmd_inj)),
CMD_KW("l1", dorn_l1, 255, (void*)(0xa040)), CMD_KW("l1", dorn_l1, 255, (void*)(0xe040|alt_cmd_inj)),
CMD_KW("filter", dorn_l2, 255, (void*)(0xa400)), CMD_KW("filter", dorn_l2, 255, (void*)(0xe400|alt_cmd_inj)),
CMD_KW("l2", dorn_l2, 255, (void*)(0xa400)), CMD_KW("l2", dorn_l2, 255, (void*)(0xe400|alt_cmd_inj)),
CMD_KW("a", dorn_l2, 255, (void*)(0xa400)), CMD_KW("a", dorn_l2, 255, (void*)(0xe400|alt_cmd_inj)),
CMD_KW("b", dorn_l2, 255, (void*)(0xa401)), CMD_KW("b", dorn_l2, 255, (void*)(0xe401|alt_cmd_inj)),
CMD_KW("banana", dorn_l3, 255, (void*)(0xa100)), CMD_KW("ab", dorn_l2, 255, (void*)(0xe400|alt_cmd_inj|alt_cmd_double)),
CMD_KW("l3", dorn_l3, 255, (void*)(0xa100)), CMD_KW("banana", dorn_l3, 255, (void*)(0xe100|alt_cmd_inj)),
CMD_KW("l3", dorn_l3, 255, (void*)(0xe100|alt_cmd_inj)),
{"", {.par=&parser_unknown_command}} {"", {.par=&parser_unknown_command}}
}; };

View file

@ -405,7 +405,7 @@ error_msg_t parse_expression_square(struct command *cmd, unsigned int *r, int op
error_msg_t parse_index(struct command *cmd, unsigned int *r, unsigned int m, unsigned int b, int optional) error_msg_t parse_index(struct command *cmd, unsigned int *r, unsigned int m, unsigned int b, int optional)
{ {
unsigned int a; unsigned int a = 0;
error_msg_t e = parse_expression_square(cmd, &a, optional); error_msg_t e = parse_expression_square(cmd, &a, optional);
if (!e && a > m) if (!e && a > m)
e = &parser_value_error; e = &parser_value_error;