EmbDev.net

Forum: FPGA, VHDL & Verilog Illegal output or inout port connection for port 'Aout'


von Michael (Guest)


Rate this post
useful
not useful
I have been trying to get this to work for quite sometime and I dont 
know why I cant simulate. It says error with port 'Aout'. Below is each 
of my modules that I have created. Please let me know. Thank you very 
much
1
// ALU TestBench
2
`timescale 1ns/1ps
3
module ALU_tb();
4
reg [3:0] A, B, OPCODE;
5
wire [3:0] ALU_out;
6
wire Cout, OF;
7
reg Cin;
8
ALU A1 (A, B, Cin, OPCODE, ALU_out, Cout, OF);
9
initial begin
10
//OPCODE 0000 and 0001, A=0101, B=0010;
11
A = 4'b0101; B = 4'b0010; Cin = 'b0; OPCODE = 4'b0000; #5;
12
$display("OPCODE = %b, A = %b, B = %b, ALU_out = %b, Cout = %b, OF = %b", OPCODE, A, B, ALU_out, Cout, OF);
13
14
OPCODE = 4'b0001; #5;
15
$display("OPCODE = %b, A = %b, B = %b, ALU_out = %b, Cout = %b, OF = %b", OPCODE, A, B, ALU_out, Cout, OF);
16
17
//OPCODE 0000, 0001, and 0010, A=0011, B=0001;
18
A = 4'b0011; B = 4'b0001; Cin = 'b0; OPCODE = 4'b0000; #5;
19
$display("OPCODE = %b, A = %b, B = %b, ALU_out = %b, Cout = %b, OF = %b", OPCODE, A, B, ALU_out, Cout, OF);
20
21
OPCODE = 4'b0001; #5;
22
$display("OPCODE = %b, A = %b, B = %b, ALU_out = %b, Cout = %b, OF = %b", OPCODE, A, B, ALU_out, Cout, OF);
23
24
OPCODE = 4'b0010; #5;
25
$display("OPCODE = %b, A = %b, B = %b, ALU_out = %b, Cout = %b, OF = %b", OPCODE, A, B, ALU_out, Cout, OF);
26
27
//OPCODE 0000 and 0001, A=0100, B=0011;
28
A = 4'b0100; B = 4'b0011; Cin = 'b0; OPCODE = 4'b0000; #5;
29
$display("OPCODE = %b, A = %b, B = %b, ALU_out = %b, Cout = %b, OF = %b", OPCODE, A, B, ALU_out, Cout, OF);
30
31
OPCODE = 4'b0001; #5;
32
$display("OPCODE = %b, A = %b, B = %b, ALU_out = %b, Cout = %b, OF = %b", OPCODE, A, B, ALU_out, Cout, OF);
33
end
34
endmodule
35
36
37
// ALU
38
39
module ALU(input [3:0] A, B, input Cin, input [3:0] OPCODE, output [3:0] ALU_out, output Cout, OF);
40
reg [3:0] Ain, Bin, Bn;
41
wire [3:0] Sum;
42
wire CoutFA, OFFA;
43
reg [3:0] ALU_out_;
44
reg Cout_, OF_;
45
comp2s C1 (B,Bn);
46
fulladder4 FA4 (Ain, Bin, Cin, Sum, CoutFA, OFFA);
47
assign ALU_out = ALU_out_;
48
assign Cout = Cout_;
49
assign OF = OF_;
50
always @ (*) begin
51
Ain = 4'b0000; Bin = 4'b0000; ALU_out_ = 4'b0000; Cout_ = 1'b0; OF_ = 1'b0;
52
case(OPCODE)
53
4'b0000 : begin
54
Ain = A;
55
Bin = B;
56
ALU_out_ = Sum;
57
Cout_ = CoutFA;
58
OF_ = OFFA;
59
end
60
4'b0001 : begin
61
Ain = A;
62
Bin = Bn;
63
ALU_out_ = Sum;
64
Cout_ = CoutFA;
65
OF_ = OFFA;
66
end
67
4'b0010 : begin
68
ALU_out_ = A&B;
69
Cout_ = 4'd0;
70
OF_ = 4'd0;
71
end
72
default : begin Ain = 4'b0000; Bin = 4'b0000; ALU_out_ = 4'b0000; Cout_ = 1'b0; OF_ = 1'b0;
73
end
74
endcase
75
end
76
endmodule
77
78
79
// 2's compliment
80
81
module comp2s(input [3:0] A, output [3:0] Aout);
82
wire Cout, OF;
83
wire [3:0] An;
84
assign An=~A;
85
fulladder4 FA4 (An, 4'd0, 1'b1, Aout, Cout, OF);
86
endmodule
87
88
89
// ripple adder
90
module fulladder4(input [3:0] A, B, input Cin, output [3:0] Sum, output Cout, OF);
91
wire Cout1, Cout2, Cout3;
92
fulladder FA1 (A[0], B[0], Cin, Sum[0], Cout1);
93
fulladder FA2 (A[1], B[1], Cout1, Sum[1], Cout2);
94
fulladder FA3 (A[2], B[2], Cout2, Sum[2], Cout3);
95
fulladder FA4 (A[3], B[3], Cout3, Sum[3], Cout);
96
xor X1 (OF, Cout3, Cout);
97
endmodule
98
99
100
101
//Full adder
102
module fulladder(input A, B, Cin, output Sum, Cout);
103
halfadder HA1 (A,B,Sum1, Cout1);
104
halfadder HA2 (Sum1,Cin,Sum,Cout2);
105
or O1 (Cout, Cout1, Cout2);
106
endmodule
107
108
109
110
//half adder
111
module halfadder(input A, B, output Sum, Cout);
112
assign Sum=A^B;
113
assign Cout=A&B;
114
endmodule

: Edited by Moderator
von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
Michael wrote:
> It says error with port 'Aout'.
What error?
I don't see any definition of Aout...


BTW: why don't you read and follow that few lines of "manual" above each 
edit box here?

: Edited by Moderator
von ElKo (Guest)


Rate this post
useful
not useful
Try to use a wire for signal "Bn" instead of reg.

von Ale (Guest)


Rate this post
useful
not useful
1
Line 43: wire [3:0] Bn;

OPCODE = 0000, A = 0101, B = 0010, ALU_out = 0111, Cout = 0, OF = 0
OPCODE = 0001, A = 0101, B = 0010, ALU_out = 0011, Cout = 1, OF = 0
OPCODE = 0000, A = 0011, B = 0001, ALU_out = 0100, Cout = 0, OF = 0
OPCODE = 0001, A = 0011, B = 0001, ALU_out = 0010, Cout = 1, OF = 0
OPCODE = 0010, A = 0011, B = 0001, ALU_out = 0001, Cout = 0, OF = 0
OPCODE = 0000, A = 0100, B = 0011, ALU_out = 0111, Cout = 0, OF = 0
OPCODE = 0001, A = 0100, B = 0011, ALU_out = 0001, Cout = 1, OF = 0

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.