File: sub8_tb.v

package info (click to toggle)
iverilog 12.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 30,148 kB
  • sloc: cpp: 109,972; ansic: 62,713; yacc: 10,216; sh: 3,470; vhdl: 3,246; perl: 1,814; makefile: 1,774; python: 78; csh: 2
file content (39 lines) | stat: -rw-r--r-- 772 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * Exhaustive check of all the subtract results.
 */
module main;

   wire [7:0] out;
   reg [7:0] A, B;

   sub8 dut(.out(out), .A(A), .B(B));

   reg	     error = 0;
   integer   adx, bdx;

   initial begin
      A = 0;
      B = 0;

      for (adx = 0 ;  adx < 256 ;  adx = adx + 1) begin
	 A = adx;
	 for (bdx = 0 ;  bdx < 256 ;  bdx = bdx + 1) begin
	    B = bdx;
	    #1 $write("%b - %b: %b", A, B, out);
	    if (out !== (A - B)) begin
	       $display(" ERROR");
	       error = 1;
	    end else begin
	       $display(" OK");
	    end

	 end // for (bdx = 0 ;  bdx < 256 ;  bdx += 1)
      end // for (adx = 0 ;  adx < 256 ;  adx = adx + 1)

      if (error == 0)
	$display("PASSED");
      else
	$display("FAILED");

   end // initial begin
endmodule // main