日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

大神教你DIY | 如何用一塊FPGA開發(fā)板制作音樂盒?

 西北望msm66g9f 2019-05-02

相信大家已經(jīng)在網(wǎng)上見識過很多“民間大神”們的天才(奇葩)手工DIY了,一些簡簡單單的材料在他們的搗鼓下,瞬間華麗轉(zhuǎn)身,變廢為寶。今天,我們?yōu)榇蠹艺砹艘晃皇止ご笊竦腄IY心得——如何利用FPGA開發(fā)板DIY一個音樂盒,也就是如何使我們的FPGA播放聲音和音樂!

下面開始吧....

首先需生成單個音調(diào),然后慢慢地做更有趣的事情,如制作警報聲和播放曲調(diào)。

需要準備的硬件

該項目使用的是一個Pluto的FPGA開發(fā)板,還有一個揚聲器和一個1kΩ的電阻。

更加直觀的展示是下面這樣的:

本次DIY的音樂盒分為4個部分:

1.簡單的嗶嗶聲

2.警報聲

3.音調(diào)

4.曲子

簡單的嗶嗶聲

FPGA可以輕松實現(xiàn)二進制計數(shù)器。例如,在回滾之前,16位計數(shù)器將從0到65535(65536個不同的值)計數(shù)。Pluto板具有一個25MHz的時鐘振蕩器,因此我們可以輕松構(gòu)建一個25MHz時鐘16位自動計數(shù)器。其最高位切換頻率為25000000/65536 = 381Hz。

其Verilog HDL的代碼如下:

module music(clk, speaker);

input clk;

output speaker;

// 首先創(chuàng)建一個16位二級制計數(shù)器

reg [15:0] counter;

always @(posedge clk) counter <= counter+1;

// 使用計數(shù)器的最高有效位來驅(qū)動揚聲器

assign speaker = counter[15];

endmodule

詳細講解的話就是,“clk”在25MHz下運行,“counter [0]”看起來像是一個12.5MHz信號(它以25MHz的頻率進行更新變化,變化的值為0 1 0 1 ......因此看起來像12.5MHz信號),“counter [1]“是6.125MHz信號,依此類推。

由于我們使用計數(shù)器的最高有效位(第15位)來驅(qū)動輸出,因此“揚聲器”輸出會產(chǎn)生一個完美的381Hz方波信號。

“A”音符(440Hz)

如果要獲得這些隨機頻率的話,為什么不嘗試生成一個440Hz的信號呢。440Hz正是“A”音符的頻率。但并不是將25MHz除以65536,而是除以56818。

代碼如下:

module music(clk, speaker);

input clk;

output speaker;

reg [15:0] counter;

always @(posedge clk) if(counter==56817) counter <= 0; else counter <= counter+1;

assign speaker = counter[15];

endmodule

但是我們的實現(xiàn)存在問題。雖說如預期的那樣,頻率為440Hz,但輸出占空比并不再是50%。低電平從計數(shù)器= 0變?yōu)橛嫈?shù)器= 32767(當計數(shù)器的第15位為低電平時),然后是從32768到56817的高電平。這使得“揚聲器”僅在42%的時間內(nèi)處于高電平。獲得50%占空比的最簡單方法是添加一個將輸出分為相同兩份步驟。首先,我們除以28409(而不是56818)然后除以2。

代碼如下:

module music(clk, speaker);

input clk;

output speaker;

reg [14:0] counter;

always @(posedge clk) if(counter==28408) counter<=0; else counter <= counter+1;

reg speaker;

always @(posedge clk) if(counter==28408) speaker <= ~speaker;

endmodule

添加一個參數(shù)

這里的代碼基本相同。添加了一個名為“clkdivider”的新參數(shù),使得計數(shù)器變?yōu)椤暗褂嫊r”計數(shù)器 - 只是看你偏向于正向計數(shù)還是倒計時了。

代碼如下:

module music(clk, speaker);

input clk;

output speaker;

parameter clkdivider = 25000000/440/2;

reg [14:0] counter;

always @(posedge clk) if(counter==0) counter <= clkdivider-1; else counter <= counter-1;

reg speaker;

always @(posedge clk) if(counter==0) speaker <= ~speaker;

endmodule

警報聲

救護車警報聲

我們可以在兩個音調(diào)之間循環(huán)。我們首先用一個24位計數(shù)器的“音調(diào)”來產(chǎn)生一個較慢的方波。其MSB(最高有效位)“tone[23]”是一1.5Hz的頻率進行變換的。

然后我們就可以用這個最高有效位切換到另一個計數(shù)器,從而在兩個頻率之間切換。

代碼如下:

module music(clk, speaker);

input clk;

output speaker;

parameter clkdivider = 25000000/440/2;

reg [23:0] tone;

always @(posedge clk) tone <= tone+1;

reg [14:0] counter;

always @(posedge clk) if(counter==0) counter <= (tone[23] ? clkdivider-: clkdivider/2-1); else counter <= counter-1;

reg speaker;

always @(posedge clk) if(counter==0) speaker <= ~speaker;

endmodule

警車警報聲

我們接下來生成一個聽起來像是警笛的斜波。

首先從“音調(diào)”計數(shù)器開始。我們只用23位使其比原來快兩倍(MSB以3Hz的頻率進行變化)。

然后我們生成一個上升的斜波。我們將音調(diào)計數(shù)器的15位到21位提取出來,比如tone[21:15]。這就給到了我們7位,也就是是說以某個中等的速度從0計數(shù)到127,。一旦計數(shù)到127,又從127回到0。

要想獲得下降的斜波,我們可以將這些同樣的位倒轉(zhuǎn)過來,比如~tone[21:15]。又給到了7位,但是這是從127數(shù)到0的。

要想在上升斜波和下降斜波之間轉(zhuǎn)換,我們使用的是tone[22]。一旦上升斜波達到127,就切換到下降斜波,知道計數(shù)變?yōu)?為止,然后又回到上升諧波…

代碼如下:

wire [6:0] ramp = (tone[22] ? tone[21:15] : ~tone[21:15]);

// 這也就意味著

// '如果 tone[22]=1 那么斜波等于tone[21:15] 否則斜波等于~tone[21:15]'

如果你沒理解這個斜波的比喻的話沒關(guān)系,我們換一種說法來講。

假設(shè)我有一個6位十進制計數(shù)器,從000000計數(shù)到199999。這個計數(shù)器是自動計數(shù)的,每毫秒計數(shù)一次(1秒內(nèi)計算1000次),但達到199999之后,又回到0,然后繼續(xù)計數(shù)。以這種速度的話,計數(shù)器每200秒又回到初始狀態(tài)。

很明顯,第一位(這里稱之為digit #0或者說是digit[0])增加速度是最快的。甚至無法用肉眼察覺,所以我們無法使用這一位。然后第二位(digit #1)增加速度要慢十倍,以此類推…

假設(shè)我們只看digit #4和digit #3(= digit[4:3])。你會發(fā)現(xiàn)digit[4:3]在0到99之間變化,,而且每秒增加一次。

因此,我們制定以下規(guī)則:如果digit[5]是0,那么我就看digit[4:3],而當digit[5]時1,那我就看其反碼,比如99- digit[4:3],這樣的話我們可以看出來一個從0到99再從99到0的梯度。

digits[5:3]  rampvalue

   000           00

   001           01

   ...           ..

   ...           ..

   098           98

   099           99

   100           99

   101           98

   102           97

   103           96

   ...           ..

   ...           ..

   197           02

   198           01

   199           00

   000           00

   001           01

   002           02

   ...           ..

所以“梯度”值從7'b0000000 計數(shù)到7'b1111111。為了獲得可用的值來產(chǎn)生聲音,我們將2位“01”放在前面,6位“000000”放在后面。

代碼如下:

wire [14:0] clkdivider = {2'b01, ramp, 6'b000000};

這樣的話,clkdivider的取值范圍從15'b010000000000000到 15'b011111111000000,以16進制表示就是從15'h2000到15'h3FC0,或者是十進制的8192到16320.當以25MHz為輸入時鐘頻率時,就可以生成一個從765Hz到1525Hz的尖銳警笛聲。

代碼如下:

module music(clk, speaker);

input clk;

output speaker;

reg [22:0] tone;

always @(posedge clk) tone <= tone+1;

wire [6:0] ramp = (tone[22] ? tone[21:15] : ~tone[21:15]);

wire [14:0] clkdivider = {2'b01, ramp, 6'b000000};

reg [14:0] counter;

always @(posedge clk) if(counter==0) counter <= clkdivider; else counter <= counter-1;

reg speaker;

always @(posedge clk) if(counter==0) speaker <= ~speaker;

endmodule

高速追捕警報聲

然后我們來生成警車高速追捕的警笛聲,這個警笛聲時快時慢,所以我們用tone[21:15]給到一個快速的音調(diào),再用tone[24:18]給到一個慢速的。

代碼如下:

wire [6:0] fastsweep = (tone[22] ? tone[21:15] : ~tone[21:15]);

wire [6:0] slowsweep = (tone[25] ? tone[24:18] : ~tone[24:18]);

wire [14:0] clkdivider = {2'b01, (tone[27] ? slowsweep : fastsweep), 6'b000000};

完整代碼如下:

module music(clk, speaker);

input clk;

output speaker;

reg [27:0] tone;

always @(posedge clk) tone <= tone+1;

wire [6:0] fastsweep = (tone[22] ? tone[21:15] : ~tone[21:15]);

wire [6:0] slowsweep = (tone[25] ? tone[24:18] : ~tone[24:18]);

wire [14:0] clkdivider = {2'b01, (tone[27] ? slowsweep : fastsweep), 6'b000000};

reg [14:0] counter;

always @(posedge clk) if(counter==0) counter <= clkdivider; else counter <= counter-1;

reg speaker;

always @(posedge clk) if(counter==0) speaker <= ~speaker;

endmodule

演奏音符

現(xiàn)在我們想要演奏一首曲子,所以需要來獲取不同的音符,就像電子琴一樣。

如果我們用6位來實現(xiàn)音符,那么我可以獲得64個音符。每個八度一共有12個音符,所以64個音符可以實現(xiàn)5個八度,完全足夠彈奏一首曲目了。

步驟1

要想實現(xiàn)一組音調(diào)不斷升高的聲音,我們用一個28位計數(shù)器來距離,提取其中6個MSB,從而給到6位的音調(diào)。

代碼如下:

reg [27:0] tone;

always @(posedge clk) tone <= tone+1;

wire [5:0] fullnote = tone[27:22];

在25MHz的時鐘下,每個音符持續(xù)167ms,64個音符一共需要10.6s才能演奏完成。

步驟2

我們將“fullnote”分成12份。這樣就可以給到我們一個八度(一共有5個8度,所以我們只需要3位,從0到4)和音符(從0到11,需要4位)。

代碼如下:

wire [2:0] octave;

wire [3:0] note;

divide_by12 divby12(.numer(fullnote[5:0]), .quotient(octave), .remain(note));

此處用了一個叫divide_by12的子模塊來實現(xiàn)分頻。細節(jié)稍后講解。

步驟3

從一個八度到另一個八度,頻率乘以了“2”。這個在硬件上很容易實現(xiàn),我們在步驟4上進行實現(xiàn)。但是要從一個音符到另一個音符,頻率就要乘以1.0594。這樣的話就沒那么容易在硬件上實現(xiàn)了,所以我們需要看下提前計算好的音符值。

我們將主時鐘除以512得到音符A,除以483得到音符A#,除以456得到音符B…記住,除以一個更低的值得到的是更高的音符。

一個八度下的音符數(shù)值如下:

always @(note)

case(note)

  0: clkdivider = 512-1; // A

  1: clkdivider = 483-1; // A#/Bb

  2: clkdivider = 456-1; // B

  3: clkdivider = 431-1; // C

  4: clkdivider = 406-1; // C#/Db

  5: clkdivider = 384-1; // D

  6: clkdivider = 362-1; // D#/Eb

  7: clkdivider = 342-1; // E

  8: clkdivider = 323-1; // F

  9: clkdivider = 304-1; // F#/Gb

  10: clkdivider = 287-1; // G

  11: clkdivider = 271-1; // G#/Ab

  12: clkdivider = 0; // should never happen

  13: clkdivider = 0; // should never happen

  14: clkdivider = 0; // should never happen

  15: clkdivider = 0; // should never happen

endcase

always @(posedge clk) if(counter_note==0) counter_note <= clkdivider; else counter_note <= counter_note-1;

每當counter_note等于0時,就進入到下一個八度。

步驟4

現(xiàn)在我們要處理好不同的八度,對于最低的八度,我們將“counter_note”除以256,對于第二個八度,除以128,以此類推。

reg [7:0] counter_octave;

always @(posedge clk)

if(counter_note==0)

begin

 if(counter_octave==0)

counter_octave<=(octave==0?255:octave==1?127:octave==2?63:octave==3?31:octave==4?15:7);

 else

  counter_octave <= counter_octave-1;

end

reg speaker;

always @(posedge clk)if(counter_note==0&&counter_octave==0)speaker <= ~speaker;

完整代碼如下:

module music(clk, speaker);

input clk;

output speaker;

reg [27:0] tone;

always @(posedge clk) tone <= tone+1;

wire [5:0] fullnote = tone[27:22];

wire [2:0] octave;

wire [3:0] note;

divide_by12 divby12(.numer(fullnote[5:0]), .quotient(octave), .remain(note));

reg [8:0] clkdivider;

always @(note)

case(note)

  0: clkdivider = 512-1; // A

  1: clkdivider = 483-1; // A#/Bb

  2: clkdivider = 456-1; // B

  3: clkdivider = 431-1; // C

  4: clkdivider = 406-1; // C#/Db

  5: clkdivider = 384-1; // D

  6: clkdivider = 362-1; // D#/Eb

  7: clkdivider = 342-1; // E

  8: clkdivider = 323-1; // F

  9: clkdivider = 304-1; // F#/Gb

  10: clkdivider = 287-1; // G

  11: clkdivider = 271-1; // G#/Ab

  12: clkdivider = 0; // should never happen

  13: clkdivider = 0; // should never happen

  14: clkdivider = 0; // should never happen

  15: clkdivider = 0; // should never happen

endcase

reg [8:0] counter_note;

always @(posedge clk) if(counter_note==0) counter_note <= clkdivider; else counter_note <= counter_note-1;

reg [7:0] counter_octave;

always @(posedge clk)

if(counter_note==0)

begin

 if(counter_octave==0)

  counter_octave <= (octave==0?255:octave==1?127:octave==2?63:octave==3?31:octave==4?15:7);

 else

  counter_octave <= counter_octave-1;

end

reg speaker;

always @(posedge clk) if(counter_note==&& counter_octave==0) speaker <= ~speaker;

endmodule

除以12

“除以12”的模塊將一個6位的可變數(shù)值作為分子,然后將其除以定值12。這樣可以獲得一個三位的商(0..5)和4位的余數(shù)(0..11)。要想除以12,可以先除以4再除以3。除以4很簡單:我們將分子的兩位去掉,然后將其作為余數(shù)就行。所以我們只需要用6-2=4位來除以3,我們用一個查詢表來實現(xiàn)。

module divide_by12(numer, quotient, remain);

input [5:0] numer;

output [2:0] quotient;

output [3:0] remain;

reg [2:0] quotient;

reg [3:0] remain_bit3_bit2;

assign remain = {remain_bit3_bit2, numer[1:0]}; // the first 2 bits are copied through

always @(numer[5:2]) // and just do a divide by '3' on the remaining bits

case(numer[5:2])

   0: begin quotient=0; remain_bit3_bit2=0; end

   1: begin quotient=0; remain_bit3_bit2=1; end

   2: begin quotient=0; remain_bit3_bit2=2; end

   3: begin quotient=1; remain_bit3_bit2=0; end

   4: begin quotient=1; remain_bit3_bit2=1; end

   5: begin quotient=1; remain_bit3_bit2=2; end

   6: begin quotient=2; remain_bit3_bit2=0; end

   7: begin quotient=2; remain_bit3_bit2=1; end

   8: begin quotient=2; remain_bit3_bit2=2; end

   9: begin quotient=3; remain_bit3_bit2=0; end

 10: begin quotient=3; remain_bit3_bit2=1; end

 11: begin quotient=3; remain_bit3_bit2=2; end

 12: begin quotient=4; remain_bit3_bit2=0; end

 13: begin quotient=4; remain_bit3_bit2=1; end

 14: begin quotient=4; remain_bit3_bit2=2; end

 15: begin quotient=5; remain_bit3_bit2=0; end

endcase

endmodule

一段旋律

現(xiàn)在我們可以彈奏一段旋律了,這個非常簡單,只是看我們怎么利用ROM中的音符。

// 用計數(shù)器來讀取ROM中我們想要播放的旋律

reg [30:0] tone;

always @(posedge clk) tone <= tone+1;

wire [7:0] fullnote;

music_ROM ROM(.clk(clk), .address(tone[29:22]), .note(fullnote));

我們還需要:

1.ROM讀取結(jié)束后旋律停止

2.值為0的fullnote是一個聲音很小的音符

所以我們改變上一個設(shè)計中的代碼

always @(posedge clk) if(counter_note==&& counter_octave==0) speaker <= ~speaker;

改為

always @(posedge clk) if(counter_note==&& counter_octave==&& tone[30]==&& fullnote!=0) speaker <= ~speaker;

剩下的設(shè)計仍保持原樣。

完整的代碼如下,你猜得出來這是什么曲子嗎?

完整代碼

// 盡可能使用25MHz的時鐘頻率 (其它頻率會

// 改變曲子的音調(diào)和速度)

/////////////////////////////////////////////////////

module music(

    input clk,

    output reg speaker

);

reg [30:0] tone;

always @(posedge clk) tone <= tone+31'd1;

wire [7:0] fullnote;

music_ROM get_fullnote(.clk(clk), .address(tone[29:22]), .note(fullnote));

wire [2:0] octave;

wire [3:0] note;

divide_by12 get_octave_and_note(.numerator(fullnote[5:0]), .quotient(octave), .remainder(note));

reg [8:0] clkdivider;

always @*

case(note)

     0: clkdivider = 9'd511;//A

     1: clkdivider = 9'd482;// A#/Bb

     2: clkdivider = 9'd455;//B

     3: clkdivider = 9'd430;//C

     4: clkdivider = 9'd405;// C#/Db

     5: clkdivider = 9'd383;//D

     6: clkdivider = 9'd361;// D#/Eb

     7: clkdivider = 9'd341;//E

     8: clkdivider = 9'd322;//F

     9: clkdivider = 9'd303;// F#/Gb

    10: clkdivider = 9'd286;//G

    11: clkdivider = 9'd270;// G#/Ab

    default: clkdivider = 9'd0;

endcase

reg [8:0] counter_note;

reg [7:0] counter_octave;

always @(posedge clk) counter_note <= counter_note==? clkdivider : counter_note-9'd1;

always @(posedge clk) if(counter_note==0) counter_octave <= counter_octave==? 8'd255 >> octave : counter_octave-8'd1;

always @(posedge clk) if(counter_note==&& counter_octave==&& fullnote!=&& tone[21:18]!=0) speaker <= ~speaker;

endmodule

/////////////////////////////////////////////////////

module divide_by12(

    input [5:0] numerator,  // value to be divided by 12

    output reg [2:0] quotient, 

    output [3:0] remainder

);

reg [1:0] remainder3to2;

always @(numerator[5:2])

case(numerator[5:2])

     0: begin quotient=0; remainder3to2=0; end

     1: begin quotient=0; remainder3to2=1; end

     2: begin quotient=0; remainder3to2=2; end

     3: begin quotient=1; remainder3to2=0; end

     4: begin quotient=1; remainder3to2=1; end

     5: begin quotient=1; remainder3to2=2; end

     6: begin quotient=2; remainder3to2=0; end

     7: begin quotient=2; remainder3to2=1; end

     8: begin quotient=2; remainder3to2=2; end

     9: begin quotient=3; remainder3to2=0; end

    10: begin quotient=3; remainder3to2=1; end

    11: begin quotient=3; remainder3to2=2; end

    12: begin quotient=4; remainder3to2=0; end

    13: begin quotient=4; remainder3to2=1; end

    14: begin quotient=4; remainder3to2=2; end

    15: begin quotient=5; remainder3to2=0; end

endcase

assign remainder[1:0] = numerator[1:0];  // the first 2 bits are copied through

assign remainder[3:2] = remainder3to2;  // and the last 2 bits come from the case statement

endmodule

/////////////////////////////////////////////////////

module music_ROM(

    input clk,

    input [7:0] address,

    output reg [7:0] note

);

always @(posedge clk)

case(address)

      0: note<= 8'd25;

      1: note<= 8'd27;

      2: note<= 8'd27;

      3: note<= 8'd25;

      4: note<= 8'd22;

      5: note<= 8'd22;

      6: note<= 8'd30;

      7: note<= 8'd30;

      8: note<= 8'd27;

      9: note<= 8'd27;

     10: note<= 8'd25;

     11: note<= 8'd25;

     12: note<= 8'd25;

     13: note<= 8'd25;

     14: note<= 8'd25;

     15: note<= 8'd25;

     16: note<= 8'd25;

     17: note<= 8'd27;

     18: note<= 8'd25;

     19: note<= 8'd27;

     20: note<= 8'd25;

     21: note<= 8'd25;

     22: note<= 8'd30;

     23: note<= 8'd30;

     24: note<= 8'd29;

     25: note<= 8'd29;

     26: note<= 8'd29;

     27: note<= 8'd29;

     28: note<= 8'd29;

     29: note<= 8'd29;

     30: note<= 8'd29;

     31: note<= 8'd29;

     32: note<= 8'd23;

     33: note<= 8'd25;

     34: note<= 8'd25;

     35: note<= 8'd23;

     36: note<= 8'd20;

     37: note<= 8'd20;

     38: note<= 8'd29;

     39: note<= 8'd29;

     40: note<= 8'd27;

     41: note<= 8'd27;

     42: note<= 8'd25;

     43: note<= 8'd25;

     44: note<= 8'd25;

     45: note<= 8'd25;

     46: note<= 8'd25;

     47: note<= 8'd25;

     48: note<= 8'd25;

     49: note<= 8'd27;

     50: note<= 8'd25;

     51: note<= 8'd27;

     52: note<= 8'd25;

     53: note<= 8'd25;

     54: note<= 8'd27;

     55: note<= 8'd27;

     56: note<= 8'd22;

     57: note<= 8'd22;

     58: note<= 8'd22;

     59: note<= 8'd22;

     60: note<= 8'd22;

     61: note<= 8'd22;

     62: note<= 8'd22;

     63: note<= 8'd22;

     64: note<= 8'd25;

     65: note<= 8'd27;

     66: note<= 8'd27;

     67: note<= 8'd25;

     68: note<= 8'd22;

     69: note<= 8'd22;

     70: note<= 8'd30;

     71: note<= 8'd30;

     72: note<= 8'd27;

     73: note<= 8'd27;

     74: note<= 8'd25;

     75: note<= 8'd25;

     76: note<= 8'd25;

     77: note<= 8'd25;

     78: note<= 8'd25;

     79: note<= 8'd25;

     80: note<= 8'd25;

     81: note<= 8'd27;

     82: note<= 8'd25;

     83: note<= 8'd27;

     84: note<= 8'd25;

     85: note<= 8'd25;

     86: note<= 8'd30;

     87: note<= 8'd30;

     88: note<= 8'd29;

     89: note<= 8'd29;

     90: note<= 8'd29;

     91: note<= 8'd29;

     92: note<= 8'd29;

     93: note<= 8'd29;

     94: note<= 8'd29;

     95: note<= 8'd29;

     96: note<= 8'd23;

     97: note<= 8'd25;

     98: note<= 8'd25;

     99: note<= 8'd23;

    100: note<= 8'd20;

    101: note<= 8'd20;

    102: note<= 8'd29;

    103: note<= 8'd29;

    104: note<= 8'd27;

    105: note<= 8'd27;

    106: note<= 8'd25;

    107: note<= 8'd25;

    108: note<= 8'd25;

    109: note<= 8'd25;

    110: note<= 8'd25;

    111: note<= 8'd25;

    112: note<= 8'd25;

    113: note<= 8'd27;

    114: note<= 8'd25;

    115: note<= 8'd27;

    116: note<= 8'd25;

    117: note<= 8'd25;

    118: note<= 8'd32;

    119: note<= 8'd32;

    120: note<= 8'd30;

    121: note<= 8'd30;

    122: note<= 8'd30;

    123: note<= 8'd30;

    124: note<= 8'd30;

    125: note<= 8'd30;

    126: note<= 8'd30;

    127: note<= 8'd30;

    128: note<= 8'd27;

    129: note<= 8'd27;

    130: note<= 8'd27;

    131: note<= 8'd27;

    132: note<= 8'd30;

    133: note<= 8'd30;

    134: note<= 8'd30;

    135: note<= 8'd27;

    136: note<= 8'd25;

    137: note<= 8'd25;

    138: note<= 8'd22;

    139: note<= 8'd22;

    140: note<= 8'd25;

    141: note<= 8'd25;

    142: note<= 8'd25;

    143: note<= 8'd25;

    144: note<= 8'd23;

    145: note<= 8'd23;

    146: note<= 8'd27;

    147: note<= 8'd27;

    148: note<= 8'd25;

    149: note<= 8'd25;

    150: note<= 8'd23;

    151: note<= 8'd23;

    152: note<= 8'd22;

    153: note<= 8'd22;

    154: note<= 8'd22;

    155: note<= 8'd22;

    156: note<= 8'd22;

    157: note<= 8'd22;

    158: note<= 8'd22;

    159: note<= 8'd22;

    160: note<= 8'd20;

    161: note<= 8'd20;

    162: note<= 8'd22;

    163: note<= 8'd22;

    164: note<= 8'd25;

    165: note<= 8'd25;

    166: note<= 8'd27;

    167: note<= 8'd27;

    168: note<= 8'd29;

    169: note<= 8'd29;

    170: note<= 8'd29;

    171: note<= 8'd29;

    172: note<= 8'd29;

    173: note<= 8'd29;

    174: note<= 8'd29;

    175: note<= 8'd29;

    176: note<= 8'd30;

    177: note<= 8'd30;

    178: note<= 8'd30;

    179: note<= 8'd30;

    180: note<= 8'd29;

    181: note<= 8'd29;

    182: note<= 8'd27;

    183: note<= 8'd27;

    184: note<= 8'd25;

    185: note<= 8'd25;

    186: note<= 8'd23;

    187: note<= 8'd20;

    188: note<= 8'd20;

    189: note<= 8'd20;

    190: note<= 8'd20;

    191: note<= 8'd20;

    192: note<= 8'd25;

    193: note<= 8'd27;

    194: note<= 8'd27;

    195: note<= 8'd25;

    196: note<= 8'd22;

    197: note<= 8'd22;

    198: note<= 8'd30;

    199: note<= 8'd30;

    200: note<= 8'd27;

    201: note<= 8'd27;

    202: note<= 8'd25;

    203: note<= 8'd25;

    204: note<= 8'd25;

    205: note<= 8'd25;

    206: note<= 8'd25;

    207: note<= 8'd25;

    208: note<= 8'd25;

    209: note<= 8'd27;

    210: note<= 8'd25;

    211: note<= 8'd27;

    212: note<= 8'd25;

    213: note<= 8'd25;

    214: note<= 8'd30;

    215: note<= 8'd30;

    216: note<= 8'd29;

    217: note<= 8'd29;

    218: note<= 8'd29;

    219: note<= 8'd29;

    220: note<= 8'd29;

    221: note<= 8'd29;

    222: note<= 8'd29;

    223: note<= 8'd29;

    224: note<= 8'd23;

    225: note<= 8'd25;

    226: note<= 8'd25;

    227: note<= 8'd23;

    228: note<= 8'd20;

    229: note<= 8'd20;

    230: note<= 8'd29;

    231: note<= 8'd29;

    232: note<= 8'd27;

    233: note<= 8'd27;

    234: note<= 8'd25;

    235: note<= 8'd25;

    236: note<= 8'd25;

    237: note<= 8'd25;

    238: note<= 8'd25;

    239: note<= 8'd25;

    240: note<= 8'd25;

    241: note<= 8'd0;

    242: note<= 8'd00;

    default: note <= 8'd0;

endcase

endmodule

關(guān)于如何使用FPGA開發(fā)板DIY音樂盒,咱們就先講到這里,如果大家對FPGA的開發(fā)與應用感興趣,或者自己也想嘗試用FPGA開發(fā)板DIIY一些不一樣的東西,可以掃描下面二維碼加入“發(fā)燒友FPGA群-1”,與更多志同道合的人“大話FPGA”!

立即掃碼入群

進群還有更多福利:10套FPGA精華資料、電子發(fā)燒友網(wǎng)站積分、VIP權(quán)限統(tǒng)統(tǒng)免費送!

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多