【FPGA学习笔记】初次使用FPGA硬件编程编程语言Verilog编写HDL程序02

案例练习:

1、创建一个实现非门的模块

在这里插入图片描述
Verilog 有单独的按位非 ( ~) 和逻辑非 ( !) 运算符。

module top_module( input in, output out );
	//assign out = !in;  // 逻辑非
    assign out = ~in`b1; // 按位非
endmodule

2、创建一个实现AND与门的模块

该电路现在有三根导线(a、b和out)。电线a和b已经有输入端口驱动到它们的值。但是电线out目前不是由任何东西驱动的。编写一个用信号和的 ANDassign驱动的语句。

Verilog 有单独的位与 ( &) 和逻辑与 ( &&) 运算符

在这里插入图片描述

module top_module( 
    input a, 
    input b, 
    output out );
	assign out = a && b;
endmodule

3、创建一个实现NOR或非门的模块

创建一个实现 NOR 门的模块。或非门是一个输出反相的或门。
用 Verilog 编写的 NOR 函数需要两个运算符。
Verilog 有单独的按位或 ( |) 和逻辑或 ( ||) 运算符
在这里插入图片描述

module top_module( 
    input a, 
    input b, 
    output out );
    assign out = !(a || b);
endmodule

4、创建一个实现XNOR异或非门的模块

按位异或运算符是^
在这里插入图片描述

module top_module( 
    input a, 
    input b, 
    output out );
    assign out = !(a^b);
endmodule

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值