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

相关文章

活用c4d官方开发文档查询代码

当你问AI助手比如豆包,如何用python禁止掉xpresso标签时候,它会提示到 这时候要用到两个东西。https://developers.maxon.net/论坛搜索和开发文档 比如这里我就在官方找到正确的id描述 然后我就把参数标签换过来

poj 1258 Agri-Net(最小生成树模板代码)

感觉用这题来当模板更适合。 题意就是给你邻接矩阵求最小生成树啦。~ prim代码:效率很高。172k...0ms。 #include<stdio.h>#include<algorithm>using namespace std;const int MaxN = 101;const int INF = 0x3f3f3f3f;int g[MaxN][MaxN];int n

计算机毕业设计 大学志愿填报系统 Java+SpringBoot+Vue 前后端分离 文档报告 代码讲解 安装调试

🍊作者:计算机编程-吉哥 🍊简介:专业从事JavaWeb程序开发,微信小程序开发,定制化项目、 源码、代码讲解、文档撰写、ppt制作。做自己喜欢的事,生活就是快乐的。 🍊心愿:点赞 👍 收藏 ⭐评论 📝 🍅 文末获取源码联系 👇🏻 精彩专栏推荐订阅 👇🏻 不然下次找不到哟~Java毕业设计项目~热门选题推荐《1000套》 目录 1.技术选型 2.开发工具 3.功能

代码随想录冲冲冲 Day39 动态规划Part7

198. 打家劫舍 dp数组的意义是在第i位的时候偷的最大钱数是多少 如果nums的size为0 总价值当然就是0 如果nums的size为1 总价值是nums[0] 遍历顺序就是从小到大遍历 之后是递推公式 对于dp[i]的最大价值来说有两种可能 1.偷第i个 那么最大价值就是dp[i-2]+nums[i] 2.不偷第i个 那么价值就是dp[i-1] 之后取这两个的最大值就是d

pip-tools:打造可重复、可控的 Python 开发环境,解决依赖关系,让代码更稳定

在 Python 开发中,管理依赖关系是一项繁琐且容易出错的任务。手动更新依赖版本、处理冲突、确保一致性等等,都可能让开发者感到头疼。而 pip-tools 为开发者提供了一套稳定可靠的解决方案。 什么是 pip-tools? pip-tools 是一组命令行工具,旨在简化 Python 依赖关系的管理,确保项目环境的稳定性和可重复性。它主要包含两个核心工具:pip-compile 和 pip

D4代码AC集

贪心问题解决的步骤: (局部贪心能导致全局贪心)    1.确定贪心策略    2.验证贪心策略是否正确 排队接水 #include<bits/stdc++.h>using namespace std;int main(){int w,n,a[32000];cin>>w>>n;for(int i=1;i<=n;i++){cin>>a[i];}sort(a+1,a+n+1);int i=1

html css jquery选项卡 代码练习小项目

在学习 html 和 css jquery 结合使用的时候 做好是能尝试做一些简单的小功能,来提高自己的 逻辑能力,熟悉代码的编写语法 下面分享一段代码 使用html css jquery选项卡 代码练习 <div class="box"><dl class="tab"><dd class="active">手机</dd><dd>家电</dd><dd>服装</dd><dd>数码</dd><dd

生信代码入门:从零开始掌握生物信息学编程技能

少走弯路,高效分析;了解生信云,访问 【生信圆桌x生信专用云服务器】 : www.tebteb.cc 介绍 生物信息学是一个高度跨学科的领域,结合了生物学、计算机科学和统计学。随着高通量测序技术的发展,海量的生物数据需要通过编程来进行处理和分析。因此,掌握生信编程技能,成为每一个生物信息学研究者的必备能力。 生信代码入门,旨在帮助初学者从零开始学习生物信息学中的编程基础。通过学习常用

husky 工具配置代码检查工作流:提交代码至仓库前做代码检查

提示:这篇博客以我前两篇博客作为先修知识,请大家先去看看我前两篇博客 博客指路:前端 ESlint 代码规范及修复代码规范错误-CSDN博客前端 Vue3 项目开发—— ESLint & prettier 配置代码风格-CSDN博客 husky 工具配置代码检查工作流的作用 在工作中,我们经常需要将写好的代码提交至代码仓库 但是由于程序员疏忽而将不规范的代码提交至仓库,显然是不合理的 所

Unity3D自带Mouse Look鼠标视角代码解析。

Unity3D自带Mouse Look鼠标视角代码解析。 代码块 代码块语法遵循标准markdown代码,例如: using UnityEngine;using System.Collections;/// MouseLook rotates the transform based on the mouse delta./// Minimum and Maximum values can