Verilog学习笔记

最近开始学习了Verilog,之前的学习我也开始意识到记录自己的学习思路的重要性,以便以后的自己可以复盘,也是对自己一段时间学习的总结和回顾

我使用的是HDLBits进行的学习,这里附上链接HDLBits,由于是纯英语网站,所以需要配合浏览器的沉浸式翻译,其实效果也一般,也可以借助AI,不过只用作翻译,不要要求它解答

由于是个人的回顾,所以整体的思路不连贯,仅仅作个人记录

正文

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module counter10(
        //端口定义
        input                   rstn,   //复位端,低有效
        input                   clk,    //输入时钟
        output [3:0]    cnt,    //计数输出
        output                  cout);  //溢出位

        reg [3:0]               cnt_temp ;      //计数器寄存器
        always@(posedge clk or negedge rstn) begin
                if(! rstn)begin         //复位时,计时归0
                        cnt_temp        <= 4'b0 ;
                end
                else if (cnt_temp==4'd9) begin  //计时10个cycle时,计时归0
                        cnt_temp        <=4'b000;
                end
                else begin                                      //计时加1
                        cnt_temp        <= cnt_temp + 1'b1 ; 
                end
        end

        assign  cout = (cnt_temp==4'd9) ;       //输出周期位
        assign  cnt  = cnt_temp ;                       //输出实时计时器

endmodule

这是从菜鸟教程里随便拿的一个代码

Licensed under CC BY-NC-SA 4.0
七弦绕明宫,知音且闻音,写作智音读作知音
使用 Hugo 构建
主题 StackJimmy 设计