HDLbits答案刷题记录1

verilog学习 | HDLBits:在线学习答案 HDLBits 在提供 Verilog 基础语法教程的同时,还能够在线仿真 Verilog 模块。 阅读详情

3.1.1 Basic gates

3.1.1.8 Truth table

  • 组合逻辑电路中输出仅仅是其输入的函数(在数学意义上)
module top_module( 
    input x3,
    input x2,
    input x1,  // three inputs
    output f   // one output
);
    assign f = (x3 & x1) | (x2 & x1) | ((~x3) & x2);
endmodule

3.1.1.9 Two-bit equality

module top_module (
	 input [1:0] A,
	 input [1:0] B,
	 output z
); 
    assign z = (A == B) ? 1 : 0;
endmodule

3.1.1.10 Sample circuit A

module top_module (input x, input y, output z);
    assign z = (x ^ y) & x;
endmodule

3.1.1.11 Sample circuit B

module top_module ( input x, input y, output z );
	assign z = x ~^ y;
endmodule

3.1.1.12 Combine circuit A and B

module top_module (input x, input y, output z);
	wire tmp1,tmp2;
    assign tmp1 = ((x ^ y) & x) | (x ~^ y);
    assign tmp2 = ((x ^ y) & x) & (x ~^ y);
    assign z = tmp1 ^ tmp2;
endmodule

3.1.1.13 Ring and vibrate?

  • 当有来电时,必须打开铃声(ringer = 1)或震动(motor = 1),但二者不会同时打开
  • 如果是震动模式(vibrate_mode = 1),打开震动,关闭铃声
module top_module (
    input ring,
    input vibrate_mode,
    output ringer,       // Make sound
    output motor         // Vibrate
);
	assign ringer = ring & ~vibrate_mode;
    assign motor = ring & vibrate_mode;
endmodule

3.1.1.14 Thermostat

  • 两种模式:制热(mode = 1),制冷(mode = 0)
  • 当 too_cold = 1时,打开制热,关闭制冷;
  • 当 too_hot = 1时,打开制冷,关闭制热;
  • 制热和制冷有一个打开时,打开风扇(fan = 1)
  • 制冷和制热都未打开,用户也可通过 fan_on = 1打开风扇
module top_module (
    input too_cold,
    input too_hot,
    input mode,
    input fan_on,
    output heater,
    output aircon,
    output fan
); 
    assign heater = mode & too_cold;
    assign aircon = ~mode & too_hot;
    assign fan = fan_on | heater | aircon;

endmodule

3.1.1.15 3-bit population count

module top_module( 
    input [2:0] in,
    output [1:0] out );
    
	integer i;
    reg [2 :0]  tmp;
    
    always @ (*) begin
        tmp = 0;
        for (i = 0; i < 3; i ++) begin
            if(in[i])
                tmp = tmp + 1;
        end
    end
	assign out = tmp;
endmodule

3.1.1.16 Gates and vectors

  • out_both:与左侧(更高位)相邻的数都为1,输出1,且最高位左侧不存在数
  • out_any:与右侧(更低位)相邻的数有一个为1,输出为1,最低位右侧不存在数
  • out_different:与左侧(更高位)相邻的数不同,输出为1,最高位左侧为[0]位
module top_module( 
    input [3:0] in,
    output [2:0] out_both,
    output [3:1] out_any,
    output [3:0] out_different );
	
    assign out_both = in[3:1] & in [2:0];
    assign out_any = in[2:0] | in[3:1];
    assign out_different = {in[0],in[3:1]} ^ in[3:0];
    
endmodule

3.1.1.17 Even longer vectors

module top_module( 
    input [99:0] in,
    output [98:0] out_both,
    output [99:1] out_any,
    output [99:0] out_different );

    assign out_both = in[99:1] & in [98:0];
    assign out_any = in[98:0] | in[99:1];
    assign out_different = {in[0],in[99:1]} ^ in[99:0];
endmodule
HDLBits全部解答 HDLbits全部解答。 有始有终,断断续续用了一个月左右的时间才完成。希望可以坚持学习,持续进步。 阅读详情

相关推荐

HDLBits答案合集(一)

本文为本人HDL刷题代码,如有问题请及时联系 文章目录前言一、Getting Started1.1 Step one1.2 Zero二、Verilog language2.1 Basics2.1.1 wire2.1.2 Wire42.1.3 Notgate2.1.4 Andgate2.1.5 Norgate2.1.6 Xnorgate2.1.7 Wire decl2.1.8 74582.2 vectors2.2.1 vector02.2.2 Vector12.2.3 Vector22.2.4 Vecto.

南边的柴柴的博客 1万+

Verilog创建子模块并调用

创建子模块并调用 module top_module( input x, input y, output z); wire o1, o2, o3, o4; A ia1 (x, y, o1); B ib1 (x, y, o2); A ia2 (x, y, o3); B ib2 (x, y, o4); assign z = (o1 | o2) ^ (o3 & o4); // Or you could simplify the circuit including the s

onesway2018的博客 6007

HDLBits答案汇总

前言 该博客为本人做HDLBits习题时的心得记录总结,欢迎大家一起交流进步。 HDLBits网站链接 Verilog Language Basics Vectors Modules:Hierarchy Procedures More Verilog Features Circuits Combinational Logic Basic gates Multiplexers Arithmetic Circuits Karnaugh Map to Circuit Sequential Logic Latche

谦豫 9万+

【HDLBits 刷题】所有答案直达链接汇总

以下为HDLBits全部答案,有些题的解法不唯一,我的也许不是最优解,欢迎提出更好的想法,HDLBits总的来说比较适合初学者,对于有一定基础希望进阶,或者是想要了解关于校招的笔试题相关题目,建议可以刷牛客网上的题,里面的试题包括基础和进阶以及企业校招真题。以下为牛客网刷题网站直达链接。☞牛客网刷题直达链接涵盖基础、进阶真题以及各类企业真题。

记录学习历程 3万+

HDLBits刷题全记录(一)

HDLBits刷题记录 ​ HDLBits是一个在线编程网站,可以直接在网站上编辑verilog代码,并进行综合仿真,查看波形图等,非常适合入门学习。 —— HDLBits的官网 ​ 注:可以配合B站的入门视频进行学习 —— Verilog硬件描述语言 西安电子科技大学 蔡觉平等主讲 文章目录HDLBits刷题记录1. Getting StartedGetting StartedOutput Zero2. Verilog LanguageBasicsSimple wireFour wireInverterA

weixin_39677048的博客 1848

别光刷题了!用HDLBits+EDA Playground玩转Verilog在线仿真与调试

本文介绍了如何利用HDLBits和EDA Playground构建Verilog高效学习闭环,从基础练习到工程实践。HDLBits提供即时反馈和渐进式题目,而EDA Playground则支持波形分析和自定义测试平台,帮助开发者提升硬件设计能力。通过六步法和模块化验证体系,实现从解题到工程实践的过渡。

weixin_30329623的博客 720

【HDLBits 刷题 1】Verilog Language(1)Basics 部分

HDLBits作为Verilog的刷题网站,非常适合初学者拿来练习,不仅可以学到基础的语法,还可以让自己写出的代码更直观,直接映射到电路中,因此在这段时间每周会抽出一点时间来把这个网站的题目刷一遍,用博客的方式记录自己的刷图经历。由于前面几节题目比较基础,所以只展示结果代码和仿真波形,具体的细节就不再赘述。............

记录学习历程 5097

HDL bits 网站刷题答案

这是HDL bits 刷题网站上的答案 大家可以参考下,里面的答案很全面,仅供参考,想要提升还是需要自己写,而不是嫖

HDLBits刷题笔记和一些拓展知识(十一)

HDLBits刷题笔记(十一),完结撒花!

m0_58679714的博客 911

别再只用线性回归了!用sklearn的核岭回归搞定非线性数据(附RBF核调参实战)

本文详细介绍了如何使用sklearn的核岭回归处理非线性数据,特别是RBF核的应用与调参实战。通过网格搜索找到最佳参数组合,核岭回归能有效捕捉数据中的复杂波动,显著提升模型性能。适合需要解决非线性问题的数据科学家和机器学习工程师。

weixin_34246529的博客 338

微信小游戏CE修改实战:从入门到精通(附防作弊思路)

本文深入探讨微信小游戏的安全攻防实战,重点分析CE修改、反编译和重打包等安全风险。通过详细的内存修改案例和代码保护方案对比,提供从客户端到服务端的全方位防护策略,帮助开发者构建有效的防作弊体系。

m2n3b4v5c6的博客 1151

HDLBits刷题笔记和一些拓展知识(八)

HDLBits刷题笔记和一些拓展知识(八),截止到Circuits下的More Circuits部分。

m0_58679714的博客 1528

STM32F103C8T6驱动DM542步进电机:从CubeMX配置到按键控制的全流程避坑指南

本文详细介绍了如何使用STM32F103C8T6通过CubeMX配置驱动DM542步进电机的全流程,包括PWM频率计算、GPIO模式选择及按键控制实现。重点解决了常见硬件连接错误、PWM参数配置及加减速算法优化,帮助开发者快速搭建稳定的电机控制系统。

weixin_42741930的博客 308

HDLBits刷题笔记和一些拓展知识(五)

HDLBits刷题笔记(五),截止到Circuits下的Basic Gates部分。

m0_58679714的博客 1427

基于STM32设计的老人监护系统(OneNet)_118

该项目是基于STM32设计的老人监护系统。本系统可以通过脉搏心率传感器,体温传感器检测老人的脉搏状态,体温状态,把老人的数据状态在STM32单片机内部进行处理,然后通过GSM模块上传到OneNet云平台,在通过可视化界面显示出来,这样可以让子女随时随地了解到老人现在的身体情况,以便对老人的突发情况能够做出及时的预防和处理。而且如今,随着老人年纪不断的增长,身体体质不断的衰弱,在上楼梯或者走斜坡的时候很容易会发生摔倒或跌倒,如果不及时的接收到治疗,很可能会造成很严重的后果。

7456

ANSYS——模态分析的理论基础

ANSYS模态分析理论基础

python_AI_fans的博客 9095

HDLBits刷题笔记和一些拓展知识(四)

HDLBits刷题笔记(四),截止到More Verilog Features

m0_58679714的博客 901

【CANoe】CANoe的 I/O功能-以VN1640A为例

Canoe的 I/O功能-以VN1640A为例

星Yeah 的博客 7883

HDLBits刷题笔记与一些拓展知识(一)

HDLBits刷题笔记(一),截止到Vecters部分。

m0_58679714的博客 1022

飞牛NAS 0day漏洞导致断网?完整的排查修复方案来了(含一键检测修复工具)

家里网络莫名断网,折腾十来天才发现是NAS被0day漏洞利用了?🔍 本文详细记录了从发现问题到最终解决的全过程,包括如何自查系统是否被入侵、使用检测脚本和专杀脚本进行修复,以及如何通过端口管理、访问控制、监控预警等措施加固系统安全 🔒,帮助遇到同样问题的用户快速排查和解决NAS安全风险 ✅

XiaoqiangClub的博客 5521

CTR-GCN 论文解读

提出了一种信道拓扑优化图卷积,该卷积可以动态有效地对信道拓扑进行建模。共享拓扑是一个参数化的邻接矩阵,作为所有通道的拓扑先验,并提供顶点之间的一般相关性。通过使用特定于通道的相关性细化共享拓扑,CTR-GC 获得了通道拓扑。

一杯水果茶!足矣~ 3089

HDLBits刷题笔记和一些拓展知识(六)

HDLBits刷题笔记和一些拓展知识(六),截止到Karnaugh Map to Circuit。

m0_58679714的博客 1198

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

HDLBits刷题笔记和一些拓展知识(七)

HDLBits刷题笔记(七),截止到Sequential Logic下的Latches and Flip-Flops部分

m0_58679714的博客 1359

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

HDLBits刷题记录——FSM Lemmings4

导言 HDLBits状态机章节Lemmings1~4是有关于旅鼠的一个系列,解前面3题时没遇到什么阻碍,第4题耽误了一些时间。 第一处阻碍是何时进入splatter状态,即计数器何时开始计数:是next_state为下落还是current_state为下落时开始计数? 第二处阻碍是本应该进入splatter状态而进入了left状态,波形上表现为:输出不能都保持为0。 原代码 module top_module( input clk, input areset, // Freshly

JJJJJJJerry的博客 1714

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

HDLBits刷题记录——Sequential circuit 10

导言 根据波形推测电路的最后一题,难度稍微大些,但很有意思。首先得承认自己没做出来,看了其他博主的答案,才明白是怎么回事。这也验证了我先前的感受,电路设计的正向思路应该是功能>电路>代码>波形,逆向过程不见得好理解。 波形图(仅从波形变化,不易看出逻辑关系。从答案看,其中蕴含了奇偶校验原理。) 代码 module top_module ( input clk, input a, input b, output q, output state

JJJJJJJerry的博客 319

【HDLBits答案及思路(仅供参考,1 Getting Started与2 Verilog Language)】

HDLBits学习笔记,答案分享

qq_45141192的博客 9207
下一篇: HDLbits 刷题答案 3.1.2 Multiplexers
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值