-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdsmod1.v
59 lines (52 loc) · 1.27 KB
/
dsmod1.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// First order Delta Sigma Modulator
// by Tomek Szczęsny 2022
//
// Transforms signed integers into a bit stream.
//
//
// +-------------------------------+
// clk --->| +----------+ |
// clr --->| |integrator| |---> out
// | dsmod1 +----------+ |
// | +-----+ |
// in[n] ===>| | ddc | |
// | +-----+ |
// +-------------------------------+
//
// Parameters:
// n - Bit width of input data (16)
//
// Ports:
// clk - a sampling clock input. Oversampling is generally required.
// clr - Asynchronous reset
// in[n] - Input data, signed integers.
// out - an output bit stream.
//
`ifndef _dsmod1_v_
`define _dsmod1_v_
`include "integrator.v"
`include "ddc1.v"
module dsmod1(
input wire clk,
input wire clr,
input wire signed [n-1:0] in,
output wire out);
parameter n = 16;
wire signed [n-1:0] ddc1;
wire signed [n:0] i1_in; // Integrator input
assign i1_in = in - ddc1;
wire signed [n+1:0] i1_out; // Integrator output
assign out = i1_out[n+1];
ddc1 #(
.n(n)) ddc11 (
.in(out),
.out(ddc1));
integrator #(
.n(n+1),
.m(n+2)) i1 (
.clk(clk),
.clr(clr),
.in(i1_in),
.out(i1_out));
endmodule
`endif