题解 | #4位数值比较器电路#

4位数值比较器电路

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

`timescale 1ns/1ns

module comparator_4(
	input		[3:0]       A   	,
	input	   [3:0]		B   	,
 
 	output	 wire		Y2    , //A>B
	output   wire        Y1    , //A=B
    output   wire        Y0      //A<B
);

	wire out0_xnor,out1_xnor,out2_xnor,out3_xnor,out0_not,out1_not,out2_not,out3_not,
			out0_and,out1_and,out2_and,out3_and,out4_and,out5_and,out6_and;

	xnor 	xonr0(out0_xnor,A[0],B[0]),
			xonr1(out1_xnor,A[1],B[1]),
			xonr2(out2_xnor,A[2],B[2]),
			xonr3(out3_xnor,A[3],B[3]);

	not		not0(out0_not,B[0]),
			not1(out1_not,B[1]),
			not2(out2_not,B[2]),
			not3(out3_not,B[3]);

	and		and0(out0_and,A[0],out0_not),//A[0]&&!B[0]
			and1(out1_and,A[1],out1_not),//A[1]&&!B[1]
			and2(out2_and,A[2],out2_not),//A[2]&&!B[2]
			and3(out3_and,A[3],out3_not),//A[3]&&!B[3]
			and4(out4_and,out3_xnor,out2_and),//
			and5(out5_and,out3_xnor,out2_xnor,out1_and),
			and6(out6_and,out3_xnor,out2_xnor,out1_xnor,out0_and),
			and7(Y1,out0_xnor,out1_xnor,out2_xnor,out3_xnor);


	or 		or0(Y2,out3_and,out4_and,out5_and,out6_and);
			
	nor		nor0(Y0,Y1,Y2);


endmodule

全部评论

相关推荐

不愿透露姓名的神秘牛友
10-04 05:12
kalistar:简历留六个字,北京大学(本科),黑体加粗,看看哪个hr不长眼敢碰瓷我们北大✌
点赞 评论 收藏
分享
09-25 00:00
已编辑
电子科技大学 Java
球球与墩墩:这不是前端常考的对象扁平化吗,面试官像是前端出来的 const flattern = (obj) => { const res = {}; const dfs = (curr, path) => { if(typeof curr === 'object' && curr !== null) { const isArray = Array.isArray(curr); for(let key in curr) { const newPath = path ? isArray ? `${path}[${key}]` : `${path}.${key}` : key; dfs(curr[key], newPath); } } else { res[path] = curr } } dfs(obj); return res; }
查看3道真题和解析
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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