Often while writing testbenches it is necessary to store vectors or
read in vectors in the testbench. This can be accomplished by declaring
a RegFile which initializes its contents at start of simulation.
import RegFile::*; module mkDesign(); ... RegFile#( Bit#(5), Bit#(11) ) stimulus_io <- mkRegFileLoad ( "input_file",0,7) ; // Create a register file which is indexed by 5 bits, and holds 11 bit data. //Initialize the Register File from "input_file", but and only create a 8 (0 to 7) by 11 bit size. RegFile#( Bit#(5), Bit#(11) ) regfile2 <- mkRegFileFullLoad ("input_file") ; // Create a register file which is indexed by 5 bits, and holds 11 bit data. //Initialize the Register File from "input_file", and create all cell // create a 32 by 11 bit size. (2 ^ 5 = 32) ... endmodule : mkDesign
The data file input_file is the file to read in during simulation initialization. It should be in Verilog hex format.
Using Lists for Test Patterns
It is not recommended to iterate over lists, to initialize objects
at runtime, since computation becomes very expensive. Each assignment
generates a rule and the synthesis of rules has complexity n-squared in
the worst case.
|