1 module halfband_tb( ) ;
3 // Parameters for instantiation
4 parameter clocks = 2 ; // Number of clocks per input
5 parameter decim = 0 ; // Sets the filter to decimate
6 parameter rate = 2 ; // Sets the decimation rate
12 reg signed [17:0] data_in ;
14 wire signed [17:0] data_out ;
17 initial clock = 1'b0 ;
18 always #5 clock <= ~clock ;
20 // Come out of reset after a while
21 initial reset = 1'b1 ;
22 initial #100 reset = 1'b0 ;
24 // Enable the entire system
25 initial enable = 1'b1 ;
36 .strobe_in ( strobe_in ),
38 .strobe_out ( strobe_out ),
39 .data_out ( data_out )
42 integer i, ri, ro, infile, outfile ;
46 infile = $fopen("input.dat","r") ;
47 outfile = $fopen("output.dat","r") ;
48 $timeformat(-9, 2, " ns", 10) ;
52 reg signed [17:0] compare ;
61 // Wait for reset to go away
64 // While we're still simulating ...
65 while( !endofsim ) begin
67 // Write the input from the file or 0 if EOF...
68 @( posedge clock ) begin
72 ri = $fscanf( infile, "%d", data_in ) ;
77 // Clocked in - set the strobe to 0 if the number of
78 // clocks per sample is greater than 1
79 if( clocks > 1 ) begin
80 @(posedge clock) begin
84 // Wait for the specified number of cycles
85 for( i = 0 ; i < (clocks-2) ; i = i + 1 ) begin
91 // Print out the number of errors that occured
93 $display( "FAILED: %d errors during simulation", noe ) ;
95 $display( "PASSED: Simulation successful" ) ;
100 // Output comparison of simulated values versus known good values
101 always @ (posedge clock) begin
105 if( !$feof(outfile) ) begin
106 if( strobe_out ) begin
107 ro = $fscanf( outfile, "%d\n", compare ) ;
108 if( compare != data_out ) begin
109 $display( "%t: %d != %d", $realtime, data_out, compare ) ;
114 // Signal end of simulation when no more outputs