题解 | #使用子模块实现三输入数的大小比较#

使用子模块实现三输入数的大小比较

https://www.nowcoder.com/practice/bfc9e2f37fe84c678f6fd04dbce0ad27

`timescale 1ns/1ns
module sub_mod(
input clk,
input rst_n,
input [7:0] in1,
input [7:0] in2,
output reg[7:0] c
);
always @(posedge clk or negedge rst_n)
begin
	if(!rst_n)
	begin 
	c<=0;
	end
		else
		begin
			if(in2>in1)
			begin
			c<=in1;
			end
			else
			begin
			c<=in2;
			end
		end
end

endmodule
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]temp,temp1,out;
sub_mod ab(.c(temp),.in1(a),.in2(b),.clk(clk),.rst_n(rst_n)); 
sub_mod ac(.c(temp1),.in1(a),.in2(c),.clk(clk),.rst_n(rst_n));
sub_mod t(.c(out),.in1(temp),.in2(temp1),.clk(clk),.rst_n(rst_n));
assign d=out;
endmodule

全部评论

相关推荐

07-03 11:02
中山大学 C++
字节刚oc,但距离九月秋招很近了有两段互联网实习,非腾讯字节。不敢赌转正,现在在纠结去还是不去如果实习俩月离职会有什么后果吗
阿城我会做到的:不去后悔一辈子,能否转正取决于ld的态度,只要他不卡,答辩就是走流程,个人觉得可以冲一把
投递字节跳动等公司9个岗位
点赞 评论 收藏
分享
Gaynes:查看图片
点赞 评论 收藏
分享
湫湫湫不会java:先投着吧,大概率找不到实习,没实习的时候再加个项目,然后把个人评价和荣誉奖项删了,赶紧成为八股战神吧,没实习没学历,秋招机会估计不多,把握机会。或者说秋招时间去冲实习,春招冲offer,但是压力会比较大
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务