-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathFPGA1394V1-QLA.v
More file actions
191 lines (157 loc) · 5.13 KB
/
Copy pathFPGA1394V1-QLA.v
File metadata and controls
191 lines (157 loc) · 5.13 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/* -*- Mode: Verilog; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ex: set filetype=v softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
/*******************************************************************************
*
* Copyright(C) 2011-2023 ERC CISST, Johns Hopkins University.
*
* This is the top level module for the FPGA1394V1-QLA motor controller interface.
*
* Revision history
* 07/15/10 Initial revision - MfgTest
* 10/27/11 Paul Thienphrapa Initial revision (pault at cs.jhu.edu)
* 02/29/12 Zihan Chen
* 08/29/18 Peter Kazanzides Added DS2505 module
* 01/22/20 Peter Kazanzides Removed global reset
* 12/11/22 Peter Kazanzides Separated code to FPGA1394V1.v and QLA.v
*/
`timescale 1ns / 1ps
// clock information
// clk1394: 49.152 MHz
// sysclk: same as clk1394 49.152 MHz
`include "Constants.v"
module FPGA1394V1QLA
(
// ieee 1394 phy-link interface
input clk1394, // 49.152 MHz
inout [7:0] data,
inout [1:0] ctl,
output wire lreq,
output wire reset_phy,
// serial interface
input wire RxD,
input wire RTS,
output wire TxD,
input wire clk40m, // 40.0000 MHz
// debug I/Os
// output wire [3:0] DEBUG,
// misc board I/Os
input [3:0] wenid, // rotary switch
inout [1:32] IO1,
inout [1:38] IO2,
output wire LED,
// SPI interface to PROM
output XCCLK,
input XMISO,
output XMOSI,
output XCSn
);
// Number of motors and encoders
parameter NUM_MOTORS = 4;
parameter NUM_ENCODERS = 4;
// System clock
wire sysclk;
BUFG clksysclk(.I(clk1394), .O(sysclk));
// ~12 MHz clock
wire clkdiv2, clk_12M;
ClkDiv div2clk(sysclk, clkdiv2);
defparam div2clk.width = 2;
BUFG clk12(.I(clkdiv2), .O(clk_12M));
// -------------------------------------------------------------------------
// local wires to tie the instantiated modules and I/Os
//
wire[3:0] board_id; // 4-bit board id
assign board_id = ~wenid;
wire[15:0] reg_raddr; // 16-bit reg read address
wire[15:0] reg_waddr; // 16-bit reg write address
wire[31:0] reg_rdata; // reg read data
wire[31:0] reg_wdata; // reg write data
wire reg_rwait; // reg read wait state
wire reg_wen; // register write signal
wire blk_wen; // block write enable
wire blk_wstart; // block write start
wire blk_rt_rd; // real-time block read
// Timestamp
wire[31:0] timestamp;
// Wires for watchdog
wire wdog_period_led; // 1 -> external LED displays wdog_period_status
wire[2:0] wdog_period_status;
wire wdog_timeout; // watchdog timeout status flag
wire wdog_clear; // clear watchdog timeout (e.g., on powerup)
assign LED = IO1[32]; // NOTE: IO1[32] pwr_enable
//******************************* FPGA Module *************************************
FPGA1394V1
#(.NUM_MOTORS(NUM_MOTORS), .NUM_ENCODERS(NUM_ENCODERS))
fpga(
.sysclk(sysclk),
.reboot_clk(clk_12M),
.board_id(board_id),
// Firewire
.data(data),
.ctl(ctl),
.lreq(lreq),
.reset_phy(reset_phy),
// Serial interface
.RxD(RxD),
.RTS(RTS),
.TxD(TxD),
.clk40m(clk40m), // 40.0000 MHz
// PROM (M25P16)
.XCCLK(XCCLK),
.XMISO(XMISO),
.XMOSI(XMOSI),
.XCSn(XCSn),
// Read/write bus
.reg_raddr(reg_raddr),
.reg_waddr(reg_waddr),
.reg_rdata_ext(reg_rdata),
.reg_wdata(reg_wdata),
.reg_rwait_ext(reg_rwait),
.reg_wen(reg_wen),
.blk_wen(blk_wen),
.blk_wstart(blk_wstart),
.blk_rt_rd(blk_rt_rd),
// Timestamp
.timestamp(timestamp),
// Watchdog support
.wdog_period_led(wdog_period_led),
.wdog_period_status(wdog_period_status),
.wdog_timeout(wdog_timeout),
.wdog_clear(wdog_clear)
);
//******************************* QLA Module **************************************
// divide 40 MHz clock down to 400 kHz for temperature sensor readings
wire clk400k_raw, clk400k;
ClkDivI divtemp(clk40m, clk400k_raw);
defparam divtemp.div = 100;
BUFG clktemp(.I(clk400k_raw), .O(clk400k));
QLA qla(
.sysclk(sysclk),
.board_id(board_id),
// Supplying 400k clock because different versions of hardware create
// this clock differently.
.clk400k(clk400k),
// ~12MHz clock for ADC
.clkadc(clk_12M),
// I/O between FPGA and QLA (connectors J1 and J2)
.IO1(IO1[1:32]),
.IO2(IO2[1:38]),
.io_extra(4'd0),
// Read/write bus
.reg_raddr(reg_raddr),
.reg_waddr(reg_waddr),
.reg_rdata(reg_rdata),
.reg_wdata(reg_wdata),
.reg_rwait(reg_rwait),
.reg_wen(reg_wen),
.blk_wen(blk_wen),
.blk_wstart(blk_wstart),
.blk_rt_rd(blk_rt_rd),
// Timestamp
.timestamp(timestamp),
// Watchdog support
.wdog_period_led(wdog_period_led),
.wdog_period_status(wdog_period_status),
.wdog_timeout(wdog_timeout),
.wdog_clear(wdog_clear)
);
endmodule