Skip to content

Commit

Permalink
Merge pull request #51 from optimsoc/rework_na
Browse files Browse the repository at this point in the history
NoC fix and MP update to latest changes
  • Loading branch information
wallento committed Apr 13, 2017
2 parents 8186096 + a6f8b21 commit 463f409
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 21 deletions.
15 changes: 11 additions & 4 deletions external/lisnoc/rtl/router/lisnoc_router_input_route.v
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,21 @@ module lisnoc_router_input_route (/*AUTOARG*/
endgenerate

// Some bit selections for better readability below
wire [1:0] flit_type;
assign flit_type = fifo_flit[flit_width-1:flit_width-2];

wire [flit_data_width-1:0] flit_header;
assign flit_header = fifo_flit[flit_data_width-1:0];

wire [ph_dest_width-1:0] flit_dest;
assign flit_dest = flit_header[flit_data_width-1:flit_data_width-ph_dest_width];

wire is_last;
assign is_last = fifo_flit[flit_data_width+1];

reg is_first;
wire nxt_is_first;

// Generating the current destination selection
assign nxt_cur_select = ( // If there is no transfer we are waiting for or the active is finished ..
(~active || (active && read)) &&
(~active || (active && read && is_first)) &&
// .. and this is valid..
(fifo_valid)
// .. take selection from the lookup vector
Expand All @@ -129,6 +132,8 @@ module lisnoc_router_input_route (/*AUTOARG*/
// .. the current request is not finished.
(active & ~read);

assign nxt_is_first = active && read && is_last;

// Pop from FIFO when active and successfully routed or not active and something waiting in FIFO.
assign fifo_ready = (active ? read : 1 ) & fifo_valid;

Expand All @@ -143,10 +148,12 @@ module lisnoc_router_input_route (/*AUTOARG*/
active <= 1'b0;
switch_request <= {directions{1'b0}};
cur_select <= {directions{1'b0}};
is_first <= 0;
end else begin
cur_select <= nxt_cur_select;
switch_request <= nxt_switch_request;
active <= nxt_active;
is_first <= nxt_is_first;

// Additionally check whether
if ((active && read) || !active)
Expand Down
27 changes: 14 additions & 13 deletions src/soc/sw/baremetal-libs/src/libmp/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ void control_init() {
optimsoc_mp_simple_addhandler(NOC_CLASS_FIFO, &control_msg_handler);

optimsoc_mp_simple_enable(0);
optimsoc_mp_simple_enable(1);
or1k_interrupts_enable();
}

Expand All @@ -51,7 +52,7 @@ void control_msg_handler(uint32_t* buffer,size_t len) {

// Return the get endpoint response to sender
rbuffer[0] = (src << OPTIMSOC_DEST_LSB) |
(1 << OPTIMSOC_CLASS_LSB) |
(NOC_CLASS_FIFO << OPTIMSOC_CLASS_LSB) |
(optimsoc_get_tileid() << OPTIMSOC_SRC_LSB) |
(CTRL_REQUEST_GETEP_RESP << CTRL_REQUEST_LSB);

Expand All @@ -73,13 +74,13 @@ void control_msg_handler(uint32_t* buffer,size_t len) {
}

trace_ep_get_resp_send(src, (struct endpoint*) rbuffer[1]);
optimsoc_mp_simple_send(0,2,rbuffer);
optimsoc_mp_simple_send(1,2,rbuffer);
break;
}
case CTRL_REQUEST_MSG_ALLOC_REQ:
{
rbuffer[0] = (src << OPTIMSOC_DEST_LSB) |
(1 << OPTIMSOC_CLASS_LSB) |
(NOC_CLASS_FIFO << OPTIMSOC_CLASS_LSB) |
(optimsoc_get_tileid() << OPTIMSOC_SRC_LSB) |
(CTRL_REQUEST_MSG_ALLOC_RESP << CTRL_REQUEST_LSB);

Expand All @@ -94,12 +95,12 @@ void control_msg_handler(uint32_t* buffer,size_t len) {
rbuffer[1] = CTRL_REQUEST_ACK;
rbuffer[2] = ptr;
trace_msg_alloc_resp_send(src, ep, ptr);
optimsoc_mp_simple_send(0,3, rbuffer);
optimsoc_mp_simple_send(1,3, rbuffer);

} else {
rbuffer[1] = CTRL_REQUEST_NACK;
trace_msg_alloc_resp_send(src, ep, -1);
optimsoc_mp_simple_send(0,2,rbuffer);
optimsoc_mp_simple_send(1,2,rbuffer);
}

break;
Expand Down Expand Up @@ -134,12 +135,12 @@ void control_msg_handler(uint32_t* buffer,size_t len) {
ep->remote = (struct endpoint *) buffer[3];

rbuffer[0] = (src << OPTIMSOC_DEST_LSB) |
(1 << OPTIMSOC_CLASS_LSB) |
(NOC_CLASS_FIFO << OPTIMSOC_CLASS_LSB) |
(optimsoc_get_tileid() << OPTIMSOC_SRC_LSB) |
(CTRL_REQUEST_CHAN_CONNECT_RESP << CTRL_REQUEST_LSB);

rbuffer[1] = endpoint_channel_get_credit(ep);
optimsoc_mp_simple_send(0, 2, rbuffer);
optimsoc_mp_simple_send(1, 2, rbuffer);
break;
}
case CTRL_REQUEST_CHAN_DATA:
Expand Down Expand Up @@ -253,7 +254,7 @@ uint32_t control_msg_alloc(struct endpoint_handle *to_ep, uint32_t size) {
// Try to retrieve from remote
// We do this as long as we do not get a valid handle back (-1)
ctrl_request.buffer[0] = (to_ep->domain << OPTIMSOC_DEST_LSB) |
(1 << OPTIMSOC_CLASS_LSB) |
(NOC_CLASS_FIFO << OPTIMSOC_CLASS_LSB) |
(optimsoc_get_tileid() << OPTIMSOC_SRC_LSB) |
(CTRL_REQUEST_MSG_ALLOC_REQ << CTRL_REQUEST_LSB);
ctrl_request.buffer[1] = (unsigned int) to_ep->ep;
Expand Down Expand Up @@ -290,7 +291,7 @@ void control_msg_data(struct endpoint_handle *ep, uint32_t address, void* buffer

for (int i=0;i<words;i=i+wordsperpacket) {
ctrl_request.buffer[0] = (ep->domain << OPTIMSOC_DEST_LSB) |
(1 << OPTIMSOC_CLASS_LSB) |
(NOC_CLASS_FIFO << OPTIMSOC_CLASS_LSB) |
(optimsoc_get_tileid() << OPTIMSOC_SRC_LSB) |
(CTRL_REQUEST_MSG_DATA << CTRL_REQUEST_LSB);
ctrl_request.buffer[1] = (unsigned int) ep->ep;
Expand All @@ -310,7 +311,7 @@ void control_msg_data(struct endpoint_handle *ep, uint32_t address, void* buffer
}

ctrl_request.buffer[0] = (ep->domain << OPTIMSOC_DEST_LSB) |
(1 << OPTIMSOC_CLASS_LSB) |
(NOC_CLASS_FIFO << OPTIMSOC_CLASS_LSB) |
(optimsoc_get_tileid() << OPTIMSOC_SRC_LSB) |
(CTRL_REQUEST_MSG_COMPLETE << CTRL_REQUEST_LSB);
ctrl_request.buffer[1] = (unsigned int) ep->ep;
Expand All @@ -326,7 +327,7 @@ void control_msg_data(struct endpoint_handle *ep, uint32_t address, void* buffer
uint32_t control_channel_connect(struct endpoint_handle *from,
struct endpoint_handle *to) {
ctrl_request.buffer[0] = (to->domain << OPTIMSOC_DEST_LSB) |
(1 << OPTIMSOC_CLASS_LSB) |
(NOC_CLASS_FIFO << OPTIMSOC_CLASS_LSB) |
(optimsoc_get_tileid() << OPTIMSOC_SRC_LSB) |
(CTRL_REQUEST_CHAN_CONNECT_REQ << CTRL_REQUEST_LSB);
ctrl_request.buffer[1] = (unsigned int) to->ep;
Expand All @@ -347,7 +348,7 @@ void control_channel_send(struct endpoint_handle *ep, uint8_t *data, uint32_t si

for (int i=0;i<words;i=i+wordsperpacket) {
ctrl_request.buffer[0] = (ep->domain << OPTIMSOC_DEST_LSB) |
(1 << OPTIMSOC_CLASS_LSB) |
(NOC_CLASS_FIFO << OPTIMSOC_CLASS_LSB) |
(optimsoc_get_tileid() << OPTIMSOC_SRC_LSB) |
(CTRL_REQUEST_CHAN_DATA << CTRL_REQUEST_LSB);
ctrl_request.buffer[1] = (unsigned int) ep->ep;
Expand All @@ -372,7 +373,7 @@ void control_channel_send(struct endpoint_handle *ep, uint8_t *data, uint32_t si

void control_channel_sendcredit(struct endpoint_handle *ep, int32_t credit) {
ctrl_request.buffer[0] = (ep->ep->remotedomain << OPTIMSOC_DEST_LSB) |
(1 << OPTIMSOC_CLASS_LSB) |
(NOC_CLASS_FIFO << OPTIMSOC_CLASS_LSB) |
(optimsoc_get_tileid() << OPTIMSOC_SRC_LSB) |
(CTRL_REQUEST_CHAN_CREDIT << CTRL_REQUEST_LSB);
ctrl_request.buffer[1] = (unsigned int) ep->ep->remote;
Expand Down
8 changes: 4 additions & 4 deletions src/soc/sw/baremetal-libs/src/libmp/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

#include "endpoints.h"

#define NOC_CLASS_FIFO 1
#define NOC_CLASS_DMA_REQ 2
#define NOC_CLASS_DMA_RESP 3
#define NOC_CLASS_MP 4
#define NOC_CLASS_FIFO 0
#define NOC_CLASS_DMA_REQ 1
#define NOC_CLASS_DMA_RESP 2
#define NOC_CLASS_MP 3

// The protocol for the MCAPI message passing uses control
// messages via the NoC.
Expand Down
13 changes: 13 additions & 0 deletions test/systemtest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,16 @@ def baremetal_apps_hello_mpsimple(baremetal_apps):
subprocess.check_output(cmd)

return src_baremetal_apps_hello_mpsimple

@pytest.fixture(scope="module")
def baremetal_apps_hello_mp(baremetal_apps):
"""
Module-scoped fixture: download and build the hello world mp example
from baremetal-apps
"""

src_baremetal_apps_hello_mp = baremetal_apps.join('hello_mp')
cmd = ['make', '-C', str(src_baremetal_apps_hello_mp)]
subprocess.check_output(cmd)

return src_baremetal_apps_hello_mp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# OpTiMSoC trace_monitor stdout file
# [TIME, CORE] MESSAGE
[ 66580, 0] Received from 1
[ 73466, 0] Received from 2
[ 175038, 0] Received from 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# OpTiMSoC trace_monitor stdout file
# [TIME, CORE] MESSAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# OpTiMSoC trace_monitor stdout file
# [TIME, CORE] MESSAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# OpTiMSoC trace_monitor stdout file
# [TIME, CORE] MESSAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# OpTiMSoC trace_monitor stdout file
# [TIME, CORE] MESSAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# OpTiMSoC trace_monitor stdout file
# [TIME, CORE] MESSAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# OpTiMSoC trace_monitor stdout file
# [TIME, CORE] MESSAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# OpTiMSoC trace_monitor stdout file
# [TIME, CORE] MESSAGE
17 changes: 17 additions & 0 deletions test/systemtest/test_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,23 @@ def test_tutorial6_hello_mpsimple(self, tmpdir, baremetal_apps_hello_mpsimple,
assert util.matches_golden_reference(str(tmpdir), f,
filter_func=util.filter_timestamps)

def test_tutorial8_hello_mp(self, baremetal_apps_hello_mp, tmpdir):
"""
Tutorial 8: Run hello_mp world application on 2x2 CCCC in Verilator
Memory loading is done through Verilator meminit.
"""
# run simulation
cmd = ['{}/examples/sim/system_2x2_cccc/system_2x2_cccc_sim_dualcore'.format(os.environ['OPTIMSOC']),
'--meminit={}'.format(str(baremetal_apps_hello_mp.join('hello_mp.vmem')))]
subprocess.check_output(cmd, cwd=str(tmpdir))

# check all output files
for i in range(0, 7):
f = "stdout.{:03d}".format(i)
assert tmpdir.join(f).isfile()
assert util.matches_golden_reference(str(tmpdir), f,
filter_func=util.filter_timestamps)

class TestTutorialFpga:
"""
Test all FPGA-based tutorial steps in the User Guide
Expand Down

0 comments on commit 463f409

Please sign in to comment.