USB Mass storage device - Save data to file - USB Mass storage device - Save data to file Hello, I have DE10-Lite board and I'm using Quartus Prime Lite Edition. My goal is to run something on the board and i want the output to be saved in a txt file. My code is correct...I think but it doesnt seem to write something on the file. I've done some research and i found out that i need to configure the usb to mass storage device, please correct me if my wrong. This is my code for a simple 2 to 1 mux just to make sure i get it right. module test99( input wire a, input wire b, input wire s, input wire clk, input wire file_enable, output wire y ); // Mux logic assign y = s ? a : b; // register to hold the data to be saved reg [15:0] data_to_save; // Initialize the data initial begin data_to_save = 16'h1234; end // Save data to a text file when file_enable is high always @(posedge clk) begin // Use the clock signal if (file_enable) begin $fopen("output.txt", "w"); // Open the file for writing $fwrite("output.txt", "Output (y) is: %b", y); // Write data to the file $fclose("output.txt"); // Close the file end end endmodule and this is on my top module that was created by the program, so i dont need to go to the pin planner, i just call my module from there. test99(.a(SW[0]),.b(SW[1]),.s(SW[2]),.clk(MAX10_CLK1_50),.file_enable(SW[3]),.y(LEDR[0])); I have created the file output.txt and saved it in the same folder. Replies: Re: USB Mass storage device - Save data to file Sorry for answering so late. Yes it worked with looping the data back to the samd21 and writing in there in a file. Thanks again for your time guys. Replies: Re: USB Mass storage device - Save data to file Hi, Probably that'll be easier by looping back the data and writing into text file using python. Thanks, Best Regards, Sheng Replies: Re: USB Mass storage device - Save data to file Thank you for your response, i saw the video that you sent me and it was actually quite good I didnt know that you could do that. Sadly it uses C and i can only use python and SystemVerilog on my project. My project is basically to combine two boards, the DE10-Lite and SAMD21 M0. The SAMD21 board will send the inputs to the DE10-Lite which will do something and the goal was to save the output to a txt file. But now im thinking if i send the output back to the SAMD21 and then save it to a txt file wouldn't that be easier? Please tell me your opinion and will keep you updated after i do some testing. Replies: Re: USB Mass storage device - Save data to file It definitely wont. I actually got a idea, please tell me what do you think about it. My project is basically to combine two boards, the DE10-Lite and SAMD21 M0. The SAMD21 board will send the inputs to the DE10-Lite which will do something and the goal was to save the output to a txt file. But now im thinking if i send the output back to the SAMD21 and then save it to a txt file wouldn't that be easier? Will try to do some testing and tell you the results. Replies: Re: USB Mass storage device - Save data to file Hi, The Verilog File IO Operations usually being used/worked for testbench check this link https://www.chipverify.com/verilog/verilog-file-io-operations If you want to run something on the board and output to be saved in a txt file, probably need to use embedded system. Here is a video link for your reference https://www.youtube.com/watch?v=kbIcXwtfBiY&t=414s Thanks, Best Regards, Sheng Replies: Re: USB Mass storage device - Save data to file This is not synthesizable code for an FPGA. An FPGA on its own has no concept of a file system. This would work for a simulation but not synthesis. You could save data to an on-chip RAM and then output it in some way or you could add a processor like Nios V, run an OS, and have drivers to access external mass storage. But as your code is right now, it won't save to a file. - 2023-10-18

external_document