1 Star 0 Fork 0

打野/Verilog练习代码

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
practice_24.2.18.v 960 Bytes
一键复制 编辑 原始数据 按行查看 历史
打野 提交于 1年前 . correct1
//2024-2-18 姜青羊
//日常练习
module fn_sw (
A,
B,
sel,
Y
);
input A,B,sel;
output Y;
reg Y;
always @(A or B or sel) begin
if(sel==1)
Y=A^B;
else
Y=A&B;
end
endmodule
//------testbench--------
module tb_fn_sw ();
reg a,b,s;
wire y;
fn_sw u_fn_sw (
.A(a),
.B(b),
.sel(s),
.Y(y)
);
initial begin
s=0; a=0; b=0;
#10 s=0; a=0; b=1;
#10 s=0; a=1; b=0;
#10 s=0; a=1; b=1;
#10 s=1; a=0; b=0;
#10 s=1; a=0; b=1;
#10 s=1; a=1; b=0;
#10 s=1; a=1; b=1;
$stop;
end
endmodule
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fight_wild/verilog-code.git
git@gitee.com:fight_wild/verilog-code.git
fight_wild
verilog-code
Verilog练习代码
master

搜索帮助