[dv/tlul] Clean up tlul TB

1. use new makefile structure
2. use new core files structure
3. fix tb-dut connections
4. update scb for new DUT
diff --git a/hw/dv/sv/scoreboard/scoreboard.sv b/hw/dv/sv/scoreboard/scoreboard.sv
index e93fa42..4eb0b3c 100644
--- a/hw/dv/sv/scoreboard/scoreboard.sv
+++ b/hw/dv/sv/scoreboard/scoreboard.sv
@@ -44,7 +44,7 @@
     if (!uvm_config_db#(virtual clk_if)::get(this, "", "clk_if", clk_vif)) begin
       `uvm_fatal(get_full_name(), "Cannot get clk interface")
     end
-    if(enable_logging) begin
+    if (enable_logging) begin
       log_filename = {get_full_name(), ".log"};
       `uvm_info(get_full_name(), $sformatf(
                 "Trasnaction logging enabled, log will be saved to %0s", log_filename), UVM_LOW)
@@ -56,7 +56,7 @@
   endfunction
 
   virtual function void add_item_port(string port_name, port_dir_e direction);
-    if(item_fifos.exists(port_name)) begin
+    if (item_fifos.exists(port_name)) begin
       `uvm_error(get_full_name(), $sformatf(
                  "Port %0s already exists, cannot be added again", port_name))
     end
@@ -68,7 +68,7 @@
 
   virtual function void add_item_queue(string queue_name,
                                        checking_policy_e policy = kInOrderCheck);
-    if(item_queues.exists(queue_name)) begin
+    if (item_queues.exists(queue_name)) begin
       `uvm_fatal(get_full_name(), $sformatf(
                  "Queue %0s already exists, cannot be added again", queue_name))
     end
@@ -81,7 +81,7 @@
 
   task run_phase(uvm_phase phase);
     run_phase_h = phase;
-    if(disable_scoreboard) return;
+    if (disable_scoreboard) return;
     fork
       timeout_monitor();
       ref_timer_thread();
@@ -105,15 +105,15 @@
       last_activity_cycle = ref_timer;
       `uvm_info(get_full_name(), $sformatf("Got an item from port %0s:\n%0s",
                 port_name, tr.sprint()), UVM_HIGH)
-      if(port_dir[port_name] == kSrcPort) begin
+      if (port_dir[port_name] == kSrcPort) begin
         process_src_packet(tr, port_name, transformed_tr);
         foreach(transformed_tr[i]) begin
           queue_name = get_queue_name(transformed_tr[i], port_name);
           // destination ports
-          if(!item_queues.exists(queue_name)) begin
+          if (!item_queues.exists(queue_name)) begin
              `uvm_fatal(get_full_name(), $sformatf("%0s queue doesn't exist", queue_name))
           end
-          if(enable_logging) begin
+          if (enable_logging) begin
             $fwrite(log_fd, $sformatf("EXP @%0t [%0s][%0s] %0s\n", $realtime, port_name,
                                      queue_name, transformed_tr[i].convert2string()));
           end
@@ -127,11 +127,12 @@
         SEQ_ITEM tr_modified;
         queue_name = get_queue_name(tr, port_name);
         // destination ports
-        if(!item_queues.exists(queue_name)) begin
+        if (!item_queues.exists(queue_name)) begin
            `uvm_fatal(get_full_name(), $sformatf("%0s queue doesn't exist", queue_name))
         end
         process_dst_packet(tr, port_name, tr_modified);
-        if(enable_logging) begin
+        #0; // avoid race condition when item is received in both queue in same cycle
+        if (enable_logging) begin
           $fwrite(log_fd, $sformatf("ACT @%0t [%0s][%0s] %0s\n", $realtime, port_name,
                                      queue_name, tr_modified.convert2string()));
         end
@@ -145,11 +146,11 @@
   endtask
 
   function void handle_objection();
-    if((num_of_act_item != num_of_exp_item) && !objection_raised) begin
+    if ((num_of_act_item != num_of_exp_item) && !objection_raised) begin
       run_phase_h.raise_objection(this);
       objection_raised = 1'b1;
     end
-    if((num_of_act_item == num_of_exp_item) && objection_raised) begin
+    if ((num_of_act_item == num_of_exp_item) && objection_raised) begin
       run_phase_h.drop_objection(this);
       objection_raised = 1'b0;
     end
@@ -157,7 +158,7 @@
 
   function void report_phase(uvm_phase phase);
     super.report_phase(phase);
-    if((num_of_act_item != num_of_exp_item) && !allow_packet_drop) begin
+    if ((num_of_act_item != num_of_exp_item) && !allow_packet_drop) begin
       `uvm_error(get_full_name(), $sformatf("Expected item cnt %0d != actual item cnt %0d",
                  num_of_exp_item, num_of_act_item))
       foreach(item_queues[queue_name]) begin
@@ -197,16 +198,16 @@
 
   // Scoreboard timeout detection
   virtual task timeout_monitor;
-    if(timeout_cycle_limit > 0) begin
+    if (timeout_cycle_limit > 0) begin
       while(1) begin
         repeat(timeout_check_cycle_interval) @(posedge clk_vif.clk);
-        if((ref_timer - last_activity_cycle > timeout_cycle_limit) &&
+        if ((ref_timer - last_activity_cycle > timeout_cycle_limit) &&
            (num_of_act_item != num_of_exp_item)) begin
-          if(!allow_packet_drop) begin
+          if (!allow_packet_drop) begin
             `uvm_error(get_full_name(), $sformatf("Scoreboard timeout, act/exp items = %0d/%0d",
                                        num_of_act_item, num_of_exp_item))
             foreach(item_queues[q]) begin
-              if(item_queues[q].expected_items.size() > 0) begin
+              if (item_queues[q].expected_items.size() > 0) begin
                 `uvm_info(get_full_name(), $sformatf("Queue[%0s] pending item[0]:%0s", q,
                           item_queues[q].expected_items[0].convert2string()), UVM_LOW)
               end
@@ -215,7 +216,7 @@
             `uvm_info(get_full_name(), $sformatf(
                       "Scoreboard timeout caused by packet drop, act/exp items = %0d/%0d",
                       num_of_act_item, num_of_exp_item), UVM_LOW)
-            if(objection_raised) begin
+            if (objection_raised) begin
               run_phase_h.drop_objection(this);
               objection_raised = 1'b0;
             end
diff --git a/hw/dv/sv/scoreboard/scoreboard_queue.sv b/hw/dv/sv/scoreboard/scoreboard_queue.sv
index 64366c8..454cfa0 100644
--- a/hw/dv/sv/scoreboard/scoreboard_queue.sv
+++ b/hw/dv/sv/scoreboard/scoreboard_queue.sv
@@ -31,34 +31,34 @@
 
   task add_expected_item(SEQ_ITEM tr, bit [63:0] current_cycle_cnt);
     token.get(1);
-    if(max_pending_items > 0) begin
-      if(expected_items.size() > max_pending_items) begin
+    if (max_pending_items > 0) begin
+      if (expected_items.size() > max_pending_items) begin
         `uvm_error(get_full_name(), $sformatf("Number of expected items %0d exceeds limit %0d",
                          expected_items.size(), max_pending_items))
       end
     end
     expected_items.push_back(tr);
     expected_items_timestamp.push_back(current_cycle_cnt);
-    if(actual_items.size() != 0) check_item();
+    if (actual_items.size() != 0) check_item();
     token.put(1);
   endtask
 
   task add_actual_item(SEQ_ITEM tr, bit [63:0] current_cycle_cnt);
     token.get(1);
-    if(max_pending_items > 0) begin
-      if(actual_items.size() > max_pending_items) begin
+    if (max_pending_items > 0) begin
+      if (actual_items.size() > max_pending_items) begin
         `uvm_error(get_full_name(), $sformatf("Number of actected items %0d exceeds limit %0d",
                          actual_items.size(), max_pending_items))
       end
     end
     actual_items.push_back(tr);
     actual_items_timestamp.push_back(current_cycle_cnt);
-    if(expected_items.size() != 0) check_item();
+    if (expected_items.size() != 0) check_item();
     token.put(1);
   endtask
 
   virtual function bit check_item();
-    if(expected_items.size() == 0 || actual_items.size() == 0) begin
+    if (expected_items.size() == 0 || actual_items.size() == 0) begin
       `uvm_error(get_full_name(), $sformatf(
         "Cannot check with empty queue, expected items: %0d, actual items: %0d",
         expected_items.size(),  actual_items.size()))
@@ -68,7 +68,7 @@
       // In order check : compare the first item in the expected and actual item queue
       kInOrderCheck: begin
         bit check_pass;
-        if(actual_items[0].compare(expected_items[0])) begin
+        if (actual_items[0].compare(expected_items[0])) begin
           `uvm_info(get_full_name(), $sformatf(
                     "IN ORDER CHECK PASS:\n Expected item:\n%0s Actual item:\n%0s",
                     expected_items[0].sprint(), actual_items[0].sprint()), UVM_HIGH)
@@ -91,7 +91,7 @@
       // the first actual item
       kOutOfOrderCheck: begin
         foreach(expected_items[i]) begin
-          if(actual_items[0].compare(expected_items[i], out_of_order_comparator)) begin
+          if (actual_items[0].compare(expected_items[i], out_of_order_comparator)) begin
             `uvm_info(get_full_name(),
                 $sformatf("OUT OF ORDER CHECK PASS:\n Expected item[%0d]:\n%0s Actual item:\n%0s",
                 i, expected_items[i].sprint(), actual_items[0].sprint()), UVM_HIGH)
diff --git a/hw/dv/sv/spi_agent/spi_monitor.sv b/hw/dv/sv/spi_agent/spi_monitor.sv
index e8a1ea2..53458f4 100755
--- a/hw/dv/sv/spi_agent/spi_monitor.sv
+++ b/hw/dv/sv/spi_agent/spi_monitor.sv
@@ -79,8 +79,10 @@
             // sending transactions when collect a word data
             if (host_item.data.size == cfg.num_bytes_per_trans_in_mon &&
                 device_item.data.size == cfg.num_bytes_per_trans_in_mon) begin
-              `uvm_info(`gfn, $sformatf("spi_monitor: host packet:\n%0s", host_item.sprint()), UVM_HIGH)
-              `uvm_info(`gfn, $sformatf("spi_monitor: device packet:\n%0s", device_item.sprint()), UVM_HIGH)
+              `uvm_info(`gfn, $sformatf("spi_monitor: host packet:\n%0s", host_item.sprint()),
+                        UVM_HIGH)
+              `uvm_info(`gfn, $sformatf("spi_monitor: device packet:\n%0s", device_item.sprint()),
+                        UVM_HIGH)
               host_analysis_port.write(host_item);
               device_analysis_port.write(device_item);
               host_item   = spi_item::type_id::create("host_item", this);
diff --git a/hw/dv/sv/tl_agent/tl_if_connect_macros.svh b/hw/dv/sv/tl_agent/tl_if_connect_macros.svh
index 10ce6a3..0d249d4 100644
--- a/hw/dv/sv/tl_agent/tl_if_connect_macros.svh
+++ b/hw/dv/sv/tl_agent/tl_if_connect_macros.svh
@@ -11,7 +11,8 @@
    initial begin \
      force intf_inst.h2d = dut_h2d; \
      force dut_d2h = intf_inst.d2h; \
-     uvm_config_db#(virtual tl_if)::set(null,  "*``intf_name``*", "vif", intf_inst); \
+     uvm_config_db#(virtual tl_if)::set(null, $sformatf("*%0s*", `"intf_name`"), "vif", \
+                                        intf_inst); \
    end
 
 `define CONNECT_TL_HOST_IF(intf_inst, dut_h2d, dut_d2h, intf_name) \
@@ -19,7 +20,8 @@
    initial begin \
      force intf_inst.d2h = dut_d2h; \
      force dut_h2d = intf_inst.h2d; \
-     uvm_config_db#(virtual tl_if)::set(null,  "*``intf_name``*", "vif", intf_inst); \
+     uvm_config_db#(virtual tl_if)::set(null, $sformatf("*%0s*", `"intf_name`"), "vif", \
+                                        intf_inst); \
    end
 
 `define CONNECT_TL_MON_IF(intf_inst, dut_h2d, dut_d2h, intf_name) \
@@ -27,5 +29,6 @@
    initial begin \
      force intf_inst.h2d = dut_h2d; \
      force intf_inst.d2h = dut_d2h; \
-     uvm_config_db#(virtual tl_if)::set(null,  "*``intf_name``*", "vif", intf_inst); \
+     uvm_config_db#(virtual tl_if)::set(null, $sformatf("*%0s*", `"intf_name`"), "vif", \
+                                        intf_inst); \
    end
diff --git a/hw/dv/sv/tl_agent/tl_monitor.sv b/hw/dv/sv/tl_agent/tl_monitor.sv
index 6fb68e6..84e67a6 100644
--- a/hw/dv/sv/tl_agent/tl_monitor.sv
+++ b/hw/dv/sv/tl_agent/tl_monitor.sv
@@ -31,7 +31,7 @@
     super.build_phase(phase);
     d_chan_port = new("d_chan_port", this);
     a_chan_port = new("a_chan_port", this);
-    if(!uvm_config_db#(virtual tl_if)::get(this,"","vif",vif)) begin
+    if (!uvm_config_db#(virtual tl_if)::get(this,"","vif",vif)) begin
       `uvm_fatal("NO_VIF", {"virtual interface must be set for:",
                  get_full_name(),".vif"});
     end
diff --git a/hw/dv/sv/tl_agent/tl_seq_item.sv b/hw/dv/sv/tl_agent/tl_seq_item.sv
index b33468d..90489da 100644
--- a/hw/dv/sv/tl_agent/tl_seq_item.sv
+++ b/hw/dv/sv/tl_agent/tl_seq_item.sv
@@ -49,7 +49,7 @@
   constraint mask_c {
     if (a_opcode == PutFullData) {
       foreach(a_mask[i]) {
-        if((i > 0) && (i < MaskWidth - 1)) {
+        if ((i > 0) && (i < MaskWidth - 1)) {
           !a_mask[i] -> !(a_mask[i-1] && a_mask[i+1]);
         }
       }
diff --git a/hw/ip/tlul/dv/tests.mk b/hw/ip/tlul/dv/Makefile
similarity index 98%
rename from hw/ip/tlul/dv/tests.mk
rename to hw/ip/tlul/dv/Makefile
index 8310caa..2c72cbe 100644
--- a/hw/ip/tlul/dv/tests.mk
+++ b/hw/ip/tlul/dv/Makefile
@@ -14,7 +14,7 @@
 ## TEST_NAME    - name of the test to run - this is supplied on the command line                  ##
 ####################################################################################################
 DV_DIR          := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
-export DUT_TOP  := tlul_xbar
+export DUT_TOP  := xbar_main
 export TB_TOP   := tb
 FUSESOC_CORE    := lowrisc:ip:xbar_dv:0.1
 COMPILE_KEY     ?= default
diff --git a/hw/ip/tlul/dv/tests/xbar_seq_lib.sv b/hw/ip/tlul/dv/env/seq_lib/xbar_seq_lib.sv
similarity index 89%
rename from hw/ip/tlul/dv/tests/xbar_seq_lib.sv
rename to hw/ip/tlul/dv/env/seq_lib/xbar_seq_lib.sv
index c4f26ab..5cea34f 100644
--- a/hw/ip/tlul/dv/tests/xbar_seq_lib.sv
+++ b/hw/ip/tlul/dv/env/seq_lib/xbar_seq_lib.sv
@@ -29,8 +29,7 @@
     end
     if (!(req.randomize() with {a_valid_delay inside {[min_req_delay:max_req_delay]};
                                 // Keep msb to zero as it's reserved to add host ID
-                                a_source[(Source_width - 1)-:Valid_host_id_lsb] == 0;
-                                a_source inside {[0:xbar_hosts.size()-1]};
+                                a_source[(SourceWidth - 1):VALID_HOST_ID_WIDTH] == 0;
                                 if (!access_unclaimed_addr) {
                                   a_addr inside {[xbar_devices[device_id].start_address :
                                                   xbar_devices[device_id].end_address]};
diff --git a/hw/ip/tlul/dv/env/seq_lib/xbar_vseq.list.sv b/hw/ip/tlul/dv/env/seq_lib/xbar_vseq.list.sv
new file mode 100644
index 0000000..0457963
--- /dev/null
+++ b/hw/ip/tlul/dv/env/seq_lib/xbar_vseq.list.sv
@@ -0,0 +1,6 @@
+// Copyright lowRISC contributors.
+// Licensed under the Apache License, Version 2.0, see LICENSE for details.
+// SPDX-License-Identifier: Apache-2.0
+
+`include "xbar_seq_lib.sv"
+`include "xbar_vseq.sv"
diff --git a/hw/ip/tlul/dv/tests/xbar_vseq.sv b/hw/ip/tlul/dv/env/seq_lib/xbar_vseq.sv
similarity index 100%
rename from hw/ip/tlul/dv/tests/xbar_vseq.sv
rename to hw/ip/tlul/dv/env/seq_lib/xbar_vseq.sv
diff --git a/hw/ip/tlul/dv/env/xbar_env.core b/hw/ip/tlul/dv/env/xbar_env.core
new file mode 100644
index 0000000..ac01ece
--- /dev/null
+++ b/hw/ip/tlul/dv/env/xbar_env.core
@@ -0,0 +1,24 @@
+CAPI=2:
+# Copyright lowRISC contributors.
+# Licensed under the Apache License, Version 2.0, see LICENSE for details.
+# SPDX-License-Identifier: Apache-2.0
+name: "lowrisc:dv:xbar_env:0.1"
+description: "xbar DV UVM environmnt"
+filesets:
+  files_dv:
+    depend:
+      - lowrisc:dv:cip_lib
+      - lowrisc:ip:xbar:0.1
+    files:
+      - xbar_env_pkg.sv
+      - xbar_env_cfg.sv: {is_include_file: true}
+      - xbar_vseqr.sv: {is_include_file: true}
+      - xbar_env.sv: {is_include_file: true}
+      - xbar_scoreboard.sv: {is_include_file: true}
+      - seq_lib/xbar_vseq_list.sv: {is_include_file: true}
+    file_type: systemVerilogSource
+
+targets:
+  default:
+    filesets:
+      - files_dv
diff --git a/hw/ip/tlul/dv/env/xbar_env.sv b/hw/ip/tlul/dv/env/xbar_env.sv
index 4aa3950..8b32e41 100644
--- a/hw/ip/tlul/dv/env/xbar_env.sv
+++ b/hw/ip/tlul/dv/env/xbar_env.sv
@@ -53,13 +53,12 @@
     foreach (xbar_devices[i]) begin
       scb.add_item_port({"a_chan_", xbar_devices[i].device_name}, scoreboard_pkg::kDstPort);
       scb.add_item_port({"d_chan_", xbar_devices[i].device_name}, scoreboard_pkg::kSrcPort);
+
+      scb.add_item_queue({"a_chan_", xbar_devices[i].device_name},
+                         scoreboard_pkg::kOutOfOrderCheck);
     end
-    foreach (xbar_hosts[i]) begin
-      foreach (xbar_devices[j]) begin
-        scb.add_item_queue({"a_chan_", xbar_hosts[i].host_name, "_", xbar_devices[j].device_name});
-        scb.add_item_queue({"d_chan_", xbar_devices[j].device_name, "_", xbar_hosts[i].host_name});
-      end
-    end
+    // all the d_channals share one queue as we can't know which host to return from device side
+    scb.add_item_queue(D_CHAN_QUEUE_NAME, scoreboard_pkg::kOutOfOrderCheck);
   endfunction : create_scoreboard
 
   function void connect_phase(uvm_phase phase);
diff --git a/hw/ip/tlul/dv/env/xbar_env_pkg.sv b/hw/ip/tlul/dv/env/xbar_env_pkg.sv
index bd73b8e..5b26075 100644
--- a/hw/ip/tlul/dv/env/xbar_env_pkg.sv
+++ b/hw/ip/tlul/dv/env/xbar_env_pkg.sv
@@ -9,6 +9,7 @@
 
   import uvm_pkg::*;
   import tl_agent_pkg::*;
+  import tl_main_pkg::*;
 
   typedef struct {
     string                      device_name;
@@ -24,6 +25,8 @@
 
   `include "xbar_params.svh"
 
+  parameter string D_CHAN_QUEUE_NAME   = "D_CHAN_COMMON_QUEUE";
+
   function automatic int get_host_id(string name);
     foreach (xbar_hosts[i]) begin
       if (xbar_hosts[i].host_name == name) return i;
diff --git a/hw/ip/tlul/dv/env/xbar_params.svh b/hw/ip/tlul/dv/env/xbar_params.svh
index 85b41d6..e1eec35 100644
--- a/hw/ip/tlul/dv/env/xbar_params.svh
+++ b/hw/ip/tlul/dv/env/xbar_params.svh
@@ -4,14 +4,26 @@
 //
 
 // Num of valid host source id bits, the upper bits should be tied to zero
-parameter int Valid_host_id_lsb  = 2;
+parameter int VALID_HOST_ID_WIDTH = 6;
 
 // List of Xbar device memory map
-tl_device_t xbar_devices[$] = '{'{"TlSram", 'h1000_0000, 'h1000_ffff},
-                                '{"TlUart", 'h4000_0000, 'h4000_ffff},
-                                '{"TlGpio", 'h4001_0000, 'h4001_ffff}};
+tl_device_t xbar_devices[$] = '{
+    '{"TlRom",       ADDR_SPACE_ROM       , ADDR_SPACE_ROM        | ADDR_MASK_ROM       },
+    '{"TlDebugMem",  ADDR_SPACE_DEBUG_MEM , ADDR_SPACE_DEBUG_MEM  | ADDR_MASK_DEBUG_MEM },
+    '{"TlRamMain",   ADDR_SPACE_RAM_MAIN  , ADDR_SPACE_RAM_MAIN   | ADDR_MASK_RAM_MAIN  },
+    '{"TlEflash",    ADDR_SPACE_EFLASH    , ADDR_SPACE_EFLASH     | ADDR_MASK_EFLASH    },
+    '{"TlUart",      ADDR_SPACE_UART      , ADDR_SPACE_UART       | ADDR_MASK_UART      },
+    '{"TlGpio",      ADDR_SPACE_GPIO      , ADDR_SPACE_GPIO       | ADDR_MASK_GPIO      },
+    '{"TlSpiDevice", ADDR_SPACE_SPI_DEVICE, ADDR_SPACE_SPI_DEVICE | ADDR_MASK_SPI_DEVICE},
+    '{"TlFlashCtrl", ADDR_SPACE_FLASH_CTRL, ADDR_SPACE_FLASH_CTRL | ADDR_MASK_FLASH_CTRL},
+    '{"TlRvTimer",   ADDR_SPACE_RV_TIMER  , ADDR_SPACE_RV_TIMER   | ADDR_MASK_RV_TIMER  },
+    '{"TlHmac",      ADDR_SPACE_HMAC      , ADDR_SPACE_HMAC       | ADDR_MASK_HMAC      },
+    '{"TlRvPlic",    ADDR_SPACE_RV_PLIC   , ADDR_SPACE_RV_PLIC    | ADDR_MASK_RV_PLIC   }};
 
 // List of Xbar hosts
-tl_host_t xbar_hosts[$] = '{'{"TlCoreI", 0, '{"TlSram"}},
-                            '{"TlCoreD", 1, '{"TlSram", "TlUart", "TlGpio"}},
-                            '{"TlDebugSba", 2, '{"TlSram"}}};
+tl_host_t xbar_hosts[$] = '{
+    '{"TlCorei", 0, '{"TlRom", "TlDebugMem", "TlRamMain", "TlEflash"}},
+    '{"TlCored", 1, '{"TlRom", "TlDebugMem", "TlRamMain", "TlEflash", "TlUart", "TlGpio",
+                      "TlFlashCtrl", "TlRvTimer", "TlRvPlic"}},
+    '{"TlDmSba", 2, '{"TlRom", "TlRamMain", "TlEflash", "TlUart", "TlGpio",
+                      "TlFlashCtrl", "TlRvTimer", "TlRvPlic"}}};
diff --git a/hw/ip/tlul/dv/env/xbar_scoreboard.sv b/hw/ip/tlul/dv/env/xbar_scoreboard.sv
index 8d1867d..1d4eb8b 100644
--- a/hw/ip/tlul/dv/env/xbar_scoreboard.sv
+++ b/hw/ip/tlul/dv/env/xbar_scoreboard.sv
@@ -22,22 +22,23 @@
     string queue_name;
     string tl_channel;
     string tl_port;
-    string pair_port_name;
     tl_channel = port_name.substr(0, chan_prefix_len-1);
+    if (tl_channel == "d_chan_") return D_CHAN_QUEUE_NAME;
+
     tl_port = port_name.substr(chan_prefix_len, port_name.len()-1);
-    pair_port_name = get_pair_port_name(tr, tl_port);
     if (!port_dir.exists(port_name)) begin
       `uvm_fatal(get_full_name(), $sformatf("Unexpected port name %0s", tl_port))
     end else if (port_dir[port_name] == scoreboard_pkg::kSrcPort) begin
-      queue_name = {tl_channel, tl_port, "_", pair_port_name};
+      queue_name = {tl_channel, get_pair_dst_port_name(tr, tl_port)};
     end else begin
-      queue_name = {tl_channel, pair_port_name, "_", tl_port};
+      queue_name = {tl_channel, tl_port};
     end
     `uvm_info(get_full_name(), $sformatf("Scoreboard queue name : %0s", queue_name), UVM_HIGH)
     return queue_name;
   endfunction
 
-  virtual function string get_pair_port_name(tl_seq_item tr, string port_name);
+  // when port_name is src, need to find the pair dst port_name
+  virtual function string get_pair_dst_port_name(tl_seq_item tr, string port_name);
     foreach (xbar_hosts[i]) begin
       if (xbar_hosts[i].host_name == port_name) begin
         // Current port is a host port, get pair device port from the address
@@ -47,48 +48,30 @@
         end
       end
     end
-    foreach (xbar_devices[i]) begin
-      if (xbar_devices[i].device_name == port_name) begin
-        // Current port is a device port, get pair host port from the source ID msb
-        int host_id = tr.a_source[Valid_host_id_lsb-1:0];
-        if (host_id >= xbar_hosts.size()) begin
-          `uvm_error(get_full_name(), $sformatf("Out of range host id : %0d", host_id))
-        end else begin
-          return xbar_hosts[host_id].host_name;
-        end
-      end
-    end
     // TODO(taliu) Determine how to handle unclaimed access
     `uvm_error(get_full_name(), $sformatf("Found unclaimed access[%0s]: %0s",
                                 port_name, tr.convert2string()))
   endfunction
 
-  // Adding host_id to the source ID to match the device side source ID
+  // from host to device, source ID may be changed and set all source ID to 0
+  function tl_seq_item modify_source_id(tl_seq_item tr);
+    tl_seq_item tr_modified;
+    `downcast(tr_modified, tr.clone());
+    tr_modified.a_source = 0;
+    tr_modified.d_source = 0;
+    return tr_modified;
+  endfunction
+
   virtual function void process_src_packet(input tl_seq_item  tr,
                                            input string port_name,
                                            output tl_seq_item transformed_tr[$]);
-    int host_id = get_host_id(get_tl_port(port_name));
-    if (host_id >= 0) begin
-      tl_seq_item tr_modified;
-      $cast(tr_modified, tr.clone());
-      tr_modified.a_source = (tr_modified.a_source << Valid_host_id_lsb) | host_id;
-      transformed_tr = {tr_modified};
-    end else begin
-      transformed_tr = {tr};
-    end
+    transformed_tr = {modify_source_id(tr)};
   endfunction
 
   virtual function void process_dst_packet(input tl_seq_item tr,
                                            input string port_name,
                                            output tl_seq_item transformed_tr);
-    int host_id = get_host_id(get_tl_port(port_name));
-    if (host_id >= 0) begin
-      $cast(transformed_tr, tr.clone());
-      transformed_tr.a_source = (transformed_tr.a_source << Valid_host_id_lsb) | host_id;
-      transformed_tr.d_source = (transformed_tr.d_source << Valid_host_id_lsb) | host_id;
-    end else begin
-      transformed_tr = tr;
-    end
+    transformed_tr = modify_source_id(tr);
   endfunction
 
   function string get_tl_port(string port_name);
diff --git a/hw/ip/tlul/dv/tb/tb.sv b/hw/ip/tlul/dv/tb/tb.sv
index d8dd686..fa29ccf 100644
--- a/hw/ip/tlul/dv/tb/tb.sv
+++ b/hw/ip/tlul/dv/tb/tb.sv
@@ -5,13 +5,15 @@
 module tb;
 
   import uvm_pkg::*;
+  import xbar_test_pkg::*;
+
 
   logic clk;
   logic rst_n;
 
-  tlul_xbar dut(
-    .clk_i(clk),
-    .rst_ni(rst_n)
+  xbar_main dut(
+    .clk_main_i(clk),
+    .rst_main_ni(rst_n)
   );
 
   `include "tl_if_connect_macros.svh"
diff --git a/hw/ip/tlul/dv/tb/xbar_main_bind.sv b/hw/ip/tlul/dv/tb/xbar_main_bind.sv
new file mode 100644
index 0000000..eb8a7c4
--- /dev/null
+++ b/hw/ip/tlul/dv/tb/xbar_main_bind.sv
@@ -0,0 +1,9 @@
+// Copyright lowRISC contributors.
+// Licensed under the Apache License, Version 2.0, see LICENSE for details.
+// SPDX-License-Identifier: Apache-2.0
+
+module xbar_main_bind;
+
+  // TODO bind tlul_assert to all interfaces
+
+endmodule
diff --git a/hw/ip/tlul/dv/tb/xbar_tl_if_connection.sv b/hw/ip/tlul/dv/tb/xbar_tl_if_connection.sv
index e9b2418..37f4566 100644
--- a/hw/ip/tlul/dv/tb/xbar_tl_if_connection.sv
+++ b/hw/ip/tlul/dv/tb/xbar_tl_if_connection.sv
@@ -3,17 +3,19 @@
 // SPDX-License-Identifier: Apache-2.0
 
 // Device TileLink interface connections
-`CONNECT_TL_DEVICE_IF(sram_tl_if, dut.tl_d_o[tl_main_pkg::TlSram],
-                      dut.tl_d_i[tl_main_pkg::TlSram], TlSram)
-`CONNECT_TL_DEVICE_IF(uart_tl_if, dut.tl_d_o[tl_main_pkg::TlUart],
-                      dut.tl_d_i[tl_main_pkg::TlUart], TlUart)
-`CONNECT_TL_DEVICE_IF(Gpio_tl_if, dut.tl_d_o[tl_main_pkg::TlGpio],
-                      dut.tl_d_i[tl_main_pkg::TlGpio], TlGpio)
+`CONNECT_TL_DEVICE_IF(rom_tl_if, dut.tl_rom_o, dut.tl_rom_i, TlRom)
+`CONNECT_TL_DEVICE_IF(debug_mem_tl_if, dut.tl_debug_mem_o, dut.tl_debug_mem_i, TlDebugMem)
+`CONNECT_TL_DEVICE_IF(ram_main_tl_if, dut.tl_ram_main_o, dut.tl_ram_main_i, TlRamMain)
+`CONNECT_TL_DEVICE_IF(eflash_tl_if, dut.tl_eflash_o, dut.tl_eflash_i, TlEflash)
+`CONNECT_TL_DEVICE_IF(uart_tl_if, dut.tl_uart_o, dut.tl_uart_i, TlUart)
+`CONNECT_TL_DEVICE_IF(gpio_tl_if, dut.tl_gpio_o, dut.tl_gpio_i, TlGpio)
+`CONNECT_TL_DEVICE_IF(spi_device_tl_if, dut.tl_spi_device_o, dut.tl_spi_device_i, TlSpiDevice)
+`CONNECT_TL_DEVICE_IF(flash_ctrl_tl_if, dut.tl_flash_ctrl_o, dut.tl_flash_ctrl_i, TlFlashCtrl)
+`CONNECT_TL_DEVICE_IF(rv_timer_tl_if, dut.tl_rv_timer_o, dut.tl_rv_timer_i, TlRvTimer)
+`CONNECT_TL_DEVICE_IF(hmac_tl_if, dut.tl_hmac_o, dut.tl_hmac_i, TlHmac)
+`CONNECT_TL_DEVICE_IF(rv_plic_tl_if, dut.tl_rv_plic_o, dut.tl_rv_plic_i, TlRvPlic)
 
 // Host TileLink interface connections
-`CONNECT_TL_HOST_IF(corei_tl_if, dut.tl_h_i[tl_main_pkg::TlCoreI],
-                      dut.tl_h_o[tl_main_pkg::TlCoreI], TlCoreI)
-`CONNECT_TL_HOST_IF(cored_tl_if, dut.tl_h_i[tl_main_pkg::TlCoreD],
-                      dut.tl_h_o[tl_main_pkg::TlCoreD], TlCoreD)
-`CONNECT_TL_HOST_IF(debug_tl_if, dut.tl_h_i[tl_main_pkg::TlDebugSba],
-                      dut.tl_h_o[tl_main_pkg::TlDebugSba], TlDebugSba)
+`CONNECT_TL_HOST_IF(corei_tl_if, dut.tl_corei_i, dut.tl_corei_o, TlCorei)
+`CONNECT_TL_HOST_IF(cored_tl_if, dut.tl_cored_i, dut.tl_cored_o, TlCored)
+`CONNECT_TL_HOST_IF(dm_sba_tl_if, dut.tl_dm_sba_i, dut.tl_dm_sba_o, TlDmSba)
diff --git a/hw/ip/tlul/dv/tests/xbar_base_test.sv b/hw/ip/tlul/dv/tests/xbar_base_test.sv
index 4e966cd..4ebbb32 100644
--- a/hw/ip/tlul/dv/tests/xbar_base_test.sv
+++ b/hw/ip/tlul/dv/tests/xbar_base_test.sv
@@ -9,7 +9,7 @@
   xbar_env_cfg    cfg;
   virtual clk_if  clk_vif;
   xbar_vseq       vseq;
-  int unsigned    max_quit_count = 1;
+  int unsigned    max_quit_count = 10;
   int unsigned    test_timeout_ns = 200_000_000; // 200ms
   int unsigned    drain_time_ns = 2_000;  // 2us
 
diff --git a/hw/ip/tlul/dv/tests/xbar_test.core b/hw/ip/tlul/dv/tests/xbar_test.core
new file mode 100644
index 0000000..85cbb09
--- /dev/null
+++ b/hw/ip/tlul/dv/tests/xbar_test.core
@@ -0,0 +1,19 @@
+CAPI=2:
+# Copyright lowRISC contributors.
+# Licensed under the Apache License, Version 2.0, see LICENSE for details.
+# SPDX-License-Identifier: Apache-2.0
+name: "lowrisc:dv:xbar_test:0.1"
+description: "xbar DV UVM test"
+filesets:
+  files_dv:
+    depend:
+      - lowrisc:dv:xbar_env
+    files:
+      - xbar_test_pkg.sv
+      - xbar_base_test.sv: {is_include_file: true}
+    file_type: systemVerilogSource
+
+targets:
+  default:
+    filesets:
+      - files_dv
diff --git a/hw/ip/tlul/xbar_dv.core b/hw/ip/tlul/dv/xbar_sim.core
similarity index 65%
rename from hw/ip/tlul/xbar_dv.core
rename to hw/ip/tlul/dv/xbar_sim.core
index 4b6d3c0..2ed0faf 100644
--- a/hw/ip/tlul/xbar_dv.core
+++ b/hw/ip/tlul/dv/xbar_sim.core
@@ -8,17 +8,16 @@
   files_dv:
     depend:
       - lowrisc:ip:tlul:0.1
+      - lowrisc:ip:xbar:0.1
       - lowrisc:dv:dv_utils
       - lowrisc:dv:tl_agent
       - lowrisc:dv:scoreboard
       - lowrisc:dv:mem_model
+      - lowrisc:dv:xbar_test:0.1
     files:
-      - dv/env/xbar_env_pkg.sv
-      - dv/tests/xbar_test_pkg.sv
-      - dv/tb/xbar_tb_top.sv
-      - dv/env/xbar_params.svh: {is_include_file: true}
-      - dv/tests/xbar_seq_lib.sv: {is_include_file: true}
-      - dv/tb/xbar_tl_if_connection.sv: {is_include_file: true}
+      - tb/tb.sv
+      - tb/xbar_main_bind.sv
+      - tb/xbar_tl_if_connection.sv: {is_include_file: true}
     file_type: systemVerilogSource
 
 targets:
diff --git a/hw/ip/tlul/xbar.core b/hw/ip/tlul/xbar.core
new file mode 100644
index 0000000..066afc8
--- /dev/null
+++ b/hw/ip/tlul/xbar.core
@@ -0,0 +1,21 @@
+CAPI=2:
+# Copyright lowRISC contributors.
+# Licensed under the Apache License, Version 2.0, see LICENSE for details.
+# SPDX-License-Identifier: Apache-2.0
+name: "lowrisc:ip:xbar:0.1"
+description: "xbar for top_earlgray"
+
+filesets:
+  files_rtl:
+    depend:
+      - lowrisc:ip:tlul
+    files:
+      - ../../top_earlgrey/rtl/tl_main_pkg.sv
+      - ../../top_earlgrey/rtl/xbar_main.sv
+    file_type: systemVerilogSource
+
+targets:
+  default: &default_target
+    filesets:
+      - files_rtl
+    toplevel: xbar_main