Add vvp implementations for pop_back and pop_front methods.
This commit is contained in:
parent
8c2d51142b
commit
335db49282
|
|
@ -3126,6 +3126,29 @@ static struct vector_info draw_ternary_expr(ivl_expr_t expr, unsigned wid)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct vector_info draw_darray_pop(ivl_expr_t expr, unsigned wid)
|
||||||
|
{
|
||||||
|
struct vector_info res;
|
||||||
|
ivl_expr_t arg;
|
||||||
|
const char*fb;
|
||||||
|
|
||||||
|
if (strcmp(ivl_expr_name(expr), "$ivl_darray_method$pop_back")==0)
|
||||||
|
fb = "b";
|
||||||
|
else
|
||||||
|
fb = "f";
|
||||||
|
|
||||||
|
res.base = allocate_vector(wid);
|
||||||
|
res.wid = wid;
|
||||||
|
|
||||||
|
arg = ivl_expr_parm(expr, 0);
|
||||||
|
assert(ivl_expr_type(arg) == IVL_EX_SIGNAL);
|
||||||
|
|
||||||
|
fprintf(vvp_out, " %%qpop/%s v%p_0, %u, %u;\n", fb,
|
||||||
|
ivl_expr_signal(arg), res.base, res.wid);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
static struct vector_info draw_sfunc_expr(ivl_expr_t expr, unsigned wid)
|
static struct vector_info draw_sfunc_expr(ivl_expr_t expr, unsigned wid)
|
||||||
{
|
{
|
||||||
unsigned parm_count = ivl_expr_parms(expr);
|
unsigned parm_count = ivl_expr_parms(expr);
|
||||||
|
|
@ -3147,6 +3170,11 @@ static struct vector_info draw_sfunc_expr(ivl_expr_t expr, unsigned wid)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strcmp(ivl_expr_name(expr), "$ivl_darray_method$pop_back")==0)
|
||||||
|
return draw_darray_pop(expr, wid);
|
||||||
|
if (strcmp(ivl_expr_name(expr),"$ivl_darray_method$pop_front")==0)
|
||||||
|
return draw_darray_pop(expr, wid);
|
||||||
|
|
||||||
res = draw_vpi_func_call(expr, wid);
|
res = draw_vpi_func_call(expr, wid);
|
||||||
|
|
||||||
/* New basic block starts after VPI calls. */
|
/* New basic block starts after VPI calls. */
|
||||||
|
|
|
||||||
|
|
@ -150,6 +150,22 @@ static void string_ex_substr(ivl_expr_t expr)
|
||||||
clr_word(arg2);
|
clr_word(arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void string_ex_pop(ivl_expr_t expr)
|
||||||
|
{
|
||||||
|
const char*fb;
|
||||||
|
ivl_expr_t arg;
|
||||||
|
|
||||||
|
if (strcmp(ivl_expr_name(expr), "$ivl_darray_method$pop_back")==0)
|
||||||
|
fb = "b";
|
||||||
|
else
|
||||||
|
fb = "f";
|
||||||
|
|
||||||
|
arg = ivl_expr_parm(expr, 0);
|
||||||
|
assert(ivl_expr_type(arg) == IVL_EX_SIGNAL);
|
||||||
|
|
||||||
|
fprintf(vvp_out, " %%qpop/%s/str v%p_0;\n", fb, ivl_expr_signal(arg));
|
||||||
|
}
|
||||||
|
|
||||||
void draw_eval_string(ivl_expr_t expr)
|
void draw_eval_string(ivl_expr_t expr)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -177,6 +193,10 @@ void draw_eval_string(ivl_expr_t expr)
|
||||||
case IVL_EX_SFUNC:
|
case IVL_EX_SFUNC:
|
||||||
if (strcmp(ivl_expr_name(expr), "$ivl_string_method$substr") == 0)
|
if (strcmp(ivl_expr_name(expr), "$ivl_string_method$substr") == 0)
|
||||||
string_ex_substr(expr);
|
string_ex_substr(expr);
|
||||||
|
else if (strcmp(ivl_expr_name(expr), "$ivl_darray_method$pop_back")==0)
|
||||||
|
string_ex_pop(expr);
|
||||||
|
else if (strcmp(ivl_expr_name(expr), "$ivl_darray_method$pop_front")==0)
|
||||||
|
string_ex_pop(expr);
|
||||||
else
|
else
|
||||||
fallback_eval(expr);
|
fallback_eval(expr);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,10 @@ extern bool of_POP_STR(vthread_t thr, vvp_code_t code);
|
||||||
extern bool of_POW(vthread_t thr, vvp_code_t code);
|
extern bool of_POW(vthread_t thr, vvp_code_t code);
|
||||||
extern bool of_POW_S(vthread_t thr, vvp_code_t code);
|
extern bool of_POW_S(vthread_t thr, vvp_code_t code);
|
||||||
extern bool of_POW_WR(vthread_t thr, vvp_code_t code);
|
extern bool of_POW_WR(vthread_t thr, vvp_code_t code);
|
||||||
|
extern bool of_QPOP_B(vthread_t thr, vvp_code_t code);
|
||||||
|
extern bool of_QPOP_F(vthread_t thr, vvp_code_t code);
|
||||||
|
extern bool of_QPOP_B_STR(vthread_t thr, vvp_code_t code);
|
||||||
|
extern bool of_QPOP_F_STR(vthread_t thr, vvp_code_t code);
|
||||||
extern bool of_PROP_OBJ(vthread_t thr, vvp_code_t code);
|
extern bool of_PROP_OBJ(vthread_t thr, vvp_code_t code);
|
||||||
extern bool of_PROP_R(vthread_t thr, vvp_code_t code);
|
extern bool of_PROP_R(vthread_t thr, vvp_code_t code);
|
||||||
extern bool of_PROP_STR(vthread_t thr, vvp_code_t code);
|
extern bool of_PROP_STR(vthread_t thr, vvp_code_t code);
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,10 @@ static const struct opcode_table_s opcode_table[] = {
|
||||||
{ "%pushi/str", of_PUSHI_STR, 1,{OA_STRING, OA_NONE, OA_NONE} },
|
{ "%pushi/str", of_PUSHI_STR, 1,{OA_STRING, OA_NONE, OA_NONE} },
|
||||||
{ "%pushv/str", of_PUSHV_STR, 2, {OA_BIT1,OA_BIT2, OA_NONE} },
|
{ "%pushv/str", of_PUSHV_STR, 2, {OA_BIT1,OA_BIT2, OA_NONE} },
|
||||||
{ "%putc/str/v",of_PUTC_STR_V,3,{OA_FUNC_PTR,OA_BIT1, OA_BIT2} },
|
{ "%putc/str/v",of_PUTC_STR_V,3,{OA_FUNC_PTR,OA_BIT1, OA_BIT2} },
|
||||||
|
{ "%qpop/b", of_QPOP_B, 3,{OA_FUNC_PTR,OA_BIT1, OA_BIT2} },
|
||||||
|
{ "%qpop/f", of_QPOP_F, 3,{OA_FUNC_PTR,OA_BIT1, OA_BIT2} },
|
||||||
|
{ "%qpop/b/str",of_QPOP_B_STR,1,{OA_FUNC_PTR,OA_NONE, OA_NONE} },
|
||||||
|
{ "%qpop/f/str",of_QPOP_F_STR,1,{OA_FUNC_PTR,OA_NONE, OA_NONE} },
|
||||||
{ "%release/net",of_RELEASE_NET,3,{OA_FUNC_PTR,OA_BIT1,OA_BIT2} },
|
{ "%release/net",of_RELEASE_NET,3,{OA_FUNC_PTR,OA_BIT1,OA_BIT2} },
|
||||||
{ "%release/reg",of_RELEASE_REG,3,{OA_FUNC_PTR,OA_BIT1,OA_BIT2} },
|
{ "%release/reg",of_RELEASE_REG,3,{OA_FUNC_PTR,OA_BIT1,OA_BIT2} },
|
||||||
{ "%release/wr",of_RELEASE_WR,2,{OA_FUNC_PTR,OA_BIT1,OA_NONE} },
|
{ "%release/wr",of_RELEASE_WR,2,{OA_FUNC_PTR,OA_BIT1,OA_NONE} },
|
||||||
|
|
|
||||||
|
|
@ -4850,6 +4850,91 @@ bool of_PUTC_STR_V(vthread_t thr, vvp_code_t cp)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool of_QPOP_B(vthread_t thr, vvp_code_t cp)
|
||||||
|
{
|
||||||
|
unsigned bit = cp->bit_idx[0];
|
||||||
|
unsigned wid = cp->bit_idx[1];
|
||||||
|
|
||||||
|
vvp_net_t*net = cp->net;
|
||||||
|
vvp_fun_signal_object*obj = dynamic_cast<vvp_fun_signal_object*> (net->fun);
|
||||||
|
assert(obj);
|
||||||
|
|
||||||
|
vvp_queue*dqueue = obj->get_object().peek<vvp_queue>();
|
||||||
|
assert(dqueue);
|
||||||
|
|
||||||
|
size_t size = dqueue->get_size();
|
||||||
|
assert(size > 0);
|
||||||
|
|
||||||
|
vvp_vector4_t value;
|
||||||
|
dqueue->get_word(size-1, value);
|
||||||
|
dqueue->pop_back();
|
||||||
|
|
||||||
|
assert(value.size() == wid);
|
||||||
|
thr->bits4.set_vec(bit, value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool of_QPOP_F(vthread_t thr, vvp_code_t cp)
|
||||||
|
{
|
||||||
|
unsigned bit = cp->bit_idx[0];
|
||||||
|
unsigned wid = cp->bit_idx[1];
|
||||||
|
|
||||||
|
vvp_net_t*net = cp->net;
|
||||||
|
vvp_fun_signal_object*obj = dynamic_cast<vvp_fun_signal_object*> (net->fun);
|
||||||
|
assert(obj);
|
||||||
|
|
||||||
|
vvp_queue*dqueue = obj->get_object().peek<vvp_queue>();
|
||||||
|
assert(dqueue);
|
||||||
|
|
||||||
|
size_t size = dqueue->get_size();
|
||||||
|
assert(size > 0);
|
||||||
|
|
||||||
|
vvp_vector4_t value;
|
||||||
|
dqueue->get_word(0, value);
|
||||||
|
dqueue->pop_front();
|
||||||
|
|
||||||
|
assert(value.size() == wid);
|
||||||
|
thr->bits4.set_vec(bit, value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool of_QPOP_B_STR(vthread_t thr, vvp_code_t cp)
|
||||||
|
{
|
||||||
|
vvp_net_t*net = cp->net;
|
||||||
|
vvp_fun_signal_object*obj = dynamic_cast<vvp_fun_signal_object*> (net->fun);
|
||||||
|
assert(obj);
|
||||||
|
|
||||||
|
vvp_queue*dqueue = obj->get_object().peek<vvp_queue>();
|
||||||
|
assert(dqueue);
|
||||||
|
|
||||||
|
size_t size = dqueue->get_size();
|
||||||
|
assert(size > 0);
|
||||||
|
|
||||||
|
string value;
|
||||||
|
dqueue->get_word(size-1, value);
|
||||||
|
dqueue->pop_back();
|
||||||
|
|
||||||
|
thr->push_str(value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool of_QPOP_F_STR(vthread_t thr, vvp_code_t cp)
|
||||||
|
{
|
||||||
|
vvp_net_t*net = cp->net;
|
||||||
|
vvp_fun_signal_object*obj = dynamic_cast<vvp_fun_signal_object*> (net->fun);
|
||||||
|
assert(obj);
|
||||||
|
|
||||||
|
vvp_queue*dqueue = obj->get_object().peek<vvp_queue>();
|
||||||
|
assert(dqueue);
|
||||||
|
|
||||||
|
string value;
|
||||||
|
dqueue->get_word(0, value);
|
||||||
|
dqueue->pop_front();
|
||||||
|
|
||||||
|
thr->push_str(value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These implement the %release/net and %release/reg instructions. The
|
* These implement the %release/net and %release/reg instructions. The
|
||||||
* %release/net instruction applies to a net kind of functor by
|
* %release/net instruction applies to a net kind of functor by
|
||||||
|
|
|
||||||
|
|
@ -231,6 +231,16 @@ void vvp_queue_string::get_word(unsigned adr, string&value)
|
||||||
value = *cur;
|
value = *cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vvp_queue_string::pop_back(void)
|
||||||
|
{
|
||||||
|
array_.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
void vvp_queue_string::pop_front(void)
|
||||||
|
{
|
||||||
|
array_.pop_front();
|
||||||
|
}
|
||||||
|
|
||||||
vvp_queue_vec4::~vvp_queue_vec4()
|
vvp_queue_vec4::~vvp_queue_vec4()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -279,3 +289,13 @@ void vvp_queue_vec4::push_front(const vvp_vector4_t&val)
|
||||||
{
|
{
|
||||||
array_.push_front(val);
|
array_.push_front(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vvp_queue_vec4::pop_back(void)
|
||||||
|
{
|
||||||
|
array_.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
void vvp_queue_vec4::pop_front(void)
|
||||||
|
{
|
||||||
|
array_.pop_front();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,9 @@ class vvp_queue : public vvp_darray {
|
||||||
|
|
||||||
virtual void push_back(const std::string&value);
|
virtual void push_back(const std::string&value);
|
||||||
virtual void push_front(const std::string&value);
|
virtual void push_front(const std::string&value);
|
||||||
|
|
||||||
|
virtual void pop_back(void) =0;
|
||||||
|
virtual void pop_front(void)=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class vvp_queue_vec4 : public vvp_queue {
|
class vvp_queue_vec4 : public vvp_queue {
|
||||||
|
|
@ -113,6 +116,8 @@ class vvp_queue_vec4 : public vvp_queue {
|
||||||
void get_word(unsigned adr, vvp_vector4_t&value);
|
void get_word(unsigned adr, vvp_vector4_t&value);
|
||||||
void push_back(const vvp_vector4_t&value);
|
void push_back(const vvp_vector4_t&value);
|
||||||
void push_front(const vvp_vector4_t&value);
|
void push_front(const vvp_vector4_t&value);
|
||||||
|
void pop_back(void);
|
||||||
|
void pop_front(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::list<vvp_vector4_t> array_;
|
std::list<vvp_vector4_t> array_;
|
||||||
|
|
@ -129,6 +134,8 @@ class vvp_queue_string : public vvp_queue {
|
||||||
void get_word(unsigned adr, std::string&value);
|
void get_word(unsigned adr, std::string&value);
|
||||||
void push_back(const std::string&value);
|
void push_back(const std::string&value);
|
||||||
//void push_front(const std::string&value);
|
//void push_front(const std::string&value);
|
||||||
|
void pop_back(void);
|
||||||
|
void pop_front(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::list<std::string> array_;
|
std::list<std::string> array_;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue