Verilog学习-05

 考研上微电子入了材料坑,开始自学verilog

此文很多也是在其他优秀的博文中复制过来

(在此也非常感谢大家在网上分享的笔记) 

仅为方便记录自己学习的笔记

习题链接:HDLBits

三,电路

3.3,大规模电路

1000计数器

module top_module (
    input clk,
    input reset,
    output [9:0] q);

    always@(posedge	clk)begin
        if(reset==1)
            q	<=	0;
        else	begin
            if(q	==	10'b1111100111)
           	 	q	<=	0;
        	else
            	q	<=	q+1;
        end
    end

endmodule

4位移位寄存器和下行计数器

Build a four-bit shift register that also acts as a down counter. Data is shifted in most-significant-bit first when shift_ena is 1. The number currently in the shift register is decremented when count_ena is 1. Since the full system doesn't ever use shift_ena and count_ena together, it does not matter what your circuit does if both control inputs are 1 (This mainly means that it doesn't matter which case gets higher priority).

module top_module (
    input clk,
    input shift_ena,
    input count_ena,
    input data,
    output [3:0] q);
    
    always@(posedge	clk)begin
        if(shift_ena==1)
            q	<=	{q[2:0],data};
        else	if(count_ena==1)
            q	<=	q-1;
    end
            
endmodule
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值