File Operations in Modelsim-Big Data Test

Source: Internet
Author: User

File Operations are inevitable in ModelSim. Check the code operations in the window. Below is a piece of test code in my own M sequence experiment.

 

1 integer I, J, K, M; 2 3 integer m_datafile, 4 indatafile, 5 oudatafile; 6 7 Reg [] I _data [0: 9999]; 8 9 10 initial 11 begin 12 m_datafile = $ fopen (". /m_data.dat "); // M sequence storage file 13 indatafile = $ fopen (". /indata. dat "); // random number (data used for sending) storage file 14 oudatafile = $ fopen (". /oudata. dat "); // The storage file for receiving data 15 for (I = 0; I <10000; I = I + 1) 16 begin 17 I _data [I] = $ random % 16; 18 $ fdisplay (indatafile, "% B", I _data [I]); 19 end 20 $ fclose (indatafile ); 21 End 22 23 always @ (posedge clock) 24 if (reset) 25 begin: wirte_file26 $ fdisplay (m_datafile, "% B", my_m.m_sequ); // The M sequence stores 27 end

 

The following section shows the validation output. If an error occurs in the received or sent data, an error message is displayed.

1 Reg [] decode_data [0: 9999]; 2 3 always @ (posedge clk1) 4 If (! Reset1) 5 begin 6 K <= 0; 7 m <= 0; 8 end 9 else if (reset) & (fi_flag )) 10 begin 11 // decode_data [k] <= my_encode.ana_sign; 12 k <= k + 1; 13 $ fdisplay (oudatafile, "% B", my_encode.ana_sign ); // Save the received data for 14 15 16 if (I _data [K-2] = my_encode.ana_sign) 17 $ display ("% B OK! % B ", I _data [K-2], my_encode.ana_sign); 18 else 19 begin 20 m <= m + 1; 21 $ display (" % B error! % B ", I _data [K-2], my_encode.ana_sign); 22 end

As for I _data [K-2], why is this-2 because the data failover period is 2 clock

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.