Commit 5c0ef2d1 authored by Dimitris Lampridis's avatar Dimitris Lampridis

sim: rework queue message class to have the message header unpacked for easier reference

parent c03f3b5b
......@@ -157,9 +157,6 @@ class MockTurtleDriver;
csr.notify_queue[core] = {};
endtask // get_cpu_notifications
task handle_hmq_in_irq ();
endtask // handle_hmq_in_irq
task hmq_receive_message (ref MQueueMsg msg);
msg = hmq[msg.core].receive_message (msg.slot);
endtask // hmq_receive_message
......@@ -169,7 +166,6 @@ class MockTurtleDriver;
endtask // hmq_send_message
task hmq_purge (int core, int slot);
hmq[core].purge (slot);
endtask // hmq_purge
......
......@@ -129,16 +129,20 @@ class MQueueHost;
MQueueMsg msg;
u32_queue hdr;
csr.hmq_select ( core, slot );
msg = slots_out[slot].pop_back();
hdr = msg.hdr_pack ();
outgoing_write (`MQUEUE_SLOT_COMMAND, `MQUEUE_CMD_CLAIM);
for (int i = 0; i < msg.header.size(); i++)
for (int i = 0; i < hdr.size(); i++)
begin
outgoing_write (`MQUEUE_SLOT_HEADER + i * 4, msg.header[i]);
outgoing_write (`MQUEUE_SLOT_HEADER + i * 4, hdr[i]);
end
for (int i = 0; i < msg.data.size(); i++)
for (int i = 0; i < msg.header.len; i++)
begin
outgoing_write (`MQUEUE_SLOT_DATA + i * 4, msg.data[i]);
end
......@@ -152,18 +156,23 @@ class MQueueHost;
uint32_t val;
uint32_t hdr[$];
csr.hmq_select ( core, slot );
msg = new (core, slot);
msg = new ( core, slot );
hdr = {};
incoming_read (`MQUEUE_SLOT_HEADER + 0, val );
msg.header[0] = val;
hdr[0] = val;
incoming_read (`MQUEUE_SLOT_HEADER + 4, val );
msg.header[1] = val;
hdr[1] = val;
incoming_read (`MQUEUE_SLOT_HEADER + 8, val );
msg.header[2] = val;
hdr[2] = val;
msg.set_header ( hdr );
for (int i = 0; i < msg.header[1] & 32'h0000ffff; i++)
for (int i = 0; i < msg.header.len; i++)
begin
incoming_read (`MQUEUE_SLOT_DATA + 4*i, val);
msg.data.push_back(val);
......
......@@ -26,40 +26,78 @@
`ifndef __MT_MQUEUE_MSG_INCLUDED
`define __MT_MQUEUE_MSG_INCLUDED
typedef uint32_t u32_queue[$];
typedef struct {
uint32_t app_id;
uint32_t flags;
uint32_t msg_id;
uint32_t len;
uint32_t sync_id;
uint32_t seq;
} mqueue_msg_header;
class MQueueMsg;
int core;
int slot;
uint32_t header[$];
uint32_t data[$];
mqueue_msg_header header;
u32_queue data;
function new (int core = 0, int slot = 0);
function new ( int core = 0, int slot = 0,
u32_queue header = {},
u32_queue data = {});
this.core = core;
this.slot = slot;
this.header = {};
this.data = {};
if ( header.size() )
this.header = hdr_unpack ( header );
else
this.header = '{0, 0, 0, 0, 0, 0};
this.data = data;
endfunction // new
function mqueue_msg_header hdr_unpack (u32_queue header );
mqueue_msg_header hdr;
if ( header.size() > 2 )
begin
hdr.app_id = header[0] & 32'h0000ffff;
hdr.flags = (header[0] & 32'h00ff0000) >> 16;
hdr.msg_id = (header[0] & 32'hff000000) >> 24;
hdr.len = header[1] & 32'h0000ffff;
hdr.sync_id = (header[1] & 32'hffff0000) >> 16;
hdr.seq = header[2];
end
else
hdr = '{0, 0, 0, 0, 0, 0};
if ( header.size() != 3 )
$warning ( "incorrect message header size %0d", header.size() );
return hdr;
endfunction // hdr_unpack
task set_header ( u32_queue header );
this.header = hdr_unpack ( header );
endtask // set_header
function u32_queue hdr_pack ( );
u32_queue hdr;
hdr[0] = header.app_id & 'hffff;
hdr[0] |= (header.flags & 'hff) << 16;
hdr[0] |= (header.msg_id & 'hff) << 24;
hdr[1] = header.len & 'hffff;
hdr[1] |= (header.sync_id & 'hffff) << 16;
hdr[2] = header.seq;
return hdr;
endfunction // hdr_pack
function string tostring ();
uint32_t app_id;
uint32_t flags;
uint32_t msg_id;
uint32_t len;
uint32_t sync_id;
uint32_t seq;
string hdr, dat;
app_id = this.header[0] & 32'h0000ffff;
flags = (this.header[0] & 32'h00ff0000) >> 16;
msg_id = (this.header[0] & 32'hff000000) >> 24;
len = this.header[1] & 32'h0000ffff;
sync_id = (this.header[1] & 32'hffff0000) >> 16;
seq = this.header[2];
hdr = $sformatf ("APP_ID: 0x%4x, MSG_ID: 0x%2x, FLAGS: 0x%2x, LEN: %0d, SYNC_ID: 0x%4x, SEQ: %0d",
app_id, msg_id, flags, len, sync_id, seq);
hdr = $sformatf ( {"CPU%0d, SLOT%0d, APP_ID: 0x%4x, MSG_ID: 0x%2x, ",
"FLAGS: 0x%2x, LEN: %0d, SYNC_ID: 0x%4x, SEQ: %0d" },
core, slot, header.app_id, header.msg_id, header.flags,
header.len, header.sync_id, header.seq);
dat = " PAYLOAD:";
for (int i = 0; i < len; i++) begin
for (int i = 0; i < header.len; i++) begin
dat = {dat, $sformatf(" 0x%8x", this.data[i])};
end
......
......@@ -104,10 +104,8 @@ module main;
inc_counter();
ntf.delete(0);
msg = new (0, 0);
msg.header[0] = 0;
msg.header[1] = 1;
msg.header[2] = 0;
msg.data[0] = 0;
msg.header.len = 1;
msg.data[0] = 0;
drv.hmq_send_message (msg);
end
endtask // check_cpu_notifications
......@@ -156,6 +154,8 @@ module main;
initial begin
$timeformat (-6, 3, "us", 10);
#10us;
drv = new (Host.get_accessor(), mt_base, IrqMonitor);
......
......@@ -158,6 +158,8 @@ module main;
automatic WBPacketSink sink = new(U_wrf_sink.get_accessor());
automatic WBPacketSource src = new(U_wrf_source.get_accessor());
$timeformat (-6, 3, "us", 10);
#10us;
drv = new (Host.get_accessor(), mt_base, IrqMonitor);
......
......@@ -86,6 +86,8 @@ module main;
initial begin
$timeformat (-6, 3, "us", 10);
@(posedge DUT.rst_sys_n);
@(posedge DUT.clk_sys);
......
......@@ -98,6 +98,8 @@ module main;
initial begin
$timeformat (-6, 3, "us", 10);
@(posedge DUT.rst_n_sys);
@(posedge DUT.clk_sys);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment