![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
HDLBits
文章平均质量分 56
bbbman7
这个作者很懒,什么都没留下…
展开
-
HDLBITS中的边沿检测
1.上升沿检测用一个寄存器来储存上个周期的输入,时钟周期到来时将寄存器输出位q。01时就为上升沿。module top_module ( input clk, input [7:0] in, output [7:0] pedge); reg [7:0] q; always@(posedge clk) begin q<=in; pedge<=~q∈ ...原创 2022-01-27 17:30:07 · 404 阅读 · 0 评论 -
Count clock
解析:需要实现一个时钟。分别建立一个60计数和12计数的BCD时钟.代码:module top_module( input clk, input reset, input ena, output pm, output [7:0] hh, output [7:0] mm, output [7:0] ss); reg[2:0] enable; //秒分时 使能 assign enable[0] = ena; ...原创 2022-01-24 11:25:52 · 370 阅读 · 0 评论 -
HDLBits_Fsm hdlc
序列检测:5个1,dsic输出1;6个1,flag输出1;7个或以上,err输出1。这题比较简单,直接附代码。module top_module( input clk, input reset, // Synchronous reset input in, output disc, output flag, output err); localparam none=0,s1=1,s2=2,s3=3,s4=4,s5=5,...原创 2021-12-15 11:31:33 · 134 阅读 · 0 评论 -
HDLBits:Serial Receiver系列问题
1.Serial receiver解析:module top_module( input clk, input in, input reset, // Synchronous reset output done); localparam idle=0,start=1,data=2,stop=3,error=4; reg[2:0] state,next; reg[3:0] cnt;//next always@(*...原创 2021-12-15 10:39:41 · 219 阅读 · 0 评论 -
HDLBits-Lemmings4
解析:Lemmings系列的最后一题。这题的要求是增加了一个死亡的判断,当向下坠落超过20个时钟周期,便会死亡,此时所有输出为0。需要增加一个计数器,最开始我把计数器和状态时序写在一个always块内,功能不知道为啥无法实现,输出没法置0,后面单独给计数器写个always块后可以实现。代码:module top_module( input clk, input areset, // Freshly brainwashed Lemmings walk left. ...原创 2021-12-13 14:53:06 · 211 阅读 · 0 评论 -
HDLBits_Lemmings3
解析:和Lemmings2类似,增了个挖地的功能,dig为0时,会进行挖地,一直挖到ground为0。思路类似,将左右挖地分开。代码:module top_module( input clk, input areset, // Freshly brainwashed Lemmings walk left. input bump_left, input bump_right, input ground, input dig, outp...原创 2021-12-10 16:07:47 · 208 阅读 · 0 评论 -
HDLBits--Lemmings2
题目:解析: 在Lemmings1中增加了一个ground信号,ground为0时,小人会掉下去,ground为1时,小人会恢复到掉下去之前的向左向右状态。所以想到把掉下去分成,从向左掉下去和从向右掉下去。代码如下:module top_module( input clk, input areset, // Freshly brainwashed Lemmings walk left. input bump_left, input bump_right,...原创 2021-12-08 14:38:45 · 213 阅读 · 0 评论 -
Exams/ece241 2013 q4:水位问题
module top_module ( input clk, input reset, input [3:1] s, output fr3, output fr2, output fr1, output dfr);parameter A=3'd0,B0=3'd1,B1=3'd2,C0=3'd3,C1=3'd4,D=3'd5;//6种状态,B0,B1分别代表从低水位往高水位和从高水外往低水位。 reg [2:0] state; ...原创 2021-12-08 09:55:11 · 252 阅读 · 0 评论 -
HDLBits-Simple FSM 3(asynhronous reset)
题目:解析:没什么内容,一个简单的状态机module top_module( input clk, input in, input areset, output out); // parameter A=0,B=1,C=2,D=3; reg[1:0] state,next_state; always@(*) begin case(state) ...原创 2021-12-07 15:57:35 · 127 阅读 · 0 评论