📄 buzzer.v
字号:
////////////////////////////////////////////////////////////////////////////////
// ____ _ __ ___ //
// / __ \(_)____/ / / (_)____ RICHIC CONFIDENTIAL PROPRIETARY NOTE //
// / /_/ / / ___/ /_/ / / ___/ This source codes contains information//
// / _, _/ / /__/ __ / / /__ confidential and proprietary to RicHic//
// /_/ |_/_/\___/_/ /_/_/\___/ Inc. It shall not be reproduced in //
// whole or in part or transferred to //
// other documents, or disclosed to third parties, or used for any purpose //
// other than that for which it was obtained, without the prior written //
// consent of RicHic Inc. //
// //
// (c) 2003, 2004, 2005 RicHic Inc. //
// All rights reserved //
// ************************************************************************* //
// //
// Email: fpga_ic@yahoo.com.cn; fpga.ic@gmail.com; mail007@richic.com //
// http://www.richic.com //
// //
////////////////////////////////////////////////////////////////////////////////
// 本设计在RicHic开发系统中验证通过
//
module buzzer(
clk,
rst_n,
led,
sp
);
output sp;
output [2:0] led;
input clk;
input rst_n; // synthesis attribute clock_buffer of rst_n is ibufg;
reg [27:0] cnt;
always @ ( posedge clk or negedge rst_n)
if (!rst_n)
cnt <= 28'd0;
else
cnt <= cnt + 1;
reg sp;
always @ (cnt[24:23])
case (cnt[24:23])
2'b00: sp = cnt[20];
2'b01: sp = cnt[18];
2'b11: sp = cnt[16];
2'b11: sp = cnt[14];
default:sp = 1'b0;
endcase
reg [1:0] led_cnt;
always @ ( posedge cnt[24] or negedge rst_n )
if (!rst_n)
led_cnt <= 2'b00;
else if (led_cnt == 2'b10)
led_cnt <= 2'b00;
else
led_cnt <= led_cnt + 1'b1;
assign led[0] = led_cnt == 2'b00;
assign led[1] = led_cnt == 2'b01;
assign led[2] = led_cnt == 2'b10;
endmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -