-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #187 from anton-malakhov/osciloscope
Oscilloscope lab
- Loading branch information
Showing
18 changed files
with
505 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -Eeuo pipefail # See the meaning in scripts/README.md | ||
|
||
script=$(basename "$0") | ||
source_script=${script/\.bash/.source_bash} | ||
dir_source_script=../scripts/steps/$source_script | ||
|
||
for i in {1..3} | ||
do | ||
[ -f $dir_source_script ] && break | ||
dir_source_script=../$dir_source_script | ||
done | ||
|
||
if ! [ -f $dir_source_script ]; then | ||
printf "$script: cannot find \"$source_script\"\n" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
dir_source_script=$(readlink -f $dir_source_script) | ||
. "$dir_source_script" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -Eeuo pipefail # See the meaning in scripts/README.md | ||
|
||
script=$(basename "$0") | ||
source_script=${script/\.bash/.source_bash} | ||
dir_source_script=../scripts/steps/$source_script | ||
|
||
for i in {1..3} | ||
do | ||
[ -f $dir_source_script ] && break | ||
dir_source_script=../$dir_source_script | ||
done | ||
|
||
if ! [ -f $dir_source_script ]; then | ||
printf "$script: cannot find \"$source_script\"\n" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
dir_source_script=$(readlink -f $dir_source_script) | ||
. "$dir_source_script" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -Eeuo pipefail # See the meaning in scripts/README.md | ||
|
||
script=$(basename "$0") | ||
source_script=${script/\.bash/.source_bash} | ||
dir_source_script=../scripts/steps/$source_script | ||
|
||
for i in {1..3} | ||
do | ||
[ -f $dir_source_script ] && break | ||
dir_source_script=../$dir_source_script | ||
done | ||
|
||
if ! [ -f $dir_source_script ]; then | ||
printf "$script: cannot find \"$source_script\"\n" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
dir_source_script=$(readlink -f $dir_source_script) | ||
. "$dir_source_script" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -Eeuo pipefail # See the meaning in scripts/README.md | ||
|
||
script=$(basename "$0") | ||
source_script=${script/\.bash/.source_bash} | ||
dir_source_script=../scripts/steps/$source_script | ||
|
||
for i in {1..3} | ||
do | ||
[ -f $dir_source_script ] && break | ||
dir_source_script=../$dir_source_script | ||
done | ||
|
||
if ! [ -f $dir_source_script ]; then | ||
printf "$script: cannot find \"$source_script\"\n" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
dir_source_script=$(readlink -f $dir_source_script) | ||
. "$dir_source_script" |
21 changes: 21 additions & 0 deletions
21
labs/3_music/3_0_oscilloscope/05_run_gui_for_fpga_synthesis.bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -Eeuo pipefail # See the meaning in scripts/README.md | ||
|
||
script=$(basename "$0") | ||
source_script=${script/\.bash/.source_bash} | ||
dir_source_script=../scripts/steps/$source_script | ||
|
||
for i in {1..3} | ||
do | ||
[ -f $dir_source_script ] && break | ||
dir_source_script=../$dir_source_script | ||
done | ||
|
||
if ! [ -f $dir_source_script ]; then | ||
printf "$script: cannot find \"$source_script\"\n" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
dir_source_script=$(readlink -f $dir_source_script) | ||
. "$dir_source_script" |
21 changes: 21 additions & 0 deletions
21
labs/3_music/3_0_oscilloscope/06_choose_another_fpga_board.bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -Eeuo pipefail # See the meaning in scripts/README.md | ||
|
||
script=$(basename "$0") | ||
source_script=${script/\.bash/.source_bash} | ||
dir_source_script=../scripts/steps/$source_script | ||
|
||
for i in {1..3} | ||
do | ||
[ -f $dir_source_script ] && break | ||
dir_source_script=../$dir_source_script | ||
done | ||
|
||
if ! [ -f $dir_source_script ]; then | ||
printf "$script: cannot find \"$source_script\"\n" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
dir_source_script=$(readlink -f $dir_source_script) | ||
. "$dir_source_script" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -Eeuo pipefail # See the meaning in scripts/README.md | ||
|
||
script=$(basename "$0") | ||
source_script=${script/\.bash/.source_bash} | ||
dir_source_script=../scripts/steps/$source_script | ||
|
||
for i in {1..3} | ||
do | ||
[ -f $dir_source_script ] && break | ||
dir_source_script=../$dir_source_script | ||
done | ||
|
||
if ! [ -f $dir_source_script ]; then | ||
printf "$script: cannot find \"$source_script\"\n" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
dir_source_script=$(readlink -f $dir_source_script) | ||
. "$dir_source_script" |
21 changes: 21 additions & 0 deletions
21
labs/3_music/3_0_oscilloscope/08_visualize_asic_synthesis_results_1.bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -Eeuo pipefail # See the meaning in scripts/README.md | ||
|
||
script=$(basename "$0") | ||
source_script=${script/\.bash/.source_bash} | ||
dir_source_script=../scripts/steps/$source_script | ||
|
||
for i in {1..3} | ||
do | ||
[ -f $dir_source_script ] && break | ||
dir_source_script=../$dir_source_script | ||
done | ||
|
||
if ! [ -f $dir_source_script ]; then | ||
printf "$script: cannot find \"$source_script\"\n" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
dir_source_script=$(readlink -f $dir_source_script) | ||
. "$dir_source_script" |
21 changes: 21 additions & 0 deletions
21
labs/3_music/3_0_oscilloscope/09_visualize_asic_synthesis_results_2.bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -Eeuo pipefail # See the meaning in scripts/README.md | ||
|
||
script=$(basename "$0") | ||
source_script=${script/\.bash/.source_bash} | ||
dir_source_script=../scripts/steps/$source_script | ||
|
||
for i in {1..3} | ||
do | ||
[ -f $dir_source_script ] && break | ||
dir_source_script=../$dir_source_script | ||
done | ||
|
||
if ! [ -f $dir_source_script ]; then | ||
printf "$script: cannot find \"$source_script\"\n" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
dir_source_script=$(readlink -f $dir_source_script) | ||
. "$dir_source_script" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# gtkwave::loadFile "dump.vcd" | ||
|
||
set all_signals [list] | ||
|
||
lappend all_signals tb.dut.clk | ||
lappend all_signals tb.dut.rst | ||
lappend all_signals tb.dut.lr | ||
lappend all_signals tb.dut.ws | ||
lappend all_signals tb.dut.sck | ||
lappend all_signals tb.dut.sd | ||
lappend all_signals tb.dut.value | ||
lappend all_signals tb.dut.cnt | ||
lappend all_signals tb.dut.sample_bit | ||
lappend all_signals tb.dut.value_done | ||
lappend all_signals tb.dut.shift | ||
|
||
set num_added [ gtkwave::addSignalsFromList $all_signals ] | ||
|
||
gtkwave::/Time/Zoom/Zoom_Full |
18 changes: 18 additions & 0 deletions
18
labs/3_music/3_0_oscilloscope/lab_specific_board_config.svh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
`ifndef LAB_SPECIFIC_CONFIG_SVH | ||
`define LAB_SPECIFIC_CONFIG_SVH | ||
|
||
`define INSTANTIATE_TM1638_BOARD_CONTROLLER_MODULE | ||
`define FORCE_NO_VIRTUAL_TM1638_USING_GRAPHICS | ||
// `define USE_HCW132_VARIANT_OF_TM1638_BOARD_CONTROLLER_MODULE | ||
|
||
`define DUPLICATE_TM1638_SIGNALS_WITH_REGULAR | ||
// `define CONCAT_REGULAR_SIGNALS_AND_TM1638 | ||
// `define CONCAT_TM1638_SIGNALS_AND_REGULAR | ||
|
||
`define EMULATE_DYNAMIC_7SEG_ON_STATIC_WITHOUT_STICKY_FLOPS | ||
|
||
`define INSTANTIATE_GRAPHICS_INTERFACE_MODULE | ||
`define INSTANTIATE_MICROPHONE_INTERFACE_MODULE | ||
`define INSTANTIATE_SOUND_OUTPUT_INTERFACE_MODULE | ||
|
||
`endif // `ifndef LAB_SPECIFIC_CONFIG_SVH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
`include "config.svh" | ||
|
||
module lab_top | ||
# ( | ||
parameter clk_mhz = 50, | ||
w_key = 4, | ||
w_sw = 8, | ||
w_led = 8, | ||
w_digit = 8, | ||
w_gpio = 100, | ||
|
||
screen_width = 640, | ||
screen_height = 480, | ||
|
||
w_red = 4, | ||
w_green = 4, | ||
w_blue = 4, | ||
|
||
w_x = $clog2 ( screen_width ), | ||
w_y = $clog2 ( screen_height ) | ||
) | ||
( | ||
input clk, | ||
input slow_clk, | ||
input rst, | ||
|
||
// Keys, switches, LEDs | ||
|
||
input [w_key - 1:0] key, | ||
input [w_sw - 1:0] sw, | ||
output logic [w_led - 1:0] led, | ||
|
||
// A dynamic seven-segment display | ||
|
||
output logic [ 7:0] abcdefgh, | ||
output logic [w_digit - 1:0] digit, | ||
|
||
// Graphics | ||
|
||
input [w_x - 1:0] x, | ||
input [w_y - 1:0] y, | ||
|
||
output logic [w_red - 1:0] red, | ||
output logic [w_green - 1:0] green, | ||
output logic [w_blue - 1:0] blue, | ||
|
||
// Microphone, sound output and UART | ||
|
||
input [ 23:0] mic, | ||
output [ 15:0] sound, | ||
|
||
input uart_rx, | ||
output uart_tx, | ||
|
||
// General-purpose Input/Output | ||
|
||
inout [w_gpio - 1:0] gpio | ||
); | ||
|
||
//------------------------------------------------------------------------ | ||
|
||
// assign led = '0; | ||
// assign abcdefgh = '0; | ||
// assign digit = '0; | ||
// assign red = '0; | ||
// assign green = '0; | ||
// assign blue = '0; | ||
assign sound = '0; | ||
assign uart_tx = '1; | ||
|
||
logic white; | ||
assign red = {w_red {white}}; | ||
assign green = {w_green{white}}; | ||
assign blue = {w_blue {white}}; | ||
|
||
|
||
//------------------------------------------------------------------------ | ||
// | ||
// Oscilloscope | ||
// | ||
//------------------------------------------------------------------------ | ||
|
||
// It is enough for the counter to be 20 bit. Why? | ||
|
||
logic [23:0] prev_mic; | ||
logic [19:0] counter; | ||
logic [19:0] distance; | ||
logic signed [w_y-1:0] bufy[screen_width/2]; | ||
wire signed [w_y-1:0] micy = {mic[23], (mic[23]?~&mic[22:16]:|mic[22:16])? ~{(w_y-1){$signed(mic[23])}} : mic[15-:w_y-1]}; | ||
wire [w_x-1:0] cnt = counter[19-:w_x]; | ||
localparam logic signed [w_y-1:0] midy = screen_height/2; | ||
|
||
always_comb | ||
white = (x>>1) < (distance[19-:w_x]) && y == midy - bufy[(x>>1)] && x < screen_width && y < screen_height; | ||
|
||
always_ff @ (posedge clk or posedge rst) | ||
if (rst) | ||
begin | ||
prev_mic <= '0; | ||
counter <= '0; | ||
distance <= '0; | ||
end | ||
else | ||
begin | ||
if (cnt < screen_width/2) | ||
bufy[cnt] <= micy; | ||
|
||
prev_mic <= mic; | ||
|
||
// Crossing from negative to positive numbers | ||
if ( prev_mic [$left ( prev_mic )] == 1'b1 | ||
& mic [$left ( mic )] == 1'b0 ) | ||
begin | ||
distance <= counter; | ||
counter <= 20'h0; | ||
end | ||
else if (counter != ~ 20'h0) // To prevent overflow | ||
begin | ||
counter <= counter + 20'h1; | ||
end | ||
end | ||
|
||
endmodule |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.