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搭配ApacheCommonsLang3和Natty库,可以实现灵活高效的日期解析与格式化,本文将通过相关示例为大家讲讲具体的实践操作,需要的可以... 目录一、背景二、依赖介绍1. Apache Commons Lang32. Natty三、核心实现代

使用Python自动化生成PPT并结合LLM生成内容的代码解析

《使用Python自动化生成PPT并结合LLM生成内容的代码解析》PowerPoint是常用的文档工具,但手动设计和排版耗时耗力,本文将展示如何通过Python自动化提取PPT样式并生成新PPT,同时... 目录核心代码解析1. 提取 PPT 样式到 jsON关键步骤:代码片段:2. 应用 JSON 样式到

SpringBoot实现二维码生成的详细步骤与完整代码

《SpringBoot实现二维码生成的详细步骤与完整代码》如今,二维码的应用场景非常广泛,从支付到信息分享,二维码都扮演着重要角色,SpringBoot是一个非常流行的Java基于Spring框架的微... 目录一、环境搭建二、创建 Spring Boot 项目三、引入二维码生成依赖四、编写二维码生成代码五

使用Python和PaddleOCR实现图文识别的代码和步骤

《使用Python和PaddleOCR实现图文识别的代码和步骤》在当今数字化时代,图文识别技术的应用越来越广泛,如文档数字化、信息提取等,PaddleOCR是百度开源的一款强大的OCR工具包,它集成了... 目录一、引言二、环境准备2.1 安装 python2.2 安装 PaddlePaddle2.3 安装

SpringBoot中四种AOP实战应用场景及代码实现

《SpringBoot中四种AOP实战应用场景及代码实现》面向切面编程(AOP)是Spring框架的核心功能之一,它通过预编译和运行期动态代理实现程序功能的统一维护,在SpringBoot应用中,AO... 目录引言场景一:日志记录与性能监控业务需求实现方案使用示例扩展:MDC实现请求跟踪场景二:权限控制与

利用Python调试串口的示例代码

《利用Python调试串口的示例代码》在嵌入式开发、物联网设备调试过程中,串口通信是最基础的调试手段本文将带你用Python+ttkbootstrap打造一款高颜值、多功能的串口调试助手,需要的可以了... 目录概述:为什么需要专业的串口调试工具项目架构设计1.1 技术栈选型1.2 关键类说明1.3 线程模

Python Transformers库(NLP处理库)案例代码讲解

《PythonTransformers库(NLP处理库)案例代码讲解》本文介绍transformers库的全面讲解,包含基础知识、高级用法、案例代码及学习路径,内容经过组织,适合不同阶段的学习者,对... 目录一、基础知识1. Transformers 库简介2. 安装与环境配置3. 快速上手示例二、核心模

Java的栈与队列实现代码解析

《Java的栈与队列实现代码解析》栈是常见的线性数据结构,栈的特点是以先进后出的形式,后进先出,先进后出,分为栈底和栈顶,栈应用于内存的分配,表达式求值,存储临时的数据和方法的调用等,本文给大家介绍J... 目录栈的概念(Stack)栈的实现代码队列(Queue)模拟实现队列(双链表实现)循环队列(循环数组

使用Java将DOCX文档解析为Markdown文档的代码实现

《使用Java将DOCX文档解析为Markdown文档的代码实现》在现代文档处理中,Markdown(MD)因其简洁的语法和良好的可读性,逐渐成为开发者、技术写作者和内容创作者的首选格式,然而,许多文... 目录引言1. 工具和库介绍2. 安装依赖库3. 使用Apache POI解析DOCX文档4. 将解析

C++使用printf语句实现进制转换的示例代码

《C++使用printf语句实现进制转换的示例代码》在C语言中,printf函数可以直接实现部分进制转换功能,通过格式说明符(formatspecifier)快速输出不同进制的数值,下面给大家分享C+... 目录一、printf 原生支持的进制转换1. 十进制、八进制、十六进制转换2. 显示进制前缀3. 指