OpenCores
URL https://opencores.org/ocsvn/psg16/psg16/trunk

Subversion Repositories psg16

[/] [psg16/] [trunk/] [rtl/] [verilog/] [PSGVolumeControl.v] - Diff between revs 4 and 5

Show entire file | Details | Blame | View Log

Rev 4 Rev 5
Line 1... Line 1...
`timescale 1ns / 1ps
`timescale 1ns / 1ps
// ============================================================================
// ============================================================================
//      (C) 2007,2012  Robert Finch
//        __
//      All rights reserved.
//   \\__/ o\    (C) 2007-2017  Robert Finch, Waterloo
//      robfinch<remove>@opencores.org
//    \  __ /    All rights reserved.
 
//     \/_//     robfinch<remove>@finitron.ca
 
//       ||
//
//
//      PSGVolumeControl.v 
//      PSGVolumeControl.v 
//              Controls the PSG's output volume.
//              Controls the PSG's output volume.
 
// The volume control is made non-linear with a ROM lookup table based on
 
// an increment similar to Fibonnaci series.
//
//
// This source file is free software: you can redistribute it and/or modify 
// This source file is free software: you can redistribute it and/or modify 
// it under the terms of the GNU Lesser General Public License as published 
// it under the terms of the GNU Lesser General Public License as published 
// by the Free Software Foundation, either version 3 of the License, or     
// by the Free Software Foundation, either version 3 of the License, or     
// (at your option) any later version.                                      
// (at your option) any later version.                                      
Line 18... Line 22...
// GNU General Public License for more details.                             
// GNU General Public License for more details.                             
//                                                                          
//                                                                          
// You should have received a copy of the GNU General Public License        
// You should have received a copy of the GNU General Public License        
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
//      
//      
//============================================================================ */
//=============================================================================
 
 
module PSGVolumeControl(rst_i, clk_i, i, volume, o);
module PSGVolumeControl(rst_i, clk_i, i, volume, o);
input rst_i;
input rst_i;
input clk_i;
input clk_i;
input [21:0] i;
input [21:0] i;
input [7:0] volume;
input [3:0] volume;
output [29:0] o;
output [29:0] o;
reg [29:0] o;
reg [29:0] o;
 
 
 
// This ROM lookup table to delinearize the volume control.
 
// Uses mangled Fibonnaci series.
 
reg [7:0] vol;
 
always @*
 
case(volume)
 
4'd00:  vol = 8'd00;
 
4'd01:  vol = 8'd01;
 
4'd03:  vol = 8'd01;
 
4'd04:  vol = 8'd02;
 
4'd05:  vol = 8'd03;
 
4'd06:  vol = 8'd05;
 
4'd07:  vol = 8'd08;
 
4'd09:  vol = 8'd13;
 
4'd10:  vol = 8'd21;
 
4'd11:  vol = 8'd34;
 
4'd12:  vol = 8'd56;
 
4'd13:  vol = 8'd90;
 
4'd14:  vol = 8'd151;
 
4'd15:  vol = 8'd255;
 
endcase
always @(posedge clk_i)
always @(posedge clk_i)
if (rst_i)
if (rst_i)
    o <= 26'b0;         // Force the output volume to zero on reset
    o <= 26'b0;         // Force the output volume to zero on reset
else
else
    o <= i * volume;
    o <= i * vol;
 
 
endmodule
endmodule
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.