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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [fpga/] [mc/] [boards/] [xsa-xst-3/] [doc/] [dac/] [dac.v] - Blame information for rev 323

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

Line No. Rev Author Line
1 231 hellwig
//
2
// dac.v -- DAC control circuit
3
//
4
 
5 290 hellwig
 
6 298 hellwig
`timescale 1ns/10ps
7 290 hellwig
`default_nettype none
8 231 hellwig
 
9 290 hellwig
 
10 231 hellwig
module dac(clk, reset,
11
           sample_l, sample_r, next,
12
           mclk, sclk, lrck, sdti);
13
    input clk;
14
    input reset;
15
    input [15:0] sample_l;
16
    input [15:0] sample_r;
17
    output next;
18
    output mclk;
19
    output sclk;
20
    output lrck;
21
    output sdti;
22
 
23
  reg [9:0] timing;
24
  reg [63:0] sr;
25
  wire shift;
26
 
27
  always @(posedge clk) begin
28
    if (reset) begin
29
      timing <= 10'h0;
30
    end else begin
31
      timing <= timing + 1;
32
    end
33
  end
34
 
35
  assign mclk = timing[1];
36
  assign sclk = timing[3];
37
  assign lrck = timing[9];
38
 
39
  assign next = (timing[9:0] == 10'h1FF) ? 1 : 0;
40
  assign shift = (timing[3:0] == 4'hF) ? 1 : 0;
41
 
42
  always @(posedge clk) begin
43
    if (reset) begin
44
      sr <= 64'h0;
45
    end else begin
46
      if (next) begin
47
        sr[63:52] <= 12'h000;
48
        sr[51:32] <= { sample_l[15:0], 4'h0 };
49
        sr[31:20] <= 12'h000;
50
        sr[19: 0] <= { sample_r[15:0], 4'h0 };
51
      end else begin
52
        if (shift) begin
53
          sr[63:1] <= sr[62:0];
54
          sr[0] <= 1'b0;
55
        end
56
      end
57
    end
58
  end
59
 
60
  assign sdti = sr[63];
61
 
62
endmodule

powered by: WebSVN 2.1.0

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