文章目录
一、前言
HDLBits是一个很棒的 Verilog 学习网站。
HDLBits 在提供 Verilog 基础语法教程的同时,还能够在线仿真你的 Verilog 模块,将你的输出与正确的时序比较。
可以让初学者在快速上手的同时,也更直观的感受到这门语言的特殊之处
下面是传送门:
HDLBits
二、组合逻辑相关练习
1.2 多路复用器
问题描述:
Create a one-bit wide, 2-to-1 multiplexer. When sel=0, choose a. When sel=1, choose b.
代码:
module top_module(
input a, b, sel,
output out );
assign out = (sel) ? b : a;
endmodule
仿真结果:
1.2 全加器
问题描述:
Create a full adder. A full adder adds three bits (including carry-in) and produces a sum and carry-out.
代码:
module top_module(
input a, b, cin,
output cout, sum );
assign{
cout,sum} = a + b + cin;
endmodule
1.3 卡诺图
问题描述:
Consider the function f shown in the Karnaugh map below.
Implement this function. d is don’t-care, which means you may choose
to output whatever value is convenient.
代码:
module top_module (
input [4:1] x,
output f );
assign f =<