【HDLBits】verilog在线编程练习

【Verilog题目练习】HDLBits题目集合 个人HDLBits练习 阅读详情

一、前言

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 = (~x[1] & x[3]) | (x[1] & x[2] & ~x[3]);
endmodule

二、门电路相关练习

2.1 非门

Create a module that implements a NOT gate.

This circuit is similar to wire, but with a slight difference. When
making the connection from the wire in to the wire out we’re going to
implement an inverter (or “NOT-gate”) instead of a plain wire.

Use an assign statement. The assign statement will continuously drive
the inverse of in onto wire out.

在这里插入图片描述

代码:

module top_module( input in, output out );
	assign out=~in;
endmodule

在这里插入图片描述

2.2 与门

Create a module that implements an AND gate.
This circuit now has three wires (a, b, and out). Wires a and b already have values driven onto them by the input ports. But wire out currently is not driven by anything. Write an assign statement that drives out with the AND of signals a and b.
Note that this circuit is very similar to the NOT gate, just with one more input. If it sounds different, it’s because I’ve started describing signals as being driven (has a known value determined by something attached to it) or not driven by something. Input wires are driven by something outside the module. assign statements will drive a logic level onto a wire. As you might expect, a wire cannot have more than one driver (what is its logic level if there is?), and a wire that has no drivers will have an undefined value (often treated as 0 when synthesizing hardware).

在这里插入图片描述
代码:
在这里插入图片描述

2.3 或非门

Create a module that implements a NOR gate. A NOR gate is an OR gate with its output inverted. A NOR function needs two operators when written in Verilog.
An assign statement drives a wire (or “net”, as it’s more formally called) with a value. This value can be as complex a function as you want, as long as it’s a combinational (i.e., memory-less, with no hidden state) function. An assign statement is a continuous assignment because the output is “recomputed” whenever any of its inputs change, forever, much like a simple logic gate.

在这里插入图片描述

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

在这里插入图片描述

三、关于时序逻辑的练习

3.1 D触发器

A D flip-flop is a circuit that stores a bit and is updated periodically, at the (usually) positive edge of a clock signal.
D flip-flops are created by the logic synthesizer when a clocked always block is used (See alwaysblock2). A D flip-flop is the simplest form of “blob of combinational logic followed by a flip-flop” where the combinational logic portion is just a wire.
Create a single D flip-flop.
在这里插入图片描述

module top_module (
    input clk,    // Clocks are used in sequential circuits
    input d,
    output reg q );//

    // Use a clocked always block
    //   copy d to q at every positive edge of clk
    //   Clocked always blocks should use non-blocking assignments
    always@(posedge clk) begin
        q <= d;
    end
endmodule

在这里插入图片描述

3.2 D锁存器

Implement the following circuit:

在这里插入图片描述

Note that this is a latch, so a Quartus warning about having inferred a latch is expected.

代码:

module top_module (
    input d, 
    input ena,
    output q);
    always@(*)begin
        if(ena)begin
            q<=d;
        end
    end

endmodule

3.3 1~12的计数器

Design a 1-12 counter with the following inputs and outputs:
Reset Synchronous active-high reset that forces the counter to 1
Enable Set high for the counter to run
Clk Positive edge-triggered clock input
Q[3:0] The output of the counter
c_enable, c_load, c_d[3:0] Control signals going to the provided 4-bit counter, so correct operation can be verified.
You have the following components available:
the 4-bit binary counter (count4) below, which has Enable and synchronous parallel-load inputs (load has higher priority than enable). The count4 module is provided to you. Instantiate it in your circuit.
logic gates
module count4(
input clk,
input enable,
input load,
input [3:0] d,
output reg [3:0] Q
);
The c_enable, c_load, and c_d outputs are the signals that go to the internal counter’s enable, load, and d inputs, respectively. Their purpose is to allow these signals to be checked for correctness.

代码:

module top_module (
    input clk,
    input reset,
    input enable,
    output [3:0] Q,
    output c_enable,
    output c_load,
    output [3:0] c_d
); //

    count4 the_counter (clk, c_enable, c_load, c_d /*, ... */ );
    reg [3:0] temp;

    //4-bit计数器的控制信号
    assign c_enable = enable;
    //带复位和置位,
    assign c_load   = reset | (Q == 4'd12 & enable == 1'b1);
    assign c_d      = 4'b1;

//    count4 the_counter (clk, c_enable, c_load, c_d, Q );
    count4 Inst_count4
    (
        .clk(clk),
        .enable(c_enable),
        .load(c_load),
        .d(c_d),
        .Q(Q)
    );
endmodule

在这里插入图片描述

四、总结

本次实验目的是利用HDLBits网站做对verilog的再次练习。通过此次练习我不仅掌握了verilog的语法,还了解了它与硬件的交互方式,了解了一些电路的设计过程,为以后的学习打下了基础。

学习笔记:Verilog VHDL硬件描述语言简介及在线仿真Verilog环境 Vitis HLS (High Level Synthesis)是 Xilinx 公司重新打造的高层次综合工具,通过添加适当的 directives(制导语句) 和 constrains(约束), 将其 C/C++/System C 代码直接转换成 FPGA RTL( Verilog, VHDL, System C )代码。Verilog 继承了 C 语言的多种操作符和结构,与另一种硬件描述语言 VHDL 相比,语法不是很严格,代码更加简洁,更容易上手。probe(signal) :将信号添加到时序图中。 阅读详情

相关推荐

在线Verilog编程网站学习

https://hdlbits.01xz.net/wiki/Main_Page HDLBits — Verilog Practice 在线练习网站。

cbm2001的博客 1424

【在线仿真】使用HDLBits进行FPGA代码在线综合仿真以及时序图生成

本文讲述使用Hdlbits进行FPGA代码在线综合仿真以及时序图生成,用于验证自己的设计。

YprgDay的博客(Yuan make progress everyday) 6527

verilog学习 | HDLBits:在线学习答案

HDLBits 在提供 Verilog 基础语法教程的同时,还能够在线仿真 Verilog 模块。

驚蟄的博客 1万+

Verilog编程练习

Verilog编程巩固记录一、HDLBits网站练习1.门电路2.组合电路3.时序电路二、7天学好Robei 一、HDLBits网站练习 进入HDLBits网址练习 总的参考链接:在这里 1.门电路 练习题目链接 与门 and gate module top_module( input a, input b, output out ); assign out=a&b; endmodule 或非门 nor gate 或门的输出取反。 module t

qq_43643118的博客 1826

HDLBits系列汇总(Verilog专题)

HDLBits系列汇总(Verilog专题)

Andy_ICer的博客 1万+

Verilog编程在线练习

目录一、门电路联系1.非门问题2.与门3.或非门二、组合逻辑练习1.2对1多路复用2.全加器3.卡诺地图三、时序逻辑相关练习1.D触发器2.D锁存器3.1~12计数器四、参考资料 以下实验均在HDLBits — Verilog Practice 在线练习网站完成 一、门电路联系 1.非门问题 问题描述 解决代码 module top_module( input in, output out ); assign out=~in; endmodule 仿真结果 2.与门 问题描述 解决代码 mo

CHL的博客 1345

HDLBits在线Verilog编程练习

文章目录一、门电路相关练习1.非门2.与门3.或非门二、组合逻辑相关练习1.2对1多路复用器2.全加器3.卡诺地图三、时序逻辑相关练习1.D 触发器2.D锁存器3.1~12的计数器四、参考资料 一、门电路相关练习 1.非门 问题描述 参考下面链接 https://hdlbits.01xz.net/wiki/Notgate 问题解决代码 module top_module( input in, output out ); assign out=~in; endmodule 仿真结果 2.与门 问题描述

Harriet的博客 715

Verilog在线编程——HDLBits

文章目录一、门电路在线练习1、与门2、非门3、或非门二、组合电路在线练习1、2对1多路复用器2、全加法器3、3变量三、时序电路在线学习1、D触发器2、四位二进制计数器3、4位移位寄存器 一、门电路在线练习 1、与门 代码: module top_module( input a, input b, output out ); assign out=a&b; endmodule 仿真结果 2、非门 代码: module top_module( input in,

qq_43678923的博客 2455

Verilog编程巩固

1.在线Verilog编程网站学习。从门电路、组合电路、时序电路中各选3个以上的例题实践完成。 https://hdlbits.01xz.net/wiki/Main_Page HDLBits — Verilog Practice 在线练习网站 https://zhuanlan.zhihu.com/c_1131528588117385216 HDLBits 中文导学 2.安装并注册 Robei 软件,按照“7天学好Robei”指导书,完成练习。 ...

lyjccchong的博客 121

verilog练习:hdlbits网站系列完结!

前言 之前的文章《如何学习verilog,如何快速入门?》中提到了verilog学习,推荐了一个可以练习的网站:hdlbits网站,今天终于完结了。 题目很基本,值得训练! 记忆最深刻的是,作者设计的独热码状态机和常规的有些差异! verilog练习:hdlbits网站上的做题笔记(1) verilog练习:hdlbits网站上的做题笔记(2) verilog练习:hdlbits网站上的做题笔记(3) verilog练习:hdlbits网站上的做题笔记(4) verilog练习:hdlbits网站上的做

杰之行的博客 2787

基于HDLBits的Verilog编程练习

这里写目录标题一、门电路练习1.非门2.与门3.或非门二、组合逻辑练习1.2对1多路复用器2.全加器3.卡诺地图三、时序逻辑练习1.D 触发器2.D锁存器3.1~12的计数器 一、门电路练习 1.非门 问题:创建一个实现“非”门的模块。这个电路类似于电线,但略有不同。从电线in到电线进行连接时,out我们将实现一个逆变器(或“ NOT-gate”)而不是普通电线。使用一个assign语句。该assign声明将持续推动的逆in上线out。 问题解决代码: module top_module( input in

m0_46145395的博客 349

HDLBits Verilog基础编程练习(1)

wire 的中文可以翻译为导线,但 Verilog 中的 wire 和现实中的导线不同,wire 应该理解为一个信号,信号是有方向性的。输入端口是由模块外部的信号驱动的,而输出端口则又会驱动另一个外部信号。你也可以在其他的编辑器上完成代码的编写,然后使用上传功能,上传你的 v 文件,这样会有些繁琐,但你可以利用到编辑器的语法补全,代码片段等特性。然后封装这个1位全加器为自定义的一个子电路模块(比如名称为OneAdder),然后新建一个项目,用1位全加器串行级联方式完成一个4位全加器的设计,并进行功能测试。

qwert_qqq的博客 1301

verilog 练习题目

verilog练习用的题目,巩固自己的基础verilog知识,检测自己的掌握程度

刷完这套题,我才发现Verilog原来如此简单----HDLBits答案汇总

给大家推荐一个非常好的练习Verilog的网站,有一两百道题,基本涵盖了Verilog语法的方方面面,是一个非常好的入门学习网站。网站连接:HDLBits

孤独的单刀 2万+

STK12与Python联合仿真(一):环境搭建

STK仿真python接口,安装与测试

qq_42635142的博客 1万+

领域驱动新实践:COLA框架全解析——架构设计与实战案例解析

定义订单支付事件java代码解读复制代码} }Order定义Order类,继承并实现支付逻辑:java代码解读复制代码} }定义接口:java代码解读复制代码定义类,处理订单支付逻辑并持久化:java代码解读复制代码} }定义和处理订单支付事件:java代码解读复制代码} }java代码解读复制代码} }定义和接口及其实现:java代码解读复制代码java代码解读复制代码。

2401_89221445的博客 2676

FPGA新手必用,Verilog HDL编程学习网站推荐 —— HDLBits

FPGA新手必用,Verilog HDL编程学习网站推荐 —— HDLBits

望森FPGA的博客 3248

如何在Android上使用OpenCV进行摄像头标定

如何在Android上使用OpenCV进行摄像头标定,我们这里使用官方一个例程,其实并不难,只是网上的资料少了而已。相机标定是计算机视觉工作的前提,为了确定相机矩阵和畸变参数。

花草的博客 3444

HDLBits — Verilog Practice 在线练习

在线练习网址: https://hdlbits.01xz.net/wiki/Main_Page 一、门电路练习 1.与门 问题的解决代码: module top_module( input a, input b, output out ); assign out=a&b; endmodule 结果展示: 2.非门 问题的解决代码: module top_module( input in, output out ); assign out=~in; endm.

qq_46051625的博客 482

[V-10]ARMv8/v9-CPU Virtualization-CPU虚拟化架构简介(vCPU/vPE)

本文简要介绍了CPU虚拟化架构的基础知识。

基层架构师的分享 1267

Ubuntu环境下读取罗技G29方向盘信息

Ubuntu环境下读取罗技G29方向盘信息

工大机器人工作室 3491

在线“巡礼” HDLBits

整个网站大约180道题左右,没有标准答案,网上很多关于Verilog的参考答案,度娘就有了,我们这次是使用SystemVerilog,网上目前好像还没有答案,不过我尽量快点更新~关于HDLBits,已经不止一次推荐给大家了,我也不在唠叨了,今天之后将使用约二十几篇文章使用SV实现HDLBits。这里特意提醒了以下,如果想跟踪学习的进度或换到另一个浏览器使用,最好创建一个用户名和密码,以便可以从其他地方登录使用。点击图片上的位置就可以第一道题目练习了,前面关于很多网站题目的介绍,大家有兴趣可以看看。

OpenFPGA的博客 1827

跨时钟域传输数据——单bit和多bit信号(总结)

总结单bit和多bit信号的跨时钟域传输

qq_42135020的博客 1万+

HDLBits: 在线学习 Verilog (〇)

本系列文章将向大家推荐一个学习 Verilog 的好去处:HDLBits.HDLBits 在提供 Verilog 基础语法教程的同时,还能够在线仿真你的 Verilog 模块,将你的输出...

weixin_42905573的博客 865

间充质干细胞衰老机制与抗衰老干预策略研究

干细胞技术在再生医学领域具有广阔应用前景,其中间充质干细胞(MSCs)因其多向分化潜能和免疫调节特性备受关注。细胞衰老是影响干细胞治疗效果的共性难题,表现为增殖能力下降、端粒缩短等特征。通过表观遗传学分析发现,衰老MSCs存在DNA甲基化异常和组蛋白修饰改变;线粒体功能障碍导致ATP产量锐减,ROS累积显著增加。针对这些机制,研究者开发了包括小分子化合物筛选、CRISPR基因编辑和三维培养优化在内的多种干预策略。这些技术在组织修复、抗衰老治疗等应用场景中展现出重要价值,例如可提升心肌梗死修复效率2.3倍,缩

weixin_33502772的博客 233

通俗易懂的Harris 角点检测

点击上方“3D视觉工坊”,选择“星标”干货第一时间送达Harris 角点检测 认为特征点具有局部差异性。如何描述“特征点具有局部差异性”:以每一个点为中心,取一个窗口,窗口大小为5*5...

3D视觉工坊 1477
上一篇: 【Nios II】以SOPC开发流程完成流水灯以及串口输出实验
下一篇: 机器学习之“查准率”与“查全率”、“F1得分”的分析实例
clyrjj
博客等级 码龄7年 82粉丝 62原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址