@Bassman59 I've never heard of using the generate statement like that but I think I get it. I'll have to do a little research to fully understand. Just quickly is the idea to do something like:
localparam TB_on = 0;
genvar i;
if(TB_on) begin
// Instance and code for verification/simulation
end else begin
// Normal instance call here.
end
endgenerate
That’s basically it.
I don’t know if Verilog has a feature like VHDL’s configurations. A configuration is a mechanism that lets you choose, at elaboration time, which architecture you use for a given entity.
For example, your test bench includes a model of an ADC. A full-up behavioral model of the converter might have a signal of type real for the input voltage and the reference voltage, and it does the “conversion” from volts to an integer with a range specified by the number of bits. And then it takes that conversion result and drives it on the interface that talks to your FPGA.
That’s all well and good, but it’s likely overly complicated, and when verifying your FPGA with this test bench, sometimes it’s easier for you to generate a known data pattern for the integer conversion result, and have that pattern drive the interface.
So you create your model with one entity port list and two architectures, one for the “full” model and one for the simplified model. The test bench instantiates the entity, and it uses a configuration statement to choose which architecture you want to use.
There is a second common use for configurations in test benches. You want to simulate your entire FPGA design, so your test bench instantiates the FPGA top level as well as models of the peripherals it talks to. This is your RTL (bus-functional) simulation. And you can use the exact same test bench to do a timing simulation, using the model generated by your FPGA tools and the SDF file for the timing information. That model has the exact same entity interface as your FPGA, so it can plug right in. Of course the internals of the model are the particular gate-level primitives that you get from the fitter. So to do this you write a configuration for your test bench, and in one configuration you do the RTL and in the other you do the timing model.
It’s all less complicated than my description makes it sound.