forked from sheldonucr/ucr-eecs168-lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gcd_toplevel.v
74 lines (59 loc) · 1.64 KB
/
gcd_toplevel.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
62
63
64
65
66
67
68
69
70
71
72
73
74
//=========================================================================
// Top level RTL Model of GCD Unit
//-------------------------------------------------------------------------
//
// W is a parameter specifying the bit width of the module
module gcdGCDUnit_rtl#( parameter W = 16 )
(
input clk,
input reset,
input [W-1:0] operands_bits_A,
input [W-1:0] operands_bits_B,
input operands_val,
output operands_rdy,
output [W-1:0] result_bits_data,
output result_val,
input result_rdy
);
// At this top level, hook together the
// datapath part and control part only
// In verilog, multi-bit wires will only be
// a single bit wide if they are not declared
wire B_mux_sel, A_en, B_en, B_zero, A_lt_B;
wire [1:0] A_mux_sel;
// Notice W parameter is sent to the datapath
// module as well
gcdGCDUnitDpath#(W) GCDdpath0(
// external
.operands_bits_A(operands_bits_A),
.operands_bits_B(operands_bits_B),
.result_bits_data(result_bits_data),
// system
.clk(clk),
.reset(reset),
// internal (between ctrl and dpath)
.A_mux_sel(A_mux_sel),
.A_en(A_en),
.B_en(B_en),
.B_mux_sel(B_mux_sel),
.B_zero(B_zero),
.A_lt_B(A_lt_B)
);
gcdGCDUnitCtrl GCDctrl0(
// external
.operands_rdy(operands_rdy),
.operands_val(operands_val),
.result_rdy(result_rdy),
.result_val(result_val),
// system
.clk(clk),
.reset(reset),
// internal (between ctrl and dpath)
.B_zero(B_zero),
.A_lt_B(A_lt_B),
.A_mux_sel(A_mux_sel),
.A_en(A_en),
.B_en(B_en),
.B_mux_sel(B_mux_sel)
);
endmodule