Mudanças entre as edições de "Exemplo de uso de memória para a geração de sinais"
Ir para navegação
Ir para pesquisar
Linha 24: | Linha 24: | ||
* No Quartus II abra o arquivo signal.mif [File > Open {signal.mif}] | * No Quartus II abra o arquivo signal.mif [File > Open {signal.mif}] | ||
* Adicione o arquivo ao projeto [Project > Add Current File to Project] | * Adicione o arquivo ao projeto [Project > Add Current File to Project] | ||
+ | * Compile o projeto e verifique se não ocorrem erros. | ||
+ | |||
+ | ==Simulando o projeto no modelsim== | ||
+ | * Execute o Modelsim-Altera a partir do Quartus II [Tools > Run EDA Simulation Tool > EDA RTL Simulation] | ||
+ | * Execute o arquivo teste.do mostrado a seguir. | ||
+ | {{collapse top | testeROM.do}} | ||
+ | <syntaxhighlight lang=tcl> | ||
+ | vcom -93 -work work {../../testrom.vhd} | ||
+ | vsim work.testrom | ||
+ | add wave -noupdate /testrom/clock | ||
+ | add wave -noupdate /testrom/address_a | ||
+ | add wave -noupdate -color Blue -format Analog-Step -height 84 -max 127.0 -min -128.0 -radix decimal /testrom/q_a | ||
+ | add wave -noupdate /testrom/address_b | ||
+ | add wave -noupdate -color Blue -format Analog-Step -height 84 -max 127.0 -min -128.0 -radix decimal /testrom/q_b | ||
+ | |||
+ | force -freeze sim:/testrom/clock 1 0, 0 {50 ps} -r 100 | ||
+ | force -freeze sim:/testrom/address_a 10#0 0 | ||
+ | noforce sim:/testrom/address_a | ||
+ | force -freeze sim:/testrom/address_b 10#0 0 | ||
+ | noforce sim:/testrom/address_b | ||
+ | |||
+ | force -freeze sim:/testrom/address_b(0) 1 0, 0 {100 ps} -r 200 | ||
+ | force -freeze sim:/testrom/address_b(1) 1 0, 0 {200 ps} -r 400 | ||
+ | force -freeze sim:/testrom/address_b(2) 1 0, 0 {400 ps} -r 800 | ||
+ | force -freeze sim:/testrom/address_b(3) 1 0, 0 {800 ps} -r 1600 | ||
+ | force -freeze sim:/testrom/address_b(4) 1 0, 0 {1600 ps} -r 3200 | ||
+ | force -freeze sim:/testrom/address_b(5) 1 0, 0 {3200 ps} -r 6400 | ||
+ | force -freeze sim:/testrom/address_b(6) 1 0, 0 {6400 ps} -r 12800 | ||
+ | force -freeze sim:/testrom/address_b(7) 1 0, 0 {12800 ps} -r 25600 | ||
+ | force -freeze sim:/testrom/address_b(8) 1 0, 0 {25600 ps} -r 51200 | ||
+ | force -freeze sim:/testrom/address_b(9) 1 0, 0 {51200 ps} -r 102400 | ||
+ | |||
+ | run 2000 | ||
+ | force -freeze sim:/testrom/address_a(0) 1 0, 0 {100 ps} -r 200 | ||
+ | force -freeze sim:/testrom/address_a(1) 1 0, 0 {200 ps} -r 400 | ||
+ | force -freeze sim:/testrom/address_a(2) 1 0, 0 {400 ps} -r 800 | ||
+ | force -freeze sim:/testrom/address_a(3) 1 0, 0 {800 ps} -r 1600 | ||
+ | force -freeze sim:/testrom/address_a(4) 1 0, 0 {1600 ps} -r 3200 | ||
+ | force -freeze sim:/testrom/address_a(5) 1 0, 0 {3200 ps} -r 6400 | ||
+ | force -freeze sim:/testrom/address_a(6) 1 0, 0 {6400 ps} -r 12800 | ||
+ | force -freeze sim:/testrom/address_a(7) 1 0, 0 {12800 ps} -r 25600 | ||
+ | force -freeze sim:/testrom/address_a(8) 1 0, 0 {25600 ps} -r 51200 | ||
+ | force -freeze sim:/testrom/address_a(9) 1 0, 0 {51200 ps} -r 102400 | ||
+ | run 100000 | ||
+ | WaveRestoreZoom {0 ps} {1000000 ps} | ||
+ | </syntaxhighlight> | ||
+ | {{collapse bottom}} |
Edição das 16h10min de 3 de julho de 2012
Para exemplificar o uso da memória na geração de sinais utilizaremos como exemplo uma memória ROM de duas portas, a qual será inicializada com valores obtidos a partir de um arquivo .wav.
O que você vai apreender
Este exemplo cobre os seguintes tópicos:
- Como criar uma memória ROM usando o MegaWizard da Altera
- Como inicializar a memória com um arquivo signal.mif
- Como simular a leitura da memória ROM usando o Modelsim
- Como obter o arquivo signal.mif a partir de um arquivo signal.wav
- Como obter o arquivo signal.wav usando o Audacity
Criando uma memória ROM com o MegaWizard
- Crie uma pasta PROJETO
- Inicie um projeto no Quartus usando [File > New Project Wizard]
- Configure a memória ROM usando o MegaWizard [Tools > MegaWizard Plug-In Manager]
- Selecione (x) Create a new custom megafunction variation [NEXT] (page 1)
- Selecione em [Select a megafunction from the list below > Memory Compiler > ROM: 2-PORT] e de um nome ao arquivo [NEXT] (page 2)
- Mude apenas [How many 8-bits words of memory? -> 1024] [NEXT] (page 3)
- [NEXT] (page 4)
- [NEXT] (page 6)
- Selecione (x) Yes, use this file for the memory content data. Digite em File name: {signal.mif} [NEXT] (page 8)
- [NEXT] (page 9)
- [FINISH] (page 10)
Inicializando a memória com o signal.mif
- Copie o arquivo signal.mif para a pasta PROJETO
- No Quartus II abra o arquivo signal.mif [File > Open {signal.mif}]
- Adicione o arquivo ao projeto [Project > Add Current File to Project]
- Compile o projeto e verifique se não ocorrem erros.
Simulando o projeto no modelsim
- Execute o Modelsim-Altera a partir do Quartus II [Tools > Run EDA Simulation Tool > EDA RTL Simulation]
- Execute o arquivo teste.do mostrado a seguir.
testeROM.do |
---|
vcom -93 -work work {../../testrom.vhd}
vsim work.testrom
add wave -noupdate /testrom/clock
add wave -noupdate /testrom/address_a
add wave -noupdate -color Blue -format Analog-Step -height 84 -max 127.0 -min -128.0 -radix decimal /testrom/q_a
add wave -noupdate /testrom/address_b
add wave -noupdate -color Blue -format Analog-Step -height 84 -max 127.0 -min -128.0 -radix decimal /testrom/q_b
force -freeze sim:/testrom/clock 1 0, 0 {50 ps} -r 100
force -freeze sim:/testrom/address_a 10#0 0
noforce sim:/testrom/address_a
force -freeze sim:/testrom/address_b 10#0 0
noforce sim:/testrom/address_b
force -freeze sim:/testrom/address_b(0) 1 0, 0 {100 ps} -r 200
force -freeze sim:/testrom/address_b(1) 1 0, 0 {200 ps} -r 400
force -freeze sim:/testrom/address_b(2) 1 0, 0 {400 ps} -r 800
force -freeze sim:/testrom/address_b(3) 1 0, 0 {800 ps} -r 1600
force -freeze sim:/testrom/address_b(4) 1 0, 0 {1600 ps} -r 3200
force -freeze sim:/testrom/address_b(5) 1 0, 0 {3200 ps} -r 6400
force -freeze sim:/testrom/address_b(6) 1 0, 0 {6400 ps} -r 12800
force -freeze sim:/testrom/address_b(7) 1 0, 0 {12800 ps} -r 25600
force -freeze sim:/testrom/address_b(8) 1 0, 0 {25600 ps} -r 51200
force -freeze sim:/testrom/address_b(9) 1 0, 0 {51200 ps} -r 102400
run 2000
force -freeze sim:/testrom/address_a(0) 1 0, 0 {100 ps} -r 200
force -freeze sim:/testrom/address_a(1) 1 0, 0 {200 ps} -r 400
force -freeze sim:/testrom/address_a(2) 1 0, 0 {400 ps} -r 800
force -freeze sim:/testrom/address_a(3) 1 0, 0 {800 ps} -r 1600
force -freeze sim:/testrom/address_a(4) 1 0, 0 {1600 ps} -r 3200
force -freeze sim:/testrom/address_a(5) 1 0, 0 {3200 ps} -r 6400
force -freeze sim:/testrom/address_a(6) 1 0, 0 {6400 ps} -r 12800
force -freeze sim:/testrom/address_a(7) 1 0, 0 {12800 ps} -r 25600
force -freeze sim:/testrom/address_a(8) 1 0, 0 {25600 ps} -r 51200
force -freeze sim:/testrom/address_a(9) 1 0, 0 {51200 ps} -r 102400
run 100000
WaveRestoreZoom {0 ps} {1000000 ps}
|