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

Subversion Repositories sqmusic

[/] [sqmusic/] [trunk/] [ver/] [sin_pow.v] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 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
`timescale 1ns/1ps
14
 
15
module sin_pow;
16
 
17
reg clk, reset_n;
18
 
19
parameter fnumber = 11'h1;
20
parameter block   =  3'h0;
21
parameter multiple=  4'h1;
22
 
23
reg [10:0] phase;
24
reg [3:0] clk2;
25
 
26
initial begin
27
  $dumpvars(0,sin_pow);
28
  $dumpon;
29
  reset_n = 0;
30
  #10 reset_n = 1;
31
  #20 reset_n = 0;
32
  #1000 reset_n=1;
33
  $display("SOUND START");
34
end
35
 
36
 
37
always begin
38
  clk = 0;
39
  forever #(400) clk = ~clk & reset_n;
40
end
41
 
42
always @(posedge clk or negedge reset_n) begin
43
  if( !reset_n)
44
    clk2 <= 2'b0;
45
  else
46
    clk2 <= clk2+1'b1;
47
end
48
 
49
always @(posedge clk2[3] or negedge reset_n) begin
50
  if( !reset_n)
51
    phase<=11'b0;
52
  else begin
53
    phase <= phase+1;
54
    $display("%d, %d, %d", phase, sin_log, linear );
55
    if( phase[10] ) $finish;
56
  end
57
end
58
 
59
wire [12:0] sin_log, linear;
60
 
61
sq_sin sin(
62
  .clk     (clk2[3]),  // slow clock
63
  .reset_n (reset_n),
64
  .phase   (phase[9:0]),
65
  .val     (sin_log) );
66
 
67
sq_pow pow(
68
  .clk     (clk),
69
  .reset_n (reset_n),
70
  .rd_n    ( 1'b0 ),
71
  .x       (sin_log),
72
  .y       (linear) );
73
 
74
// always #(1e9/44100) $display("%d", linear);
75
endmodule

powered by: WebSVN 2.1.0

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