sp.v

来自「cup 的设计源代码」· Verilog 代码 · 共 45 行

V
45
字号
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer:
//
// Create Date:    19:54:15 10/08/08
// Design Name:    
// Module Name:    SP
// Project Name:   
// Target Device:  
// Tool versions:  
// Description:
//
// Dependencies:
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
////////////////////////////////////////////////////////////////////////////////
module SP(clk, rst, inc_enable, dec_enable, SP_out);
    parameter width=8;

    input clk;
    input rst;
    input inc_enable;
    input dec_enable;
    output[width-1:0] SP_out;
    
    reg[width-1:0] SP_out;

    always@(posedge clk or negedge rst)
    begin
        if(~rst)
            SP_out<='b11111111;
        else if(dec_enable)
            SP_out<=SP_out-1;
        else if(inc_enable)
            SP_out<=SP_out+1;
        else
            SP_out<=SP_out;
    end

endmodule

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?