Skip to content
Snippets Groups Projects
Commit 5a0858b4 authored by dam1n19's avatar dam1n19
Browse files

Added Model Stimulus Reader and fixed testbench bug

parent 248221ef
No related branches found
No related tags found
No related merge requests found
......@@ -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) : 512'd0;
assign end_marker = |data_word_rem ? 1 << (512 - data_word_rem - 1) : 512'd0; // BUG HERE!
// Combine Last Data (after being masked) with end marker and size
assign last_data_word = (data_in & last_word_mask) | end_marker;
......
......@@ -124,6 +124,7 @@ module tb_message_build;
logic data_out_last_check;
logic check_output;
logic test_end;
int packet_num;
// Handle Output Ready Driving
always_ff @(posedge clk, negedge nrst) begin: data_out_recieve
......@@ -138,37 +139,32 @@ module tb_message_build;
end else begin
data_out_ready <= 1'b0;
end
// Check Data on Handshake
if ((data_out_valid == 1'b1) && (data_out_ready == 1'b1)) begin
check_output <= 1'b1;
if ((data_out_queue.size() > 0) && (data_out_last_queue.size() > 0)) begin
data_out_check <= data_out_queue.pop_front();
data_out_last_check <= data_out_last_queue.pop_front();
end else begin
test_end <= 1'b1;
end
end else begin
check_output <= 1'b0;
end
end
end
// Handle Output Data Verification
always @(posedge clk) begin
if (check_output == 1'b1) begin
assert (data_out == data_out_check) else begin
$error("data_out missmatch! recieve: %x != check: %x", data_out, data_out_check);
$finish;
end
assert (data_out_last == data_out_last_check) else begin
$error("data_out_last missmatch! recieve: %x != check: %x", data_out_last, data_out_last_check);
// Check Data on Handshake
if ((data_out_valid == 1'b1) && (data_out_ready == 1'b1)) begin
if ((data_out_queue.size() > 0) && (data_out_last_queue.size() > 0)) begin
data_out_check <= data_out_queue.pop_front();
data_out_last_check <= data_out_last_queue.pop_front();
assert (data_out == data_out_check) else begin
$error("data_out missmatch! packet %d | recieve: %x != check: %x", packet_num, data_out, data_out_check);
$finish;
end
assert (data_out_last == data_out_last_check) else begin
$error("data_out_last missmatch! packet %d | recieve: %x != check: %x", packet_num, data_out_last, data_out_last_check);
$finish;
end
if (data_out_last_check == 1'b1) begin
packet_num <= packet_num + 1;
end
end else begin
$display("Test Passes");
$finish;
end
end
if (test_end == 1'b1) begin
$display("Test Passes");
$finish;
end
end
// File Reading Variables
......
......@@ -11,16 +11,20 @@
import os, sys, random, math, csv
def main(argv):
def main():
# Check Environment Variables set
if not "SHA_2_ACC_DIR" in os.environ:
print("Sourceme file at root of repository has not been sourced. Please source this file and try again.")
quit()
# Read in Descriptor File
# - contains number of packets of data to generate and random seed
# input_file = argv[1]
seed = 1 # Needs to be loaded in from file
packets = 1
stim_file = os.environ["SHA_2_ACC_DIR"] + "/simulate/stimulus/" + "model_builder_stim.csv"
with open(stim_file, "r") as stim:
csvreader = csv.reader(stim, delimiter=",")
stim_list = list(csvreader)
seed = int(stim_list[0][0])
packets = int(stim_list[0][1])
random.seed(seed)
print(f"Generating {packets} packets using seed: {seed}")
......@@ -47,7 +51,6 @@ 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:
......@@ -103,4 +106,4 @@ def chunkstring(string, length):
return array
if __name__ == "__main__":
main(sys.argv[1:])
main()
1132,0,1
2d00,0,1
33dd,0,1
1bc4,0,1
2428,0,1
3ea7,0,1
21c4,0,1
312a,0,1
1ecb,0,1
4bb,0,1
8df,0,1
18ec,0,1
227,0,1
1f99,0,1
2c89,0,1
201d,0,1
123e,0,1
2d68,0,1
2c91,0,1
3637,0,1
1c0,0,1
23d0,0,1
1afc,0,1
174d,0,1
2b56,0,1
358f,0,1
265f,0,1
106b,0,1
ef5,0,1
3f0b,0,1
e80,0,1
1723,0,1
3518,0,1
49e,0,1
225c,0,1
35ac,0,1
8e1,0,1
129,0,1
2cbb,0,1
130f,0,1
2bec,0,1
1c5b,0,1
33ae,0,1
712,0,1
1906,0,1
1436,0,1
26a6,0,1
1145,0,1
14ed,0,1
fca,0,1
3119,0,1
This diff is collapsed.
325259,50
\ No newline at end of file
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment