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.
Hi,
Probably that'll be easier by looping back the data and writing into text file using python.
Thanks,
Best Regards,
Sheng