From c10e1b0ff4146c4a7c8c032ac0944f21b17945a9 Mon Sep 17 00:00:00 2001
From: "Wesley W. Terpstra" <w.terpstra@gsi.de>
Date: Thu, 21 Apr 2016 17:31:30 +0200
Subject: [PATCH] msi: handle empty msi sdb records

---
 modules/wishbone/wb_crossbar/sdb_rom.vhd      | 25 +++++++++++--------
 .../wishbone/wb_crossbar/xwb_sdb_crossbar.vhd |  7 +++++-
 modules/wishbone/wishbone_pkg.vhd             |  6 ++---
 3 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/modules/wishbone/wb_crossbar/sdb_rom.vhd b/modules/wishbone/wb_crossbar/sdb_rom.vhd
index d0b65b11..e22ae494 100644
--- a/modules/wishbone/wb_crossbar/sdb_rom.vhd
+++ b/modules/wishbone/wb_crossbar/sdb_rom.vhd
@@ -77,14 +77,14 @@ architecture rtl of sdb_rom is
     return t_rom 
   is
     variable res : t_rom := (others => (others => '0'));
-    variable sdb_device : std_logic_vector(c_sdb_device_length-1 downto 0) := (others => '0');
+    variable sdb_record : t_sdb_record;
     variable sdb_component : t_sdb_component;
   begin
-    sdb_device(511 downto 480) := x"5344422D"  ;                                     -- sdb_magic
-    sdb_device(479 downto 464) := std_logic_vector(to_unsigned(c_used_entries, 16)); -- sdb_records
-    sdb_device(463 downto 456) := x"01";                                             -- sdb_version
-    sdb_device(455 downto 448) := x"00";                                             -- sdb_bus_type = sdb_wishbone
-    sdb_device(  7 downto   0) := x"00";                                             -- record_type  = sdb_interconnect
+    sdb_record(511 downto 480) := x"5344422D"  ;                                     -- sdb_magic
+    sdb_record(479 downto 464) := std_logic_vector(to_unsigned(c_used_entries, 16)); -- sdb_records
+    sdb_record(463 downto 456) := x"01";                                             -- sdb_version
+    sdb_record(455 downto 448) := x"00";                                             -- sdb_bus_type = sdb_wishbone
+    sdb_record(  7 downto   0) := x"00";                                             -- record_type  = sdb_interconnect
     
     sdb_component.addr_first := (others => '0');
     sdb_component.addr_last  := std_logic_vector(g_bus_end);
@@ -93,19 +93,24 @@ architecture rtl of sdb_rom is
     sdb_component.product.version   := x"00000003";
     sdb_component.product.date      := x"20120511";
     sdb_component.product.name      := "WB4-Crossbar-GSI   ";
-    sdb_device(447 downto   8) := f_sdb_embed_component(sdb_component, (others => '0'));
+    sdb_record(447 downto   8) := f_sdb_embed_component(sdb_component, (others => '0'));
     
     for i in 0 to c_sdb_words-1 loop
       res(c_sdb_words-1-i) := 
-        sdb_device((i+1)*c_wishbone_data_width-1 downto i*c_wishbone_data_width);
+        sdb_record((i+1)*c_wishbone_data_width-1 downto i*c_wishbone_data_width);
     end loop;
     
     for idx in c_layout'range loop
-      sdb_device(511 downto 0) := c_layout(idx);
+      sdb_record := c_layout(idx);
+      
+      -- All local/temporary types => empty record
+      if sdb_record(7 downto 4) = x"f" then
+        sdb_record(3 downto 0) := x"f";
+      end if;
       
       for i in 0 to c_sdb_words-1 loop
         res((idx+1)*c_sdb_words-1-i) := 
-          sdb_device((i+1)*c_wishbone_data_width-1 downto i*c_wishbone_data_width);
+          sdb_record((i+1)*c_wishbone_data_width-1 downto i*c_wishbone_data_width);
       end loop;
     end loop;
     
diff --git a/modules/wishbone/wb_crossbar/xwb_sdb_crossbar.vhd b/modules/wishbone/wb_crossbar/xwb_sdb_crossbar.vhd
index c237a721..0de69e92 100644
--- a/modules/wishbone/wb_crossbar/xwb_sdb_crossbar.vhd
+++ b/modules/wishbone/wb_crossbar/xwb_sdb_crossbar.vhd
@@ -173,11 +173,16 @@ architecture rtl of xwb_sdb_crossbar is
           result.msi_mask   (msi_index) := std_logic_vector(size(address'range));
           msi_index := msi_index + 1;
         
-        when x"ff" =>
+        when x"f1" | x"f2" =>
           result.bus_address(bus_index) := (others => '1');
           result.bus_mask   (bus_index) := (others => '0');
           bus_index := bus_index + 1;
         
+        when x"f3" =>
+          result.msi_address(msi_index) := (others => '1');
+          result.msi_mask   (msi_index) := (others => '0');
+          msi_index := msi_index + 1;
+        
         when others => null;
       end case;
     end loop;
diff --git a/modules/wishbone/wishbone_pkg.vhd b/modules/wishbone/wishbone_pkg.vhd
index ea085890..4d1826d6 100644
--- a/modules/wishbone/wishbone_pkg.vhd
+++ b/modules/wishbone/wishbone_pkg.vhd
@@ -1361,7 +1361,7 @@ package body wishbone_pkg is
     constant c_zero  : t_wishbone_address := (others => '0');
     variable v_empty : t_sdb_record := (others => '0');
   begin
-    v_empty(7 downto 0) := (others => '1');
+    v_empty(7 downto 0) := x"f1";
     if enable then
       return f_sdb_embed_device(device, c_zero);
     else
@@ -1375,7 +1375,7 @@ package body wishbone_pkg is
     constant c_zero  : t_wishbone_address := (others => '0');
     variable v_empty : t_sdb_record := (others => '0');
   begin
-    v_empty(7 downto 0) := (others => '1');
+    v_empty(7 downto 0) := x"f2";
     if enable then
       return f_sdb_embed_bridge(bridge, c_zero);
     else
@@ -1389,7 +1389,7 @@ package body wishbone_pkg is
     constant c_zero  : t_wishbone_address := (others => '0');
     variable v_empty : t_sdb_record := (others => '0');
   begin
-    v_empty(7 downto 0) := (others => '1'); -- !!! fuck
+    v_empty(7 downto 0) := x"f3";
     if enable then
       return f_sdb_embed_msi(msi, c_zero);
     else
-- 
GitLab