Verilog | HDL 音乐流水灯(代码类)

2024-06-05 19:58
文章标签 代码 音乐 流水 verilog hdl

本文主要是介绍Verilog | HDL 音乐流水灯(代码类),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

博主github:https://github.com/MichaelBeechan
博主CSDN:https://blog.csdn.net/u011344545

module beyond(clk,beep,led);
input clk;
output beep;
output [7:0]led;
reg beep;
reg [22:0]i;
reg clk_4hz;
reg [7:0]led;
reg [16:0] count,div_num;//
reg [6:0] music;//just for a test;
always @(posedge clk)//4hz
begin
if(i==23'h47868c)
begin
i<=0;
clk_4hz=~clk_4hz;
end
else
i=i+1'b1;
end
always @(posedge clk_4hz)
begin
if(music==7'd90)notice
music<=0;
else
music<=music+1'b1;
end
always @(posedge clk)
begin
if(count==div_num)
begin
count<=0;
beep=~beep;
end
else
count<=count+1'b1;
end
parameter 
L1=17'h1754e,
L2=17'h14c81,
L3=17'h1284a,
L4=17'h117A8,
L5=17'h14e70,
L6=17'h0ddf2,
L7=17'h0c5ba,
M1=17'h0ba9e,
M2=17'h0a648,
M3=17'h0941f,
M4=17'h08bcf,
M5=17'h07c90,
M6=17'h06ef9,
M7=17'h062dd,
H1=17'h05d68,
H2=17'h05322,
H3=17'h04a11,
H4=17'h045e9,
H5=17'h3e48,
H6=17'h377d,
H7=17'h316f;
always @(posedge clk_4hz)
begin
case(music)
7'd0 : div_num=M7;
7'd1 : div_num=M7;
7'd2 : div_num=H1;
7'd3 : div_num=H1;
7'd4 : div_num=H2;
7'd5 : div_num=H2;
7'd6 : div_num=H2;
7'd7 : div_num=H3;
7'd8 : div_num=H3;
7'd9 : div_num=H3;
7'd10 : div_num=H3;
7'd11 : div_num=H2;
7'd12 : div_num=H2;
7'd13 : div_num=H2;
7'd14 : div_num=H2;
7'd15 : div_num=H2;
7'd16 : div_num=H1;
7'd17 : div_num=M7;
7'd18 : div_num=M5;
7'd19 : div_num=M6;
7'd20 : div_num=M6;
7'd21 : div_num=M6;
7'd22 : div_num=M3;
7'd23 : div_num=M2;
7'd24 : div_num=M3;
7'd25 : div_num=M3;
7'd26 : div_num=M3;
7'd27 : div_num=M3;
7'd28 : div_num=M5;
7'd29 : div_num=M5;
7'd30 : div_num=M5;
7'd31 : div_num=M6;
7'd32 : div_num=M6;
7'd33 : div_num=M6;
7'd34 : div_num=H1;
7'd35 : div_num=M7;
7'd36 : div_num=H1;
7'd37 : div_num=H1;
7'd38 : div_num=H7;
7'd39 : div_num=H7;
7'd40 : div_num=H1;
7'd41 : div_num=H1;
7'd42 : div_num=H1;
7'd43 : div_num=H1;
//repeat
7'd44 : div_num=M7;
7'd45 : div_num=M7;
7'd46 : div_num=H1;
7'd47 : div_num=H1;
7'd48 : div_num=H2;
7'd49 : div_num=H2;
7'd50 : div_num=H2;
7'd51 : div_num=H3;
7'd52 : div_num=H3;
7'd53 : div_num=H3;
7'd54 : div_num=H3;
7'd55 : div_num=H2;
7'd56 : div_num=H2;
7'd57 : div_num=H2;
7'd58 : div_num=H2;
7'd59 : div_num=H2;
7'd60 : div_num=H1;
7'd61 : div_num=M7;
7'd62 : div_num=H1;
7'd63 : div_num=H1;
7'd64 : div_num=M7;
7'd65 : div_num=M7;
7'd66 : div_num=M7;
7'd67 : div_num=M7;
7'd68 : div_num=M3;
7'd69 : div_num=M2;
7'd70 : div_num=M3;
7'd71 : div_num=M3;
7'd72 : div_num=M3;
7'd73 : div_num=M3;
7'd74 : div_num=M5;
7'd75 : div_num=M5;
7'd76 : div_num=M5;
7'd77 : div_num=M6;
7'd78 : div_num=M6;
7'd79 : div_num=M6;
7'd80 : div_num=L5;
7'd81 : div_num=L6;
7'd82 : div_num=M1;
7'd83 : div_num=M2;
7'd84 : div_num=M3;
7'd85 : div_num=M5;
7'd86 : div_num=H1;
7'd87 : div_num=H1;
7'd88 : div_num=H1;
7'd89 : div_num=H1;
endcase
end
always @(div_num)
begin
case(div_num)
L5 : led=8'b1111_1111;
L6 : led=8'b0111_1111;
L7,
M1 : led=8'b0011_1111;
M2,
M3 : led=8'b0001_1111;
M4,
M5 : led=8'b0000_1111;
M6,
M7 : led=8'b0000_0111;
H1 : led=8'b0000_0011;
H2 : led=8'b0000_0001;
H3 : led=8'b0000_0000;
default : led=8'bx;
endcase
endendmodule// Copyright (C) 1991-2008 Altera Corporation
// Your use of Altera Corporation's design tools, logic functions 
// and other software and tools, and its AMPP partner logic 
// functions, and any output files from any of the foregoing 
// (including device programming or simulation files), and any 
// associated documentation or information are expressly subject 
// to the terms and conditions of the Altera Program License 
// Subscription Agreement, Altera MegaCore Function License 
// Agreement, or other applicable license agreement, including, 
// without limitation, that your use is for the sole purpose of 
// programming logic devices manufactured by Altera and sold by 
// Altera or its authorized distributors.  Please refer to the 
// applicable agreement for further details.// Generated by Quartus II Version 8.0 (Build Build 231 07/10/2008)
// Created on Sun Dec 22 11:38:33 2013beyond beyond_inst
(
.clk(clk_sig) , // input  clk_sig
.beep(beep_sig) , // output  beep_sig
.led(led_sig) // output [7:0] led_sig
);defparam beyond_inst.L1 = 'b10111010101001110;
defparam beyond_inst.L2 = 'b10100110010000001;
defparam beyond_inst.L3 = 'b10010100001001010;
defparam beyond_inst.L4 = 'b10001011110101000;
defparam beyond_inst.L5 = 'b10100111001110000;
defparam beyond_inst.L6 = 'b01101110111110010;
defparam beyond_inst.L7 = 'b01100010110111010;
defparam beyond_inst.M1 = 'b01011101010011110;
defparam beyond_inst.M2 = 'b01010011001001000;
defparam beyond_inst.M3 = 'b01001010000011111;
defparam beyond_inst.M4 = 'b01000101111001111;
defparam beyond_inst.M5 = 'b00111110010010000;
defparam beyond_inst.M6 = 'b00110111011111001;
defparam beyond_inst.M7 = 'b00110001011011101;
defparam beyond_inst.H1 = 'b00101110101101000;
defparam beyond_inst.H2 = 'b00101001100100010;
defparam beyond_inst.H3 = 'b00100101000010001;
defparam beyond_inst.H4 = 'b00100010111101001;
defparam beyond_inst.H5 = 'b00011111001001000;
defparam beyond_inst.H6 = 'b00011011101111101;
defparam beyond_inst.H7 = 'b00011000101101111;

 

这篇关于Verilog | HDL 音乐流水灯(代码类)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1034028

相关文章

Java中调用数据库存储过程的示例代码

《Java中调用数据库存储过程的示例代码》本文介绍Java通过JDBC调用数据库存储过程的方法,涵盖参数类型、执行步骤及数据库差异,需注意异常处理与资源管理,以优化性能并实现复杂业务逻辑,感兴趣的朋友... 目录一、存储过程概述二、Java调用存储过程的基本javascript步骤三、Java调用存储过程示

Visual Studio 2022 编译C++20代码的图文步骤

《VisualStudio2022编译C++20代码的图文步骤》在VisualStudio中启用C++20import功能,需设置语言标准为ISOC++20,开启扫描源查找模块依赖及实验性标... 默认创建Visual Studio桌面控制台项目代码包含C++20的import方法。右键项目的属性:

MySQL数据库的内嵌函数和联合查询实例代码

《MySQL数据库的内嵌函数和联合查询实例代码》联合查询是一种将多个查询结果组合在一起的方法,通常使用UNION、UNIONALL、INTERSECT和EXCEPT关键字,下面:本文主要介绍MyS... 目录一.数据库的内嵌函数1.1聚合函数COUNT([DISTINCT] expr)SUM([DISTIN

Java实现自定义table宽高的示例代码

《Java实现自定义table宽高的示例代码》在桌面应用、管理系统乃至报表工具中,表格(JTable)作为最常用的数据展示组件,不仅承载对数据的增删改查,还需要配合布局与视觉需求,而JavaSwing... 目录一、项目背景详细介绍二、项目需求详细介绍三、相关技术详细介绍四、实现思路详细介绍五、完整实现代码

Go语言代码格式化的技巧分享

《Go语言代码格式化的技巧分享》在Go语言的开发过程中,代码格式化是一个看似细微却至关重要的环节,良好的代码格式化不仅能提升代码的可读性,还能促进团队协作,减少因代码风格差异引发的问题,Go在代码格式... 目录一、Go 语言代码格式化的重要性二、Go 语言代码格式化工具:gofmt 与 go fmt(一)

HTML5实现的移动端购物车自动结算功能示例代码

《HTML5实现的移动端购物车自动结算功能示例代码》本文介绍HTML5实现移动端购物车自动结算,通过WebStorage、事件监听、DOM操作等技术,确保实时更新与数据同步,优化性能及无障碍性,提升用... 目录1. 移动端购物车自动结算概述2. 数据存储与状态保存机制2.1 浏览器端的数据存储方式2.1.

基于 HTML5 Canvas 实现图片旋转与下载功能(完整代码展示)

《基于HTML5Canvas实现图片旋转与下载功能(完整代码展示)》本文将深入剖析一段基于HTML5Canvas的代码,该代码实现了图片的旋转(90度和180度)以及旋转后图片的下载... 目录一、引言二、html 结构分析三、css 样式分析四、JavaScript 功能实现一、引言在 Web 开发中,

Python如何去除图片干扰代码示例

《Python如何去除图片干扰代码示例》图片降噪是一个广泛应用于图像处理的技术,可以提高图像质量和相关应用的效果,:本文主要介绍Python如何去除图片干扰的相关资料,文中通过代码介绍的非常详细,... 目录一、噪声去除1. 高斯噪声(像素值正态分布扰动)2. 椒盐噪声(随机黑白像素点)3. 复杂噪声(如伪

Java Spring ApplicationEvent 代码示例解析

《JavaSpringApplicationEvent代码示例解析》本文解析了Spring事件机制,涵盖核心概念(发布-订阅/观察者模式)、代码实现(事件定义、发布、监听)及高级应用(异步处理、... 目录一、Spring 事件机制核心概念1. 事件驱动架构模型2. 核心组件二、代码示例解析1. 事件定义

Python实例题之pygame开发打飞机游戏实例代码

《Python实例题之pygame开发打飞机游戏实例代码》对于python的学习者,能够写出一个飞机大战的程序代码,是不是感觉到非常的开心,:本文主要介绍Python实例题之pygame开发打飞机... 目录题目pygame-aircraft-game使用 Pygame 开发的打飞机游戏脚本代码解释初始化部