`timescale 1ns/1ns
module main_mod(
    input clk,
    input rst_n,
    input [7:0]a,
    input [7:0]b,
    input [7:0]c,
    
    output [7:0]d
);
    //将子模块进行例化操作
    //
    wire[7:0]  c0;
    //先求出ab的最小值c0
    son_mod t1(clk,rst_n,a,b,c0);
    //再求出ac的最小值c1
    wire[7:0]  c1;
    son_mod t2(clk,rst_n,a,c,c1);
    //最后求出最小值
    son_mod t3(clk,rst_n,c0,c1,d);
    

endmodule

//子模块定义
module son_mod(
    input clk,
    input rst_n,
    input[7:0] a,
    input[7:0] b,
    output[7:0] c0
);
    reg[7:0] reg_c0;
    always@(posedge clk or negedge rst_n)begin
        if(~rst_n)begin
            reg_c0<=8'b0;
        end
        else if(a>b)begin
            reg_c0<=b;
        end
        else begin
            reg_c0<=a;
        end
    end
    assign c0=reg_c0;
endmodule