Mahnaz_m
Newbie level 2
Hi,
I have a vector and a matrix of hexadecimal values stored in .mem files. I need to subtract this vector from each row of a matrix in each clock cycle.
I have read my files to my testbench file using $readmemh in verilog. How can I subtract them now?
I have used xilinx ip floating ip core for subtraction as well.
Here is my code but this code works for only one row of matrix.
I have a vector and a matrix of hexadecimal values stored in .mem files. I need to subtract this vector from each row of a matrix in each clock cycle.
I have read my files to my testbench file using $readmemh in verilog. How can I subtract them now?
I have used xilinx ip floating ip core for subtraction as well.
Here is my code but this code works for only one row of matrix.
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 module rbfnn_tb; //Memory for reading files reg [63:0] test_input[7:0]; reg [63:0] centers [7:0]; // Input ports all be registers reg aclk; reg [64*8-1:0] test_flat; reg [64*8-1:0] center_flat; reg aresetn; reg s_axis_a_tvalid; reg s_axis_b_tvalid; reg s_axis_operation_tvalid; reg m_axis_result_tready; reg [7:0] s_axis_operation_tdata; // output ports will be wires wire s_axis_a_tready; wire s_axis_b_tready; wire s_axis_operation_tready; wire m_axis_result_tvalid; wire [2:0] m_axis_result_tuser; wire [64*8-1:0] sub_out; //reg [64*8-1:0] sub_result; // reading input files initial begin $readmemh("test.mem", test_input); $readmemh("centers.mem", centers); end // flattening Input vectors integer i; always @ (posedge aclk) begin for (i = 0; i < 8; i = i+1) begin test_flat[64*i+: 64] <= test_input[i]; center_flat[64*i+: 64] <= centers[i]; end end rbfnn RBFNN( .test_input(test_flat), .centers(center_flat), .sub_out(sub_out), .aclk(aclk), .aresetn(aresetn), .s_axis_a_tvalid(s_axis_a_tvalid), .s_axis_b_tvalid(s_axis_b_tvalid), .s_axis_operation_tvalid(s_axis_operation_tvalid), .m_axis_result_tready(m_axis_result_tready), .s_axis_operation_tdata(s_axis_operation_tdata), .s_axis_a_tready(s_axis_a_tready), .s_axis_b_tready(s_axis_b_tready), .s_axis_operation_tready(s_axis_operation_tready), .m_axis_result_tvalid(m_axis_result_tvalid), .m_axis_result_tuser(m_axis_result_tuser) //.sub_result(sub_result) ); initial begin aclk <= 0; end always #10 aclk <= ~aclk; initial begin $monitor($time, " clk = %b \n test: %h \n center: %h \n result = %h ", aclk, test_flat, center_flat, sub_out ); // Initialize Inputs aresetn <= 1; s_axis_a_tvalid <= 0; s_axis_b_tvalid <= 0; s_axis_operation_tvalid <= 0; m_axis_result_tready <= 0; test_flat <= 0; center_flat <= 0; s_axis_operation_tdata <= 0; #8; // Add stimulus here aresetn = 1; s_axis_a_tvalid = 1; s_axis_b_tvalid = 1; s_axis_operation_tvalid = 1; m_axis_result_tready = 1; s_axis_operation_tdata = 1; #800 $finish; end endmodule