Cov txheej txheem:

Basys3 FPGA Digital Audio Synthesizer: 5 Kauj Ruam
Basys3 FPGA Digital Audio Synthesizer: 5 Kauj Ruam

Video: Basys3 FPGA Digital Audio Synthesizer: 5 Kauj Ruam

Video: Basys3 FPGA Digital Audio Synthesizer: 5 Kauj Ruam
Video: Real-time Audio Processing via FIR Filters on Basys-3 FPGA 2024, Hlis ntuj nqeg
Anonim
Image
Image
Basys3 FPGA Digital Audio Synthesizer
Basys3 FPGA Digital Audio Synthesizer
Basys3 FPGA Digital Audio Synthesizer
Basys3 FPGA Digital Audio Synthesizer

Qhov digital sine wave keyboard synthesizer no yuav siv cov neeg siv nkag los ntawm cov hloov pauv ib ntus tso tawm zoo li cov keyboard thiab tso lub suab yoj los ntawm tus hais lus. Raws li cov neeg siv tswv yim, lub cuab yeej yuav tsim hluav taws xob sine ntawm ntau zaus los ntawm C4 txog C6. Tus neeg siv tuaj yeem sau cov ntawv sau los ntawm C4 txog C6 (tag nrho cov ntawv sau tseg), thiab txog plaub tus yuam sij nyob rau tib lub sijhawm - yog tias ntau dua plaub tus lej raug nias, plaub lub suab qis tshaj yuav raug ntaus.

Txoj haujlwm no tau ua tiav los ntawm Ryan Morris thiab Mavis Tsoi rau peb Cal Poly CPE 133 Digital Design chav kawm:)

Kauj ruam 1: Txoj kev xav

Pawg FPGA tsuas tuaj yeem tso tawm cov cim digital. Hauv lwm lo lus, nws tsuas tuaj yeem tsim hluav taws xob siab (3.3V) lossis qis (0V) qhov hluav taws xob. Txawm li cas los xij, cov cim suab yog analog thiab tuaj yeem muaj ntau qhov sib ntxiv hauv qhov hluav taws xob. Txhawm rau kom nyob ib puag ncig qhov no, peb yuav siv PWM (mem tes dav tes taws los piav) teeb liab kom ua raws li qhov sib piv sib piv. Yog tias koj tsis paub PWM yog dab tsi, txheeb xyuas qhov no:

Kauj Ruam 2: Cov Khoom Siv & Cov Cuab Yeej

  • Khoos phis tawj nrog Vivado teeb tsa
  • Peb yuav siv Vivado version 2017.2
  • Basys3 FPGA Pawg Thawj Coj
  • 25 SPDT Txwv Hloov (peb siv cov no)
  • 30 jumper xov hlau (ib tus txiv neej kawg, lwm qhov kawg tsis muaj teeb meem), 12 nti
  • Hlau txiav
  • Cov hlua hlau
  • Spare hlau rau soldering
  • Resin-core Solder
  • Soldering hlau
  • Female”poj niam lub mloog pob ntseg
  • Amplifier/hais lus
  • Ib yam dab tsi los txhim kho cov hloov pauv (peb siv protoboard + lub thawv ntoo)

Kauj Ruam 3: Teeb thiab Kho Vajtse

Teeb & Kho Vajtse Teeb
Teeb & Kho Vajtse Teeb
Teeb & Kho Vajtse Teeb
Teeb & Kho Vajtse Teeb
Teeb & Kho Vajtse Teeb
Teeb & Kho Vajtse Teeb

Txheej Txheem Txheej Txheem

Saib daim duab 1: 25 muaj cov khoom siv nkag mus, Basys3 Board → amplifier & hais lus.

Tso zis

Saib Daim Duab 2: Basys3 Board → 1/2 Poj Niam Lub Suab Jack → Hais Lus (nrog Amplifier)

Tswv yim

Kev sib txuas ntawm pmod ntawm Basys3 pawg thawj coj yuav tsum txuas nrog hauv av txhawm rau pom qhov nkag qis thiab yuav tsis ua haujlwm zoo yog tias sab laug yog qhib Circuit Court. Vim li no, peb yuav tsum siv SPDT hloov pauv rau txhua qhov ntawm peb cov yuam sij ceeb toom. Kev hloov SPDT ib txwm tso cai rau tus neeg siv hloov pauv ntawm cov kab hluav taws xob thaum nias, yog li peb yuav siv lawv li peb "cov nyees khawm" txhawm rau nkag qis (0V) lossis siab (3.3V) cov cim rau Basys3 board.

Txhua qhov hloov pauv yuav muaj NO (nquag qhib) lub dav hlau txuas nrog 3.3V, NC (ib txwm kaw) lub davhlau ya nyob twg txuas nrog GND, thiab COM (ib txwm) davhlau ya nyob twg txuas nrog FPGA cov tswv yim. Saib daim duab 3.

Vim tias peb muaj 25 tus lej txwv, lawv txhua tus yuav koom ua ke 3.3V kab thiab ib txoj kab GND. Tom qab ntawd, kab teeb liab los ntawm txhua qhov txwv hloov pauv yuav tau muab ua pawg 8 thiab sib txuas mus rau yav tsaus ntuj kev sib txuas ntawm Basys3 pawg thawj coj siv zippable jumper xov hlau kom txo qis qhov tsis txaus ntseeg uas peb yuav ua. Saib daim duab 4 lossis piv txwv ntawm thawj yim tus yuam sij.

Kauj Ruam 4: Teeb VHDL (Vivado)

VHDL Teeb (Vivado)
VHDL Teeb (Vivado)
VHDL Teeb (Vivado)
VHDL Teeb (Vivado)

Lub tshuab hluav taws xob sine thiab PWM lub tshuab hluav taws xob tau raug sim thawj zaug kom ntseeg tau tias peb lub tswv yim ua haujlwm, tom qab ntawd cov tswv yim txwv thiab qhov dav ntxiv/hloov pauv tau suav nrog. Cov ntsiab lus ntawm kev ua haujlwm thiab I/O ntawm txhua txoj kev thaiv yog raws li qhia hauv Daim Duab. Cov cai tau qhia hauv qab no, tab sis kuj txuas ua VHD thiab txt cov ntaub ntawv. Yog tias muaj qhov sib txawv, mus nrog VHD cov ntaub ntawv.

BTW: tej zaum peb yuav tsum tau ua peb kab luv dua tab sis cov lej cim rau ntawm Instructables kuj tau dhau los ua qhov tsis txaus ntseeg los cuam tshuam nrog, yog li qhov kev sib nrug tsis yog qhov loj tshaj thiab tsis muaj cov ntsiab lus tseem ceeb. Yog tias koj muaj Vivado thiab xav ua raws txoj cai, peb pom zoo kom koj tsuas yog rub tawm cov ntawv.

Ua ntej, cia saib ntawm Sine Wave Generator module.

tsev qiv ntawv IEEE; siv IEEE. STD_LOGIC_1164. ALL; siv IEEE. NUMERIC_STD. ALL; qhov chaw Wave_Generator yog Chaw Nres Nkoj (Qhov tshwm sim: hauv STD_LOGIC; - Qhov tseem ceeb nias Freq_Cnt: hauv STD_LOGIC_VECTOR (15 downto 0); - Tus nqi suav = 100MHz / (Nco Ntsoov*64 Kev faib tawm ntawm Sine Wave) (hloov mus rau tus lej nyob ze) - hloov npe los ntawm Freq wavegenCLK: hauv STD_LOGIC; - Basys3 100MHz CLK WaveOut: tawm STD_LOGIC_VECTOR (9 downto 0)); - Kos npe qhov dav ntawm nthwv dej kawg Wave_Generator; architecture Tus Cwj Pwm ntawm Wave_Generator yog teeb liab i: integer range 0 txog 64: = 0; -qhov ntsuas ntawm qhov dav dav nco lub txhab nyiaj hom memory_type yog array (0 txog 63) ntawm cov lej sib txawv -64 txog 63; - tsim lub txhab nyiaj nco (ROM) los tuav qhov tseem ceeb- yog RAM lossis ROM tsuas yog xav tsis thoob… teeb liab qhov loj: cim xeeb_type: = (0, 7, 13, 19, 25, 30, 35, 40, 45, 49, 52), 55, 58, 60, 62, 63, 63, 63, 62, 60, 58, 55, 52, 49, 45, 40, 35, 30, 25, 19, 13, 7, 0, -7, -13, -19, -25, -30, -35, -40, -45, -49, -52, -55, -58, -60, -62, -63, -63, -63, -62, - 60, -58, -55, -52, -49, -45, -40, -35, -30, -25, -19, -13, -7); - amplitude nco bank rau sine wave pib txheej txheem (wavegenCLK, Trigger) sib txawv txee: tsis kos npe (15 downto 0): = to_unsigned (0, 16); - lub moos faib faib, hloov npe los ntawm count1 pib yog (nce_edge (wavegenCLK)) tom qab ntawd yog (Trigger = '1') tom qab ntawd- qhov tseem ceeb raug nias txee: = txee + 1; if (counter = unsigned (Freq_Cnt)) then - Freq_Cnt = 100Mhz / (note freq * 64 divisions of the sine wave) - reset counter and assign amplitude data to output counter: = to_unsigned (0, 16); WaveOut <= STD_LOGIC_VECTOR (to_signed (amplitude (i), 10))); - nce ntxiv rau kev nyeem ntawv tom ntej i <= i + 1; - rov pib dua kuv yog tias ib qho sine wave tau ua tiav yog (i = 63) ces kuv <= 0; kawg yog; kawg yog; - (txee = tsis tau kos npe (Freq_Cnt)) lwm qhov- qhov tseem ceeb tsis raug nias- rov pib dua qhov tso tawm, qhov ntsuas qhov dav, thiab lub txee WaveOut <= "0000000000"; kuv <= 0; txee: = to_unsigned (0, 16); -tawm suab Amplitude = -64 thaum tsis muaj ntawv sau ua si kawg yog; - (Trigger = '1') kawg yog; - (nce_edge (CLK)) txheej txheem kawg; kawg Tus Cwj Pwm;

Peb yuav tsim hluav taws xob digital sine hauv Basys3 los ntawm kev siv lub moos sab hauv thiab ROM. Qhov ROM no yuav khaws 64 qhov tseem ceeb uas sawv cev rau 64 qhov dav ntawm sine wave. Saib daim duab 1. 64 qhov tseem ceeb uas peb siv ua raws lub sine wave nrog kev daws teeb meem zoo nkauj.

Siv lub moos sab hauv, peb suav rau tus nqi uas sawv cev rau lub moos nrawm faib los ntawm qhov zaus ntawm nthwv dej peb xav tau thiab 64: Clk div = 100MHz / (Freq * 64) Txhua lub sijhawm peb lub txee nce mus txog tus nqi ntawd, peb hu tus lej los ntawm ROM thiab xa qhov ntawd tawm ntawm peb lub tshuab hluav taws xob tsim hluav taws xob. Qhov zaus ntawm peb nthwv dej yuav nyob ntawm qhov nrawm peb hu cov suab nrov no.

Peb yuav muaj 25 tus qauv sib txawv, txhua qhov cuam tshuam nrog ib zaus/ceeb toom.

Nov yog qhov seem ntawm cov cai uas hu rau Sine Wave Generator modules:

tsev qiv ntawv IEEE; siv IEEE. STD_LOGIC_1164. ALL; siv IEEE. NUMERIC_STD. ALL; qhov chaw Two_Octave_Synth yog Chaw Nres Nkoj (CLK: hauv STD_LOGIC; O4: hauv STD_LOGIC_VECTOR (11 downto 0); O5: hauv STD_LOGIC_VECTOR (12 downto 0); tso zis: tawm STD_LOGIC); kawg Ob_Octave_Synth; architecture Tus Cwj Pwm ntawm Two_Octave_Synth yog ib feem Wave_Generator yog Chaw Nres Nkoj (Ua rau: hauv STD_LOGIC; Freq_Cnt: hauv STD_LOGIC_VECTOR (15 downto 0); wavegenCLK: hauv STD_LOGIC; WaveOut: tawm STD_LOGIC_VECTOR (9 downto); 9 kawg tivthaiv; --------------------------- tso tawm cov cim los ntawm lub tshuab hluav taws xob ------------------ ----- teeb liab WaveC4, WaveCs4, WaveD4, WaveDs4, WaveE4, WaveF4, WaveFs4, WaveG4, WaveG4, WaveGs4, WaveA4, WaveAs4, WaveB4, WaveC5, WaveCs5, WaveD5, WaveDs5, WaveE5, WaveF5, WaveF5, WaveFs5, WaveG5, WaveGs5, WaveAs5, WaveB5, WaveC6: kos npe (9 downto 0); -------------------------------- rau kev ceeb toom xaiv logic -------------- ------ teeb liab C4, Cs4, D4, Ds4, E4, F4, Fs4, G4, Gs4, A4, As4, B4, C5, Cs5, D5, Ds5, E5, F5, Fs5, G5, Gs5, A5, As5, B5, C6: unsigned (4 downto 0); teeb liab cntC4, cntCs4, cntD4, cntDs4, cntE4, cntF4, cntFs4, cntG4, cntGs4, cntA4, cntAs4, cntB4, cntC5, cntCs5, cntD5, cntDs5, cntEnt, cnt, cnt, cnt, cnt, cnt, cnt, cnt, cnt, cnt, cnt, cnt, cnt, cnt, cnt: unsigned (4 downto rau 0); teeb liab yuam kev: STD_LOGIC; ----------------------------------- rau kev ntxiv sine wave ----------- --------------- teeb liab Wave0, Wave1, Wave2, Wave3: kos npe (9 downto 0); --signals los ntawm Wave Generator module tso zis teeb liab WaveSum: STD_LOGIC_VECTOR (9 downto 0); --sim rau sum sine wave (2 qhov kev qhuas -512 txog 511) teeb liab positiveWaveSum: STD_LOGIC_VECTOR (9 downto 0); --signed 0 rau 1023, rau siv hauv PWM generator ----------------------------------- rau tsim PWM ------------------------------- teeb liab ping_length: unsigned (9 downto 0): = unsigned (positiveWaveSum); --signal off_length: unsigned (6 downto 0): = to_unsigned (127, 7) -unsigned (WAVE); signal PWM: unsigned (9 downto 0): = to_unsigned (0, 10); pib Ceeb Toom_C4: Wave_Generator chaw nres nkoj daim ntawv qhia (Trigger => O4 (0), Freq_Cnt => X "1755", wavegenCLK => CLK, kos npe (WaveOut) => WaveC4); --5973, 261.63 Hz Note_Cs4: Wave_Generator chaw nres nkoj daim ntawv qhia (Trigger => O4 (1), Freq_Cnt => X "1606", wavegenCLK => CLK, kos npe (WaveOut) => WaveCs4);-5638, 277.18 Hz Nco ntsoov_D4: Wave_Generator chaw nres nkoj daim ntawv qhia (Trigger => O4 (2), Freq_Cnt => X "14C9", wavegenCLK => CLK, kos npe (WaveOut) => WaveD4); --5321, 293.66 Hz Note_Ds4: Wave_Generator chaw nres nkoj daim ntawv qhia (Trigger => O4 (3), Freq_Cnt => X "139F", wavegenCLK => CLK, kos npe (WaveOut) => WaveDs4);-5023, 311.13 Hz Note_E4: Wave_Generator chaw nres nkoj daim ntawv qhia (Trigger => O4 (4), Freq_Cnt => X "1285", wavegenCLK => CLK, kos npe (WaveOut) => WaveE4); --4741, 329.63 Hz Note_F4: Wave_Generator chaw nres nkoj daim ntawv qhia (Trigger => O4 (5), Freq_Cnt => X "117B", wavegenCLK => CLK, kos npe (WaveOut) => WaveF4); -4475, 349.23 Hz Note_Fs4: Wave_Generator chaw nres nkoj daim ntawv qhia (Trigger => O4 (6), Freq_Cnt => X "1080", wavegenCLK => CLK, kos npe (WaveOut) => WaveFs4);-4224, 369.99 Hz Note_G4: Wave_Generator chaw nres nkoj daim ntawv qhia (Trigger => O4 (7), Freq_Cnt => X "0F92", wavegenCLK => CLK, kos npe (WaveOut) => WaveG4); --3986, 392.00 Hz Note_Gs4: Wave_Generator chaw nres nkoj daim ntawv qhia (Trigger => O4 (8), Freq_Cnt => X "0EB3", wavegenCLK => CLK, kos npe (WaveOut) => WaveGs4);-3763, 415.30 Hz Note_A4: Wave_Generator chaw nres nkoj daim duab qhia chaw (Trigger => O4 (9), Freq_Cnt => X "0DE0", wavegenCLK => CLK, kos npe (WaveOut) => WaveA4); -3552, 440.00 Hz Note_As4: Wave_Generator chaw nres nkoj daim duab qhia chaw (Trigger => O4 (10), Freq_Cnt => X "0D18", wavegenCLK => CLK, kos npe (WaveOut) => WaveAs4);-3352, 466.16 Hz Note_B4: Wave_Generator chaw nres nkoj daim ntawv qhia (Trigger => O4 (11), Freq_Cnt => X "0C5C", wavegenCLK => CLK, kos npe (WaveOut) => WaveB4); -3164, 493.88 Hz -------------------------------------------- ----------------------------------------------------------------------- --------------------------- Note_C5: Wave_Generator chaw nres nkoj daim duab qhia chaw (Trigger => O5 (0), Freq_Cnt => X "0BAB", wavegenCLK => CLK, kos npe (WaveOut) => WaveC5); --2987, 523.25 Hz Note_Cs5: Wave_Generator chaw nres nkoj daim duab qhia chaw (Trigger => O5 (1), Freq_Cnt => X "0B03", wavegenCLK => CLK, kos npe (WaveOut) => WaveCs5);-2819, 554.37 Hz Nco ntsoov_D5: Wave_Generator chaw nres nkoj daim ntawv qhia (Trigger => O5 (2), Freq_Cnt => X "0A65", wavegenCLK => CLK, kos npe (WaveOut) => WaveD5); --2661, 587.33 Hz Note_Ds5: Wave_Generator chaw nres nkoj daim ntawv qhia (Trigger => O5 (3), Freq_Cnt => X "09D0", wavegenCLK => CLK, kos npe (WaveOut) => WaveDs5);-2512, 622.25 Hz Note_E5: Wave_Generator chaw nres nkoj daim ntawv qhia (Trigger => O5 (4), Freq_Cnt => X "0943", wavegenCLK => CLK, kos npe (WaveOut) => WaveE5); --2371, 659.25 Hz Note_F5: Wave_Generator chaw nres nkoj daim ntawv qhia (Trigger => O5 (5), Freq_Cnt => X "08Be", wavegenCLK => CLK, kos npe (WaveOut) => WaveF5); --2238, 698.46 Hz Note_Fs5: Wave_Generator chaw nres nkoj daim ntawv qhia (Trigger => O5 (6), Freq_Cnt => X "0840", wavegenCLK => CLK, kos npe (WaveOut) => WaveFs5);-2112, 739.99 Hz Note_G5: Wave_Generator chaw nres nkoj daim duab qhia chaw (Trigger => O5 (7), Freq_Cnt => X "07CA", wavegenCLK => CLK, kos npe (WaveOut) => WaveG5); --1994, 783.99 Hz Note_Gs5: Wave_Generator chaw nres nkoj daim ntawv qhia (Trigger => O5 (8), Freq_Cnt => X "075A", wavegenCLK => CLK, kos npe (WaveOut) => WaveGs5);-1882, 830.61 Hz Note_A5: Wave_Generator chaw nres nkoj daim duab qhia chaw (Trigger => O5 (9), Freq_Cnt => X "06F0", wavegenCLK => CLK, kos npe (WaveOut) => WaveA5); --1776, 880.00 Hz Note_As5: Wave_Generator chaw nres nkoj daim ntawv qhia (Trigger => O5 (10), Freq_Cnt => X "068C", wavegenCLK => CLK, kos npe (WaveOut) => WaveAs5);-1676, 932.33 Hz Note_B5: Wave_Generator chaw nres nkoj daim ntawv qhia (Trigger => O5 (11), Freq_Cnt => X "062E", wavegenCLK => CLK, kos npe (WaveOut) => WaveB5); --1582, 987.77 Hz Note_C6: Wave_Generator chaw nres nkoj daim ntawv qhia (Trigger => O5 (12), Freq_Cnt => X "05D6", wavegenCLK => CLK, kos npe (WaveOut) => WaveC6); --1494, 1046.5 Hz ------------ nco txog kev xaiv logic ------------ C4 <= "0000" & O4 (0); Cs4 <= "0000" & O4 (1); D4 <= "0000" & O4 (2); Ds4 <= "0000" & O4 (3); E4 <= "0000" & O4 (4); F4 <= "0000" & O4 (5); Fs4 <= "0000" & O4 (6); G4 <= "0000" & O4 (7); Gs4 <= "0000" & O4 (8); A4 <= "0000" & O4 (9); As4 <= "0000" & O4 (10); B4 <= "0000" & O4 (11); C5 <= "0000" & O5 (0); Cs5 <= "0000" & O5 (1); D5 <= "0000" & O5 (2); Ds5 <= "0000" & O5 (3); E5 <= "0000" & O5 (4); F5 <= "0000" & O5 (5); Fs5 <= "0000" & O5 (6); G5 <= "0000" & O5 (7); Gs5 <= "0000" & O5 (8); A5 <= "0000" & O5 (9); As5 <= "0000" & O5 (10); B5 <= "0000" & O5 (11); C6 <= "0000" & O5 (12); cntC4 <= C4; cntCs4 <= C4 + Cs4; cntD4 <= C4 + Cs4 + D4; cntDs4 <= C4 + Cs4 + D4 + Ds4; cntE4 <= C4 + Cs4 + D4 + Ds4 + E4; cntF4 <= C4 + Cs4 + D4 + Ds4 + E4 + F4; cntFs4 <= C4 + Cs4 + D4 + Ds4 + E4 + F4 + Fs4; cntG4 <= C4 + Cs4 + D4 + Ds4 + E4 + F4 + Fs4 + G4; cntGs4 <= C4 + Cs4 + D4 + Ds4 + E4 + F4 + Fs4 + G4 + Gs4; cntA4 <= C4 + Cs4 + D4 + Ds4 + E4 + F4 + Fs4 + G4 + Gs4 + A4; cntAs4 <= C4 + Cs4 + D4 + Ds4 + E4 + F4 + Fs4 + G4 + Gs4 + A4 + As4; cntB4 <= C4 + Cs4 + D4 + Ds4 + E4 + F4 + Fs4 + G4 + Gs4 + A4 + As4 + B4; cntC5 <= C4 + Cs4 + D4 + Ds4 + E4 + F4 + Fs4 + G4 + Gs4 + A4 + As4 + B4 + C5; cntCs5 <= C4 + Cs4 + D4 + Ds4 + E4 + F4 + Fs4 + G4 + Gs4 + A4 + As4 + B4 + C5 + Cs5; cntD5 <= C4 + Cs4 + D4 + Ds4 + E4 + F4 + Fs4 + G4 + Gs4 + A4 + As4 + B4 + C5 + Cs5 + D5; cntDs5 <= C4 + Cs4 + D4 + Ds4 + E4 + F4 + Fs4 + G4 + Gs4 + A4 + As4 + B4 + C5 + Cs5 + D5 + Ds5; cntE5 <= C4 + Cs4 + D4 + Ds4 + E4 + F4 + Fs4 + G4 + Gs4 + A4 + As4 + B4 + C5 + Cs5 + D5 + Ds5 + E5; cntF5 <= C4 + Cs4 + D4 + Ds4 + E4 + F4 + Fs4 + G4 + Gs4 + A4 + As4 + B4 + C5 + Cs5 + D5 + Ds5 + E5 + F5; cntFs5 <= C4 + Cs4 + D4 + Ds4 + E4 + F4 + Fs4 + G4 + Gs4 + A4 + As4 + B4 + C5 + Cs5 + D5 + Ds5 + E5 + F5 + Fs5; cntG5 <= C4 + Cs4 + D4 + Ds4 + E4 + F4 + Fs4 + G4 + Gs4 + A4 + As4 + B4 + C5 + Cs5 + D5 + Ds5 + E5 + F5 + Fs5 + G5; cntGs5 <= C4 + Cs4 + D4 + Ds4 + E4 + F4 + Fs4 + G4 + Gs4 + A4 + As4 + B4 + C5 + Cs5 + D5 + Ds5 + E5 + F5 + Fs5 + G5 + Gs5; cntA5 <= C4 + Cs4 + D4 + Ds4 + E4 + F4 + Fs4 + G4 + Gs4 + A4 + As4 + B4 + C5 + Cs5 + D5 + Ds5 + E5 + F5 + Fs5 + G5 + Gs5 + A5; cntAs5 <= C4 + Cs4 + D4 + Ds4 + E4 + F4 + Fs4 + G4 + Gs4 + A4 + As4 + B4 + C5 + Cs5 + D5 + D5 + E5 + F5 + Fs5 + G5 + Gs5 + A5 + As5; cntB5 <= C4 + Cs4 + D4 + Ds4 + E4 + F4 + Fs4 + G4 + Gs4 + A4 + As4 + B4 + C5 + Cs5 + D5 + D5 + E5 + F5 + Fs5 + G5 + Gs5 + A5 + As5 + B5; cntC6 <= C4 + Cs4 + D4 + Ds4 + E4 + F4 + Fs4 + G4 + Gs4 + A4 + As4 + B4 + C5 + Cs5 + D5 + D5 + E5 + F5 + Fs5 + G5 + Gs5 + A5 + As5 + B5 + C6; Kev xaiv: txheej txheem (WaveC4, WaveCs4, WaveD4, WaveDs4, WaveE4, WaveF4, WaveFs4, WaveG4, WaveG4, WaveGs4, WaveA4, WaveAs4, WaveB4, WaveC5, WaveCs5, WaveD5, WaveDs5, WaveE5, WaveF5, WaveFs5, WaveG5, Wave5s, WaveB5, WaveC6) pib yog (cntC6 = "00000") ces --------------- yog tias tsis muaj cov cim qhia tau tsim Wave0 <= "0000000000"; Wave1 <= "0000000000"; Wave2 <= "0000000000"; Wave3 <= "0000000000"; lwm tus yog (O4 (0) = '1') ces ------------------- nco C4 ua si Wave0 Wave0 Wave1 yuam kev Wave0 Wave1 Wave2 yuam kev Wave0 Wave1 Wave2 Wave3 yuam kev Wave0 Wave1 Wave2 Wave3 yuam kev Wave0 Wave1 Wave2 Wave3 yuam kev Wave0 Wave1 Wave2 Wave3 yuam kev Wave0 Wave1 Wave2 yuam kev Wave0 Wave1 Wave2 Wave3 yuam kev 0 Wave1 Wave2 Wave3 yuam kev Wave0 Wave1 Wave2 Wave3 yuam kev Wave0 Wave1 Wave2 Wave3 yuam kev Wave0 Wave1 wave2 yuam kev Wave0 Wave1 Wave2 Wave3 yuam kev = WaveC6; Wave1 <= "0000000000"; Wave2 <= "0000000000"; Wave3 Wave1 <= WaveC6; Wave2 <= "0000000000"; Wave3 Wave2 <= WaveC6; Wave3 Wave3 yuam kev Wave1 <= "0000000000"; Wave2 <= "0000000000"; Wave3 Wave2 <= "0000000000"; Wave3 Wave3 yuam kev <= '1'; rooj plaub xaus; kawg yog; kawg yog; txheej txheem kawg; ------------- sine wave adder -------------------- WaveSum <= STD_LOGIC_VECTOR (Wave0 + Wave1 + Wave2 + Wave3); --------- ua sine wave positive rau pwm --------------------- positiveWaveSum <= tsis WaveSum (9) & WaveSum (8 downto 0); ------------- PWM generator --------------------- process (CLK) --variable count: unsigned (1 downto 0): = to_signed (0, 2); pib yog (nce_edge (CLK)) ces -suav: = suav + 1; --if (suav = to_unsigned (4, 2)) ces --count: = to_unsigned (0, 2); --if (PWM = to_ if (PWM <ping_length) then output <= '1'; else output <= '0'; end if; PWM <= PWM + 1; ping_length <= unsigned (positiveWaveSum); --end yog; xaus yog; xaus txheej txheem; xaus Tus Cwj Pwm;

4 Nco Ntsoov Selector Qhov nyuaj tshaj plaws ntawm txoj haujlwm no yog xaiv tsuas yog plaub zaus. Peb tau ua nws nrog tag nrho lotta IF cov lus, thiab peb siv cov cim qhia tsis hloov pauv kom cov txheej txheem tuaj yeem simulated thiab debugged. Peb tau sim lwm txoj hauv kev siv qhov sib txawv thiab FOR loops, tab sis tau khiav mus rau lub sijhawm tsis raug. Yog li, thaum kawg, peb txiav txim siab tias yog nws ua haujlwm, peb yuav tso nws ib leeg. Tsis kho qhov uas tsis tawg amirite?

Plaub qhov tso tawm nthwv dej tau sau tias Wave0, Wave1, Wave2, Wave3 - cov no yog dab tsi uas yuav muab ntxiv ua ke los ua qhov tso tawm zaum kawg.

Saib ntawm txoj cai, koj yuav pom ntau pawg cim qhia tias yog C4, Cs4, D4, Ds4, thiab lwm yam. 5-ntsis rau ntxiv.

Tom ntej no cntC4, cntCs4, thiab lwm yam kev hloov pauv sawv cev pes tsawg daim ntawv qis dua lub hom phiaj tau ua si, suav nrog lub hom phiaj ceeb toom. Piv txwv, yog C4, E4, G4, A#4, thiab D5 tau ua si (C9 chord) cntC4 yuav yog 1, cntE4 yuav yog 2, cntG4 yuav yog 3, thiab lwm yam.

Tom qab ntawd, thaum twg los xij uas tau sau ntawv, suav rau lub hom phiaj sau tseg yuav raug tshuaj xyuas kom pom qhov twg los txhawm rau sau cov ntawv ceeb toom. Piv txwv li, yog D5 sau ntawv ua si (uas txhais tau tias O5 (2) siab dua) thiab cntD5 yog 3, tam sim no muaj 3 cov ntawv tau ua si, nrog 2 cov ntawv qis dua D5, yog li peb yuav nuv waveD5 rau Wave2 (nthwv peb teeb liab suav los ntawm Wave0). Xwb, yog cntD5 yog 5, tam sim no muaj 5 cov ntawv sau ua si, nrog 4 cov ntawv qis dua D5, yog li peb yuav cia li tso waveD5 dai thiab tsis ua dab tsi nrog nws.

Cov lus IF yog tom qab ntawd txhawm rau npog cov ntaub ntawv rau txhua 25 ntawv.

Amplitude Adder Cov

Tom qab qhov qis tshaj 4 ntus raug xaiv peb yuav tsum ntxiv lawv ua ke. Qhov laj thawj peb tsuas yog ntxiv plaub daim ntawv ua ke vim tias PWM lub tswv yim peb siv rau peb cov khoom tuaj yeem tsuas muaj qhov kev daws teeb meem kom txog thaum PWM khiav qeeb dhau thiab tus hais lus yuav pib khaws PWM square yoj. Piv txwv li, yog tias peb yuav siv qhov kev daws teeb meem ntawm 8192 (13 ntsis), txhua qhov ntawm 8192 cov ntsiab lus yuav tsum sib haum mus rau qhov nce ntawm ntug ntawm lub moos onboard. Yog li, 100MHz / 8192 = 12.2kHz, uas zoo nyob hauv thaj tsam ntawm tib neeg kev hnov lus.

Qhov sib ntxiv ntawm qhov dav yog yooj yim heev, koj tsuas yog yuav tsum paub tseeb tias nws tuaj yeem ua haujlwm nrawm heev.

PWM Output

PWM lub luag haujlwm hloov pauv yuav sawv cev rau qhov dav ntawm peb cov nthwv dej tawm tam sim ntawd. Piv txwv li, yog tias peb muaj qhov ntau ntawm 0 txog 128, 0 yuav yog 0%kev ua haujlwm, 64 yuav yog 50%, 128 yuav yog 100%, thiab lwm yam. PWM no yuav khiav nrawm heev (peb yog 97.6 kHz), nrawm heev uas tus neeg hais lus yuav tsis lees paub tus kheej ib puag ncig nthwv dej thiab hloov chaw saib qhov nruab nrab qhov hluav taws xob, tsim peb li "analog" teeb liab.

Cov ntaub ntawv txwv

Tej zaum koj yuav tau sib txuas koj cov cuab yeej sib txawv, yog li tsuas yog ua kom ntseeg tau tias cov ntaub ntawv txwv tsis pub sib phim.

Kauj ruam 5: Code Downloads

Hauv qab no yog cov cai, ob qho tib si hauv.txt hom thiab.vhd rau Vivado. Wave_Generator yog lub tshuab hluav taws xob tsim hluav taws xob sub-module, thiab Two_Octave_Synth yog cov qauv sab saum toj nrog txhua yam ntxiv.

Pom zoo: