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

Subversion Repositories sqmusic

[/] [sqmusic/] [trunk/] [sqm/] [sq_pg.v] - Blame information for rev 16

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 gryzor
/*
2
        SQmusic
3
 
4
  (c) Jose Tejada Gomez, 9th May 2013
5
  You can use this file following the GNU GENERAL PUBLIC LICENSE version 3
6
  Read the details of the license in:
7
  http://www.gnu.org/licenses/gpl.txt
8
 
9
  Send comments to: jose.tejada@ieee.org
10
 
11
*/
12
 
13 12 gryzor
module sq_pg(
14
        input clk,
15
        input reset_n,
16
        input [10:0] fnumber,
17
        input [2:0] block,
18
  input [3:0] multiple,
19
        output [9:0]phase );
20
 
21
reg [19:0] count;
22
assign phase = count[19:10];
23
 
24
wire [19:0]fmult;
25
 
26
always @(*) begin
27
  case( multiple )
28
    4'b0: fmult = (phase << block) >> 1'b1;
29
    default: fmult = (phase<<block)*multiple;
30
  endcase
31
end
32
 
33
always @(posedge clk or negedge reset_n ) begin
34
        if( !reset_n )
35
                count <= 20'b0;
36
        else begin
37
          count <= count + fmult;
38
        end
39
end
40
 
41
endmodule
42
 
43
module sq_sin(
44
//  input clk,
45
//  input reset_n,
46
  input [9:0]phase,
47
  output [19:0] val
48
)
49
 
50
reg [19:0] sin_table[1023:0];
51
 
52
initial begin
53
  $readmemh("sin_table.hex", sin_table);
54
end
55
 
56
assign val = sin_table[phase];
57
 
58
end

powered by: WebSVN 2.1.0

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