When calling a pop_back() function on an empty queue, the simulation doesnt fail
module GRG_queue1;
typedef struct {
string txt ;
byte unsigned b ;
int array[];
} T;
typedef enum {
HELLO,
UNKNOWN,
RESET,
SET
} wire_state_t;
T q[$];
wire_state_t wire_q[$];
int test_q[$];
wire_state_t map_q[];
initial begin
q.push_back('{"abc", 123, '{4, 5, 6}});
q.push_back('{"def", 156, '{9, 8, 7}});
$display("%p", q);
$display("wire_q: %s", wire_q.pop_back());
$display("wire_q: %s", wire_q.pop_back());
$display("wire_q: %s", wire_q.pop_back());
$display("wire_q: %s", wire_q.pop_back());
$display("wire_q: %s", wire_q.pop_back());
$display("map_q: %s", map_q[0]);
$display("wire_q size: %d", wire_q.size());
$display("test_q: %d", test_q[0]);
end
endmodule
Output:__
wire_q: HELLO
wire_q: HELLO
wire_q: HELLO
wire_q: HELLO
wire_q: HELLO
map_q: HELLO
wire_q size: 0
test_q: 0