Defining a function/procedure in testbench

Status
Not open for further replies.

madalin1990

Full Member level 2
Joined
Apr 4, 2012
Messages
124
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Visit site
Activity points
2,090
Hi!
I want to write a testbench in VHDL to test writing/reading to/from a register!
I want to use some kind of user defined function to realise the "write to reg X the value Y" function and "read from reg Z the data stored" function.

The problem is I don't know what is best to userocess,function,procedures.Which of the VHDL features do you recommend for my testbench needs?
 

All three in the right circumstances. The fact you are asking this question shows you probably dont have a great understanding of VHDL. I suggest reading up about functions, procedures and processes from a tutorial.
 
I have followed your advice and I read some tutorial about them and I decided procedures were the ones I needed.
But I need a little help once more:how can I write some data to "ModelSim Transcript" to indicate that certain operation were done and to indicate what data was written at the current address?
 

Two ways:

use the report:

if (something_happened) then report "Something Happened" severity note; --severity level is NOTE, WARNING, ERROR or FAILURE

or use the OUTPUT file declared in textio:

Code:
variable l : line;

write(l, string'("Something Happened") );
writeline(OUTPUT, l);

Following this - you can easily write yourself an echo procedure:

Code:
procedure echo (arg : in string := "") is
  begin
    std.textio.write(std.textio.output, arg);
  end procedure echo;
 

How can i write in the report something like this:
"The data <data_value> was written at the address <address>" where data value and address are procedure's variables.
 
Last edited:

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…