Coding tip: signals with similar name

Hi everyone,

I’m looking for a efficient way to instantiate a lot of signals with similar names. For example, I have 20 signals with the name “switch_0”, “switch_1” … “switch_19”. I don’t want to have to replicate the names everytime I need to use it.

Can you help me?

When I was using Specman E I could use “switch: list of simple_ports” (or something like that) to instantiate and work with a large number of signals.

Regards,
luca

In reply to lucaskoelho:

You need to better explain how what you are asking for is different from an array signal[0:19].

In reply to dave_59:

Okay.

When I am writing assertions in 20 pins I have to write assertions for every single pin?

Like this:


property p_signal_0
@(posedge clk) !switch_0 |-> enable_0 && !mem_read;
endproperty

property p_signal_1
@(posedge clk) !switch_1 |-> enable_1 && !mem_read;
endproperty

//... and son on 20 times.

My question is: how can I do that more efficiently?

In reply to lucaskoelho:

One way to do this would be write up a macro which should get it down to 23 lines of code 3 for the property & 20 for the signals.

Or if you have the option then you could use a script to spit this code out for you or you could check out if a generate statement would do the trick for you.

In reply to nndad:

One way to do this would be write up a macro which should get it down to 23 lines of code 3 for the property & 20 for the signals.

Can you give me an example?

Write a script to do that is my last option. I’m studying SystemVerilog and I think there’s a way to deal with it more easily.

THAT’S what I’m talking about!

Works like a charm!!!

If anyone has something nice to share post here!

In reply to lucaskoelho:

Hi,

If you are still searching for the answer on how to write a macro then see below,

`define SWITCH_PROP(NUM)
property p_signal_NUM; \ @(posedge clk) !switch_NUM |-> enable_``NUM && !mem_read;
endproperty

Now you just need to call the define above i.e. `SWITCH_PROP(0), and so on with other 19 numbers.

Hope that helps !

In reply to Avdhut Patel:

Hello Avdhut this macro modelling helps

then he need to call that macro 20 times as below:

SWITCH_PROP(1) SWITCH_PROP(2)

.
.
.
.
SWITCH_PROP(19) SWITCH_PROP(20)

Thanks