计数器 buaa Verilog 练习1 计组

`timescale 1ns / 1ps
//
// Company: 
// Engineer: 
// 
// Create Date:    15:30:43 10/07/2021 
// Design Name: 
// Module Name:    code 
// Project Name: 
// Target Devices: 
// Tool versions: 
// Description: 
//
// Dependencies: 
//
// Revision: 
// Revision 0.01 - File Created
// Additional Comments: 
//
//
module code(
    input Clk,
    input Reset,
    input Slt,
    input En,
    output reg [63:0] Output0,
    output reg [63:0] Output1
    );

    //integer count1 = 0; // q1
	 reg [1:0] count1 = 2'b01; //assign 1, not 0


    // sequential logic
    always @(posedge Clk) begin
        if (Reset == 1'b1) begin
            Output0 <= 64'h0000_0000; // match the identifier's bit width
            Output1 <= 64'h0000_0000;
				count1 <= 2'b01; // reset will also reset the valid time Periodd
            //count1 <= 0; // why not
        end 
        else if (En == 1'b1) begin
            if (Slt == 1'b0) begin
                Output0 <= Output0 + 64'h0000_0001; // match the bit width
                Output1 <= Output1;            
            end
            else begin
                count1 <= count1 + 2'b01;
                if (count1 == 2'b00) begin
                    Output0 <= Output0;
                    Output1 <= Output1 + 64'h0000_0001;
                end
                else begin
                    Output0 <= Output0;
                    Output1 <= Output1;
                end
            end
        end
        else begin
            Output0 <= Output0;
            Output1 <= Output1;
        end
    end


endmodule

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值