【Verilog刷题篇】硬件工程师进阶1|序列检测

2025-04-27阅读 0热度 0
硬件

前言硬件工程师近年来也开始慢慢吃香,校招进大厂年薪总包不下30-40w的人数一大把!而且大厂人数并没有饱和! - 本期是【Verilog刷题篇】硬件工程师进阶1|序列检测,有不懂的地方可以评论进行讨论!推荐给大家一款刷题、面试的神器,我也是用这一款神器进行学习Verilog硬件代码的!~链接如下:刷题面试神器跳转链接也欢迎大家去牛客查看硬件工程师招聘职位的各类资料,并进行提前批投递面试!小白新手可以通过该神器进行日常的刷题、看大厂面经、学习计算机基础知识、与大牛面对面沟通~ 刷题的图片已经放在下面了~Q1:输入序列连续的序列检测

问题描述:请编写一个序列检测模块,检测输入信号a是否满足01110001序列,当信号满足该序列,给出指示信号match。

模块的接口信号图如下:

【Verilog刷题篇】硬件工程师进阶1|序列检测

模块的时序图如下:

【Verilog刷题篇】硬件工程师进阶1|序列检测

输入描述: clk:系统时钟信号 rst_n:异步复位信号,低电平有效 a:单比特信号,待检测的数据

输出描述: match:当输入信号a满足目标序列,该信号为1,其余时刻该信号为0

案例代码:

代码语言:javascript代码运行次数:0运行复制
`timescale 1ns/1nsmodule sequence_detect(input clk,input rst_n,input a,output reg match);    parameter zero = 4'd0;       parameter one = 4'd1;       parameter two = 4'd2;       parameter three = 4'd3;       parameter four = 4'd4;       parameter five = 4'd5;       parameter six = 4'd6;       parameter seven = 4'd7;     parameter    eight=4'd8;       reg [3:0] cu_st;    always@(posedge clk or negedge rst_n)        begin            if(!rst_n)begin                cu_stQ2: 含有无关项的序列检测<p>问题描述:请编写一个序列检测模块,检测输入信号a是否满足011XXX110序列(长度为9位数据,前三位是011,后三位是110,中间三位不做要求),当信号满足该序列,给出指示信号match。</p><p>程序的接口信号图如下: </p><figure class=""><img src="https://img.php.cn/upload/article/001/503/042/174564543852756.jpg" alt="【Verilog刷题篇】硬件工程师进阶1|序列检测"></figure><p> 程序的功能时序图如下: </p><figure class=""><img src="https://img.php.cn/upload/article/001/503/042/174564543899991.jpg" alt="【Verilog刷题篇】硬件工程师进阶1|序列检测"></figure><p>输入描述: clk:系统时钟信号 rst_n:异步复位信号,低电平有效 a:单比特信号,待检测的数据</p><p>输出描述: match:当输入信号a满足目标序列,该信号为1,其余时刻该信号为0</p><p>案例代码:</p>代码语言:javascript<i class="icon-code"></i>代码运行次数:<!-- -->0<svg xmlns="http://www.w3.org/2000/svg" width="16"    style="max-width:90%" viewbox="0 0 16 16" fill="none"><path d="M6.66666 10.9999L10.6667 7.99992L6.66666 4.99992V10.9999ZM7.99999 1.33325C4.31999 1.33325 1.33333 4.31992 1.33333 7.99992C1.33333 11.6799 4.31999 14.6666 7.99999 14.6666C11.68 14.6666 14.6667 11.6799 14.6667 7.99992C14.6667 4.31992 11.68 1.33325 7.99999 1.33325ZM7.99999 13.3333C5.05999 13.3333 2.66666 10.9399 2.66666 7.99992C2.66666 5.05992 5.05999 2.66659 7.99999 2.66659C10.94 2.66659 13.3333 5.05992 13.3333 7.99992C13.3333 10.9399 10.94 13.3333 7.99999 13.3333Z" fill="currentcolor"></path></svg>运行<svg width="16" height="16" viewbox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M4.5 15.5V3.5H14.5V15.5H4.5ZM12.5 5.5H6.5V13.5H12.5V5.5ZM9.5 2.5H3.5V12.5H1.5V0.5H11.5V2.5H9.5Z" fill="currentcolor"></path></svg>复制<pre class="prism-token token line-numbers javascript">`timescale 1ns/1nsmodule sequence_detect(input clk,input rst_n,input a,output reg match);    reg [8:0] a_temp;    always@(posedge clk or negedge rst_n)        begin            if(!rst_n)                a_tempQ3:不重叠序列检测<p>问题描述:请编写一个序列检测模块,检测输入信号(a)是否满足011100序列, 要求以每六个输入为一组,不检测重复序列,例如第一位数据不符合,则不考虑后五位。一直到第七位数据即下一组信号的第一位开始检测。当信号满足该序列,给出指示信号match。当不满足时给出指示信号not_match。</p><p>模块的接口信号图如下: </p><figure class=""><img src="https://img.php.cn/upload/article/001/503/042/174564543816047.jpg" alt="【Verilog刷题篇】硬件工程师进阶1|序列检测"></figure><p> 模块的时序图如下: </p><figure class=""><img src="https://img.php.cn/upload/article/001/503/042/174564543837289.jpg" alt="【Verilog刷题篇】硬件工程师进阶1|序列检测"></figure><p>输入描述: clk:系统时钟信号 rst_n:异步复位信号,低电平有效 a:单比特信号,待检测的数据</p><p>输出描述: match:当输入信号a满足目标序列,该信号为1,其余时刻该信号为0 not_match:当输入信号a不满足目标序列,该信号为1,其余时刻该信号为0</p><p>案例代码:</p>代码语言:javascript<i class="icon-code"></i>代码运行次数:<!-- -->0<svg xmlns="http://www.w3.org/2000/svg" width="16"    style="max-width:90%" viewbox="0 0 16 16" fill="none"><path d="M6.66666 10.9999L10.6667 7.99992L6.66666 4.99992V10.9999ZM7.99999 1.33325C4.31999 1.33325 1.33333 4.31992 1.33333 7.99992C1.33333 11.6799 4.31999 14.6666 7.99999 14.6666C11.68 14.6666 14.6667 11.6799 14.6667 7.99992C14.6667 4.31992 11.68 1.33325 7.99999 1.33325ZM7.99999 13.3333C5.05999 13.3333 2.66666 10.9399 2.66666 7.99992C2.66666 5.05992 5.05999 2.66659 7.99999 2.66659C10.94 2.66659 13.3333 5.05992 13.3333 7.99992C13.3333 10.9399 10.94 13.3333 7.99999 13.3333Z" fill="currentcolor"></path></svg>运行<svg width="16" height="16" viewbox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M4.5 15.5V3.5H14.5V15.5H4.5ZM12.5 5.5H6.5V13.5H12.5V5.5ZM9.5 2.5H3.5V12.5H1.5V0.5H11.5V2.5H9.5Z" fill="currentcolor"></path></svg>复制<pre class="prism-token token line-numbers javascript">`timescale 1ns/1nsmodule sequence_detect(input clk,input rst_n,input data,output reg match,output reg not_match);reg [5:0]cs;reg [5:0]ns;reg [5:0]count;always@(posedge clk or negedge rst_n)   if(!rst_n)   count=5)     countQ4:输入序列不连续的序列检测<p>问题描述:请编写一个序列检测模块,输入信号端口为data,表示数据有效的指示信号端口为data_valid。当data_valid信号为高时,表示此刻的输入信号data有效,参与序列检测;当data_valid为低时,data无效,抛弃该时刻的输入。当输入序列的有效信号满足0110时,拉高序列匹配信号match。</p><p>模块的接口信号图如下: </p><figure class=""><img src="https://img.php.cn/upload/article/001/503/042/174564543869659.jpg" alt="【Verilog刷题篇】硬件工程师进阶1|序列检测"></figure><p> 模块的时序图如下: </p><figure class=""><img src="https://img.php.cn/upload/article/001/503/042/174564543972228.jpg" alt="【Verilog刷题篇】硬件工程师进阶1|序列检测"></figure><p>输入描述: clk:系统时钟信号 rst_n:异步复位信号,低电平有效 data:单比特信号,待检测的数据 data_valid:输入信号有效标志,当该信号为1时,表示输入信号有效</p><p>输出描述: match:当输入信号data满足目标序列,该信号为1,其余时刻该信号为0</p><p>案例代码:</p>代码语言:javascript<i class="icon-code"></i>代码运行次数:<!-- -->0<svg xmlns="http://www.w3.org/2000/svg" width="16"    style="max-width:90%" viewbox="0 0 16 16" fill="none"><path d="M6.66666 10.9999L10.6667 7.99992L6.66666 4.99992V10.9999ZM7.99999 1.33325C4.31999 1.33325 1.33333 4.31992 1.33333 7.99992C1.33333 11.6799 4.31999 14.6666 7.99999 14.6666C11.68 14.6666 14.6667 11.6799 14.6667 7.99992C14.6667 4.31992 11.68 1.33325 7.99999 1.33325ZM7.99999 13.3333C5.05999 13.3333 2.66666 10.9399 2.66666 7.99992C2.66666 5.05992 5.05999 2.66659 7.99999 2.66659C10.94 2.66659 13.3333 5.05992 13.3333 7.99992C13.3333 10.9399 10.94 13.3333 7.99999 13.3333Z" fill="currentcolor"></path></svg>运行<svg width="16" height="16" viewbox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M4.5 15.5V3.5H14.5V15.5H4.5ZM12.5 5.5H6.5V13.5H12.5V5.5ZM9.5 2.5H3.5V12.5H1.5V0.5H11.5V2.5H9.5Z" fill="currentcolor"></path></svg>复制<pre class="prism-token token line-numbers javascript">`timescale 1ns/1nsmodule sequence_detect(input clk,input rst_n,input data,input data_valid,output reg match);    parameter [3:0] data_ref = 4'b0110;    reg [3:0] data_in;    always @(posedge clk or negedge rst_n)        if(!rst_n) data_in Q5:信号发生器<p>问题描述:请编写一个信号发生器模块,根据波形选择信号wave_choise发出相应的波形:wave_choice=0时,发出方波信号;wave_choice=1时,发出锯齿波信号;wave_choice=2时,发出三角波信号。</p><p>模块的接口信号图如下: </p><figure class=""><img src="https://img.php.cn/upload/article/001/503/042/174564543928739.jpg" alt="【Verilog刷题篇】硬件工程师进阶1|序列检测"></figure><p> 模块的时序图如下: </p><figure class=""><img src="https://img.php.cn/upload/article/001/503/042/174564543919699.jpg" alt="【Verilog刷题篇】硬件工程师进阶1|序列检测"></figure><p>输入描述: clk:系统时钟信号 rst_n:异步复位信号,低电平有效 wave_choise:2比特位宽的信号,根据该信号的取值不同,输出不同的波形信号</p><p>输出描述: wave:5比特位宽的信号,根据wave_choise的值,输出不同波形的信号</p><p>案例代码:</p>代码语言:javascript<i class="icon-code"></i>代码运行次数:<!-- -->0<svg xmlns="http://www.w3.org/2000/svg" width="16"    style="max-width:90%" viewbox="0 0 16 16" fill="none"><path d="M6.66666 10.9999L10.6667 7.99992L6.66666 4.99992V10.9999ZM7.99999 1.33325C4.31999 1.33325 1.33333 4.31992 1.33333 7.99992C1.33333 11.6799 4.31999 14.6666 7.99999 14.6666C11.68 14.6666 14.6667 11.6799 14.6667 7.99992C14.6667 4.31992 11.68 1.33325 7.99999 1.33325ZM7.99999 13.3333C5.05999 13.3333 2.66666 10.9399 2.66666 7.99992C2.66666 5.05992 5.05999 2.66659 7.99999 2.66659C10.94 2.66659 13.3333 5.05992 13.3333 7.99992C13.3333 10.9399 10.94 13.3333 7.99999 13.3333Z" fill="currentcolor"></path></svg>运行<svg width="16" height="16" viewbox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M4.5 15.5V3.5H14.5V15.5H4.5ZM12.5 5.5H6.5V13.5H12.5V5.5ZM9.5 2.5H3.5V12.5H1.5V0.5H11.5V2.5H9.5Z" fill="currentcolor"></path></svg>复制<pre class="prism-token token line-numbers javascript">`timescale 1ns/1nsmodule signal_generator(input clk,input rst_n,input [1:0] wave_choise,output reg [4:0]wave);    reg [4:0] cnt;    reg k;    always @(posedge clk or negedge rst_n) begin        if(!rst_n) begin            cnt =5'd9 &amp;&amp; cnt= 5'd20)                        wave  5'd0)                        wave 总结:小白跟大牛都在用的平台硬件工程师近年来也开始慢慢吃香,校招进大厂年薪总包不下30-40w的人数一大把!而且大厂人数并没有饱和! - 本期是【Verilog刷题篇】硬件工程师从0到入门3|组合逻辑复习+时序逻辑入门,有不懂的地方可以评论进行讨论!
登录后复制
免责声明

本网站新闻资讯均来自公开渠道,力求准确但不保证绝对无误,内容观点仅代表作者本人,与本站无关。若涉及侵权,请联系我们处理。本站保留对声明的修改权,最终解释权归本站所有。

相关阅读

更多
欢迎回来 登录或注册后,可保存提示词和历史记录
登录后可同步收藏、历史记录和常用模板
注册即表示同意服务条款与隐私政策