From 248221ef9018b905128ca5360b02361f97d17a72 Mon Sep 17 00:00:00 2001
From: dam1n19 <d.a.mapstone@soton.ac.uk>
Date: Thu, 5 Jan 2023 16:55:09 +0000
Subject: [PATCH] fixed last bug and fixed message end pointer bug

---
 hdl/src/message_build.sv  | 4 ++--
 model/py/message_build.py | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/hdl/src/message_build.sv b/hdl/src/message_build.sv
index b4d69c3..c6597de 100644
--- a/hdl/src/message_build.sv
+++ b/hdl/src/message_build.sv
@@ -44,7 +44,7 @@ module message_build (
     
     // Create Position Marker to show end of data message (place a "1")
     // - only if not a multiple of 512
-    assign end_marker = |data_word_rem ? 1 << (512 - data_word_rem - 1) : 512'd0;  
+    assign end_marker = |data_word_rem ? 1 << (512 - data_word_rem) : 512'd0;  
     
     // Combine Last Data (after being masked) with end marker and size
     assign last_data_word = (data_in & last_word_mask) | end_marker;
@@ -107,7 +107,6 @@ module message_build (
                     if (!(data_out_valid && !data_out_ready)) begin
                         // If data out handshake has been seen, drop valid
                         next_data_out_valid = 1'b0;
-                        next_data_out_last  = 1'b0;
                     end
                     // If there is no Valid data at the output or there is a valid transfer happening on this clock cycle
                     if (cfg_valid == 1'b1) begin
@@ -144,6 +143,7 @@ module message_build (
                             // Write Input Data to Output 
                             next_data_out       = data_in;
                             next_data_out_valid = 1'b1;
+                            next_data_out_last  = 1'b0;
                             if (next_data_word_count == 1) begin
                                 // Last Input Data Word
                                 next_state = 3'd3;
diff --git a/model/py/message_build.py b/model/py/message_build.py
index 0edc652..3ec3858 100644
--- a/model/py/message_build.py
+++ b/model/py/message_build.py
@@ -47,6 +47,7 @@ def main(argv):
         out_data_words = chunked_data_words.copy()
         out_data_words_last = []
         last_len = len(chunked_data_words[-1])
+        # print(chunked_data_words[-1])
         if (last_len == 512):
             out_data_words.append("1" + "0"*447 + cfg_size_str)
         else:
-- 
GitLab