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 40 41
| `timescale 1ns/10ps module tb_sort4; // 输入和输出信号 reg [3:0] a, b, c, d; wire [3:0] ra, rb, rc, rd; // 实例化sort4模块 sort4 uut ( .ra(ra), .rb(rb), .rc(rc), .rd(rd), .a(a), .b(b), .c(c), .d(d) ); // 初始化块 initial begin // 打印标题 $display("Test for sort4 module"); // 提供测试向量 // 每个测试向量包括四个输入值及其预期排序输出 a = 4'b1010; b = 4'b0101; c = 4'b1100; d = 4'b0011; #10; // 等待10个时间单位 $display("Input: a=%b, b=%b, c=%b, d=%b -> Output: ra=%b, rb=%b, rc=%b, rd=%b", a, b, c, d, ra, rb, rc, rd); a = 4'b0001; b = 4'b0011; c = 4'b0111; d = 4'b1111; #10; $display("Input: a=%b, b=%b, c=%b, d=%b -> Output: ra=%b, rb=%b, rc=%b, rd=%b", a, b, c, d, ra, rb, rc, rd); a = 4'b1001; b = 4'b0110; c = 4'b0011; d = 4'b1100; #10; $display("Input: a=%b, b=%b, c=%b, d=%b -> Output: ra=%b, rb=%b, rc=%b, rd=%b", a, b, c, d, ra, rb, rc, rd); // 结束仿真 $stop; end endmodule
|