### Welcome to EDAboard.com

#### Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

# Verilog task similar to $signal_force Status Not open for further replies. #### amsverif ##### Newbie level 2 Hi All, I am creating a task in verilog that works similar to$signal_force verilog system task.
But with a lesser number of arguments i.e. - Signal to force, value to be forced and the time at which the value is to be forced.

As its not working for me I am working with 2 arguments - Signal to force, value to be forced.

My test case calls this task as
my_signal_force (Top.X1.X2.sig, 1'b0); // The signal can be bus also

input reg [8*10:0] string;
input [31:0] val;

begin
$display("PRINT THE SIGNAL = %s \n", string); force string = val;$display("PRINT THE SIGNAL NOW= %s \n", string);
end

My main concern is if I take the first argument as wire and define as "input string;" . Verilog will not understand that the way I intend to as the signal is anyways a set of characters. So, I have to anyways take the first arg as string.
Now, how to force the signal with a value here ? How to get the signal forced in the force statement when I receive the left hand side as a string. The first display statement displays the signal path. But second doesn't diplay anything as it accepts the value 00000 ....
Can anyone help?

#### dave_59

• First of all, why don't you just use $signal_force without the optional arguments? Or put it inside your task? • Second, the force statement does not take a string. It uses the identifier that follows the force keyword to apply the force. In your example, string is the name of the variable that will be forced because that is the name if the identifier that follows the force keyword. • Third, Top.X1.X2.sig is not a string, it is a hierarchical reference to the signal sig. If you want a string literal, you need to put quotes around it. like "Top.X1.X2.sig". • Fourth, that string "Top.X1.X2.sig" in my third bullet is 13 character long and it wouldn't fit in the string input argument you declared, event if that's what you want to do. • Fifth, string is a reserved keyword in SystemVerilog, don't use it as an identifier. #### amsverif ##### Newbie level 2 Thanks Dave for your reply. I want my environment to be portable and hence don't want$signal_force which is tool dependant. Its \$signal_force for Modelsim and nc_force for NCSim.
I have gone through some literature that the implementation I want to do is indeed possible but verilog can't do it standalone. It requires a PLI.

#### dave_59

##### Advanced Member level 3
Yes, PLI is the only way to look up Verilog identifiers by string names. Note that using the PLI to access signals this way can have a dramatic effect on performance of the simulation, since it prevents all sorts of optimizations. So you should think of another way to achieve what you want (and I don't know what you really want).

Status
Not open for further replies.