题解 | #使用子模块实现三输入数的大小比较#
使用子模块实现三输入数的大小比较
https://www.nowcoder.com/practice/bfc9e2f37fe84c678f6fd04dbce0ad27
`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]c1; wire [7:0]c2; wire [7:0] d_buff; assign d = d_buff; mod uut1( .clk(clk), .rst_n(rst_n), .a(a), .b(b), .c(c1) ); mod uut2( .clk(clk), .rst_n(rst_n), .a(a), .b(c), .c(c2) ); mod uut3( .clk(clk), .rst_n(rst_n), .a(c1), .b(c2), .c(d_buff) ); endmodule module mod( input clk, input rst_n, input [7:0]a, input [7:0]b, output [7:0]c ); reg [7:0] c_buff; assign c = c_buff; always@(posedge clk or negedge rst_n)begin if(!rst_n) c_buff <= 8'b0; else c_buff <= (a < b)?a:b; end endmodule
查看16道真题和解析