vec4 string literal expressions

This commit is contained in:
Stephen Williams 2014-01-06 08:35:23 -08:00
parent e5eb754150
commit fcc0a6a203
3 changed files with 42 additions and 1 deletions

View File

@ -2231,7 +2231,7 @@ static struct vector_info draw_realnum_expr(ivl_expr_t expr, unsigned wid)
return res; return res;
} }
static char *process_octal_codes(const char *in, unsigned width) char *process_octal_codes(const char *in, unsigned width)
{ {
unsigned idx = 0; unsigned idx = 0;
unsigned ridx = 0; unsigned ridx = 0;

View File

@ -560,6 +560,41 @@ static void draw_signal_vec4(ivl_expr_t expr)
clr_word(addr_index); clr_word(addr_index);
} }
static void draw_string_vec4(ivl_expr_t expr, int stuff_ok_flag)
{
unsigned wid = ivl_expr_width(expr);
char*fp = process_octal_codes(ivl_expr_string(expr), wid);
char*p = fp;
unsigned long tmp = 0;
unsigned tmp_wid = 0;
int push_flag = 0;
for (unsigned idx = 0 ; idx < wid ; idx += 8) {
tmp <<= 8;
tmp |= *p;
p += 1;
tmp_wid += 8;
if (tmp_wid == 32) {
fprintf(vvp_out, " %%pushi/vec4 %lu, 0, 32;\n", tmp);
tmp = 0;
tmp_wid = 0;
if (push_flag != 0)
push_flag += 1;
else
fprintf(vvp_out, " %%concat/vec4;\n");
}
}
if (tmp_wid > 0) {
fprintf(vvp_out, " %%pushi/vec4 %lu, 0, %u;\n", tmp, tmp_wid);
if (push_flag != 0)
fprintf(vvp_out, " %%oncat/vec4;\n");
}
free(fp);
}
static void draw_ternary_vec4(ivl_expr_t expr, int stuff_ok_flag) static void draw_ternary_vec4(ivl_expr_t expr, int stuff_ok_flag)
{ {
ivl_expr_t cond = ivl_expr_oper1(expr); ivl_expr_t cond = ivl_expr_oper1(expr);
@ -734,6 +769,10 @@ void draw_eval_vec4(ivl_expr_t expr, int stuff_ok_flag)
draw_signal_vec4(expr); draw_signal_vec4(expr);
return; return;
case IVL_EX_STRING:
draw_string_vec4(expr, stuff_ok_flag);
return;
case IVL_EX_TERNARY: case IVL_EX_TERNARY:
draw_ternary_vec4(expr, stuff_ok_flag); draw_ternary_vec4(expr, stuff_ok_flag);
return; return;

View File

@ -112,6 +112,8 @@ extern void draw_ufunc_object(ivl_expr_t expr);
extern void pad_expr_in_place(ivl_expr_t expr, struct vector_info res, extern void pad_expr_in_place(ivl_expr_t expr, struct vector_info res,
unsigned swid); unsigned swid);
extern char* process_octal_codes(const char*txt, unsigned wid);
/* /*
* modpath.c symbols. * modpath.c symbols.
* *