收藏 分销(赏)

四选一程序及仿真.doc

上传人:仙人****88 文档编号:8299388 上传时间:2025-02-09 格式:DOC 页数:4 大小:37.50KB 下载积分:10 金币
下载 相关 举报
四选一程序及仿真.doc_第1页
第1页 / 共4页
四选一程序及仿真.doc_第2页
第2页 / 共4页


点击查看更多>>
资源描述
请用四种方法,描述数据选择器 输入端 输出端 a b out 0 0 in0 0 1 in1 1 0 in2 1 1 in3 in0 in3 in1 in2 a b b out 方法1 module mux4_1(out,a,b,in); input a,b;input [3:0]in;output out; assign out =(!a&!b&in[0])| (!a&b&in[1])| (a&!b&in[2])| (a&b&in[3]); endmodule 方法2 module mux4_1(out,a,b,in); input a,b;input [3:0]in;output out; wire na,nb,c1,c2,c3,c0; not my_not1(na,a),my_not2(nb,b); and my_and0(c0,na,nb,in[0]), my_and1(c1,na,b,in[1]), my_and2(c2,a,nb,in[2]), my_and3(c1,a,b,in[3]); or my_or(out,c0,c1,c2,c3); endmodule 方法3 module mux4_1(out,a,b,in); input a,b;input [3:0]in;output reg out; always@( a,b,in)begin if(!a&&!b)out=in[0]; else if (!a&&b)out=in[1]; else if (a&&!b)out=in[2]; else out=in[3]; endmodule 方法4 module mux4_1(out,a,b,in); input a,b;input [3:0]in;output reg out; always@(a,b,in) begin case({a,b}) 0:out=in[0]; 1:out=in[1]; 2:out=in[2]; 3:out=in[3]; default:out=1’bx; endcase end endmodule 仿真程序 `timescale 1ns / 1ps module mux4_1_tf; reg a; reg b; reg [3:0] in=0; wire out; mux4_1 uut ( .out(out), .a(a), .b(b), .in(in) ); initial begin a = 0;b = 0;#120;a = 0;b = 1;#150; a = 1;b = 0;#160;a = 1;b = 1;#200; end always #30 in=in+1; endmodule
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 教育专区 > 小学其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服