From d4db57083959813c7032143d565b5be76808f70f Mon Sep 17 00:00:00 2001 From: Seemebadnekai <51400137+SagarDevAchar@users.noreply.github.com> Date: Thu, 29 Aug 2024 06:05:08 +0530 Subject: [PATCH] Some code cleanup --- src/audio_engine.v | 24 +++++++++++------------- src/text_demosiine.v | 19 +++++++++---------- src/text_sda.v | 20 ++++++++++---------- src/text_tt08.v | 18 +++++++++--------- src/vga_controller.v | 30 +++++++++++++++--------------- 5 files changed, 54 insertions(+), 57 deletions(-) diff --git a/src/audio_engine.v b/src/audio_engine.v index f1921f0..2595d4c 100644 --- a/src/audio_engine.v +++ b/src/audio_engine.v @@ -4,20 +4,18 @@ module audio_engine( output wire audio, input wire clk, rst_n ); - - //TODO: Eliminate NOTE_G3 - parameter [6:0] NOTE_B1 = 7'd100; - parameter [6:0] NOTE_D2 = 7'd84; - parameter [6:0] NOTE_E2 = 7'd74; - parameter [6:0] NOTE_F2 = 7'd70; - parameter [6:0] NOTE_G2 = 7'd62; - parameter [6:0] NOTE_A2 = 7'd55; - parameter [6:0] NOTE_C3 = 7'd47; - parameter [6:0] NOTE_D3 = 7'd42; - parameter [6:0] NOTE_E3 = 7'd37; - parameter [6:0] NOTE_F3 = 7'd35; - parameter [6:0] NOTE_A3 = 7'd28; + localparam [6:0] NOTE_B1 = 7'd100; + localparam [6:0] NOTE_D2 = 7'd84; + localparam [6:0] NOTE_E2 = 7'd74; + localparam [6:0] NOTE_F2 = 7'd70; + localparam [6:0] NOTE_G2 = 7'd62; + localparam [6:0] NOTE_A2 = 7'd55; + localparam [6:0] NOTE_C3 = 7'd47; + localparam [6:0] NOTE_D3 = 7'd42; + localparam [6:0] NOTE_E3 = 7'd37; + localparam [6:0] NOTE_F3 = 7'd35; + localparam [6:0] NOTE_A3 = 7'd28; function [6:0] seq_lut (input [6:0] timestamp); begin diff --git a/src/text_demosiine.v b/src/text_demosiine.v index e8662ad..ca153f6 100644 --- a/src/text_demosiine.v +++ b/src/text_demosiine.v @@ -6,16 +6,15 @@ module text_demosiine( input wire [8:0] y ); - // TODO: Try array-based optimization - parameter [45:0] demosiine_line0 = 46'b0000000000000000001110000000000000000000001111; - parameter [45:0] demosiine_line1 = 46'b0000000000000000000001000000000000000000010001; - parameter [45:0] demosiine_line2 = 46'b0000000000000000000000100000000000000000100001; - parameter [45:0] demosiine_line3 = 46'b0000000000000000000000100000000000000000100001; - parameter [45:0] demosiine_line4 = 46'b1111010010111011100111000110010001011110100001; - parameter [45:0] demosiine_line5 = 46'b0001010110010001001000001001011011000010100001; - parameter [45:0] demosiine_line6 = 46'b0111011010010001001000001001010101001110100001; - parameter [45:0] demosiine_line7 = 46'b0001010010010001000100001001010001000010010001; - parameter [45:0] demosiine_line8 = 46'b1111010010111011100011100110010001011110001111; + localparam [45:0] demosiine_line0 = 46'b0000000000000000001110000000000000000000001111; + localparam [45:0] demosiine_line1 = 46'b0000000000000000000001000000000000000000010001; + localparam [45:0] demosiine_line2 = 46'b0000000000000000000000100000000000000000100001; + localparam [45:0] demosiine_line3 = 46'b0000000000000000000000100000000000000000100001; + localparam [45:0] demosiine_line4 = 46'b1111010010111011100111000110010001011110100001; + localparam [45:0] demosiine_line5 = 46'b0001010110010001001000001001011011000010100001; + localparam [45:0] demosiine_line6 = 46'b0111011010010001001000001001010101001110100001; + localparam [45:0] demosiine_line7 = 46'b0001010010010001000100001001010001000010010001; + localparam [45:0] demosiine_line8 = 46'b1111010010111011100011100110010001011110001111; wire [6:0] demosiine_off_x; wire [5:0] demosiine_off_y; diff --git a/src/text_sda.v b/src/text_sda.v index 6806f0e..0c48fae 100644 --- a/src/text_sda.v +++ b/src/text_sda.v @@ -6,16 +6,16 @@ module text_sda( input wire [8:0] y ); - parameter [59:0] sda_line0 = 60'b000000000001000000100000000000110000000000000000001100011100; - parameter [59:0] sda_line1 = 60'b000000000001000001010000000001010000000000000000000010100010; - parameter [59:0] sda_line2 = 60'b000000000001000001010000000001010000000000000000000010101001; - parameter [59:0] sda_line3 = 60'b101001100111011001110101011001010101001100110011000100110101; - parameter [59:0] sda_line4 = 60'b011001010101000101010101010101010011001010101010101000001001; - parameter [59:0] sda_line5 = 60'b001001010101000101010101000101010001001010101010101000100010; - parameter [59:0] sda_line6 = 60'b001011100101011001010010011000110001011100110111000110011100; - parameter [59:0] sda_line7 = 60'b000000000000000000000000000000000000000000100000000000000000; - parameter [59:0] sda_line8 = 60'b000000000000000000000000000000000000000000101000000000000000; - parameter [59:0] sda_line9 = 60'b000000000000000000000000000000000000000000010000000000000000; + localparam [59:0] sda_line0 = 60'b000000000001000000100000000000110000000000000000001100011100; + localparam [59:0] sda_line1 = 60'b000000000001000001010000000001010000000000000000000010100010; + localparam [59:0] sda_line2 = 60'b000000000001000001010000000001010000000000000000000010101001; + localparam [59:0] sda_line3 = 60'b101001100111011001110101011001010101001100110011000100110101; + localparam [59:0] sda_line4 = 60'b011001010101000101010101010101010011001010101010101000001001; + localparam [59:0] sda_line5 = 60'b001001010101000101010101000101010001001010101010101000100010; + localparam [59:0] sda_line6 = 60'b001011100101011001010010011000110001011100110111000110011100; + localparam [59:0] sda_line7 = 60'b000000000000000000000000000000000000000000100000000000000000; + localparam [59:0] sda_line8 = 60'b000000000000000000000000000000000000000000101000000000000000; + localparam [59:0] sda_line9 = 60'b000000000000000000000000000000000000000000010000000000000000; wire [6:0] sda_off_x; wire [5:0] sda_off_y; diff --git a/src/text_tt08.v b/src/text_tt08.v index 53e9a73..7daef02 100644 --- a/src/text_tt08.v +++ b/src/text_tt08.v @@ -5,15 +5,15 @@ module text_tt08( input wire [8:0] x, y ); - parameter [21:0] tt08_line0 = 22'b0000000000000001111100; - parameter [21:0] tt08_line1 = 22'b0000000000000010000010; - parameter [21:0] tt08_line2 = 22'b0111000111000100011111; - parameter [21:0] tt08_line3 = 22'b1000101001100100001000; - parameter [21:0] tt08_line4 = 22'b0111001010100101111001; - parameter [21:0] tt08_line5 = 22'b1000101100100100101001; - parameter [21:0] tt08_line6 = 22'b0111000111000100100001; - parameter [21:0] tt08_line7 = 22'b0000000000000010100010; - parameter [21:0] tt08_line8 = 22'b0000000000000000111100; + localparam [21:0] tt08_line0 = 22'b0000000000000001111100; + localparam [21:0] tt08_line1 = 22'b0000000000000010000010; + localparam [21:0] tt08_line2 = 22'b0111000111000100011111; + localparam [21:0] tt08_line3 = 22'b1000101001100100001000; + localparam [21:0] tt08_line4 = 22'b0111001010100101111001; + localparam [21:0] tt08_line5 = 22'b1000101100100100101001; + localparam [21:0] tt08_line6 = 22'b0111000111000100100001; + localparam [21:0] tt08_line7 = 22'b0000000000000010100010; + localparam [21:0] tt08_line8 = 22'b0000000000000000111100; wire [5:0] tt08_off_x; wire [5:0] tt08_off_y; diff --git a/src/vga_controller.v b/src/vga_controller.v index 2408f8f..c6d62b6 100644 --- a/src/vga_controller.v +++ b/src/vga_controller.v @@ -10,24 +10,24 @@ module vga_controller ( input wire clk, rst_n ); - // declarations for TV-simulator sync parameters + // declarations for TV-simulator sync localparams // horizontal constants - parameter W_DISPLAY = 640; // horizontal display width - parameter W_BACK = 48; // horizontal left border (back porch) - parameter W_FRONT = 16; // horizontal right border (front porch) - parameter W_SYNC = 96; // horizontal sync width + localparam W_DISPLAY = 640; // horizontal display width + localparam W_BACK = 48; // horizontal left border (back porch) + localparam W_FRONT = 16; // horizontal right border (front porch) + localparam W_SYNC = 96; // horizontal sync width // vertical constants - parameter H_DISPLAY = 480; // vertical display height - parameter H_TOP = 33; // vertical top border - parameter H_BOTTOM = 10; // vertical bottom border - parameter H_SYNC = 2; // vertical sync # lines + localparam H_DISPLAY = 480; // vertical display height + localparam H_TOP = 33; // vertical top border + localparam H_BOTTOM = 10; // vertical bottom border + localparam H_SYNC = 2; // vertical sync # lines // derived constants - parameter W_SYNC_START = W_DISPLAY + W_FRONT; - parameter W_SYNC_END = W_DISPLAY + W_FRONT + W_SYNC - 1; - parameter W_MAX = W_DISPLAY + W_BACK + W_FRONT + W_SYNC - 1; - parameter H_SYNC_START = H_DISPLAY + H_BOTTOM; - parameter H_SYNC_END = H_DISPLAY + H_BOTTOM + H_SYNC - 1; - parameter H_MAX = H_DISPLAY + H_TOP + H_BOTTOM + H_SYNC - 1; + localparam W_SYNC_START = W_DISPLAY + W_FRONT; + localparam W_SYNC_END = W_DISPLAY + W_FRONT + W_SYNC - 1; + localparam W_MAX = W_DISPLAY + W_BACK + W_FRONT + W_SYNC - 1; + localparam H_SYNC_START = H_DISPLAY + H_BOTTOM; + localparam H_SYNC_END = H_DISPLAY + H_BOTTOM + H_SYNC - 1; + localparam H_MAX = H_DISPLAY + H_TOP + H_BOTTOM + H_SYNC - 1; wire h_limit = (x == W_MAX) || ~rst_n; // set when x is maximum wire v_limit = (y == H_MAX) || ~rst_n; // set when y is maximum