-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPowerChannel.v
61 lines (54 loc) · 1.28 KB
/
PowerChannel.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
60
61
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 03:05:05 12/05/2014
// Design Name:
// Module Name: PowerChannel
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module PowerChannel(
input clk,
input voltknob,
input currentknob,
input powered, // Force value_out to 0 if 0
output mode, // 0=voltage, 1=current
output reg [17:0] value_out
);
reg [17:0] voltage, current;
reg vreset, ireset, clkslow;
wire [15:0] clktimer;
EncodedRotatingKnob VKnob(clk,voltknob,voltage);
EncodedRotatingKnob IKnob(clk,currentknob,current);
initial begin
vreset = 0;
ireset = 0;
voltage = 0;
current = 0;
value_out = 0;
end
always @(posedge clk) begin
clktimer = clktimer+1;
if(clktimer >= 10000/2) begin // 10kHz clock
clktimer = 0;
clkslow = ~clkslow;
end
end
always @(posedge clkslow) begin
// determine the change in the encoder detectors
if(~powered) begin // force to 0 if unpowered
value_out = 0;
end
end
endmodule