[moved] How to clear Verilog HDL error

Status
Not open for further replies.

sugubai

Newbie level 6
Joined
Oct 22, 2017
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
111

Code Verilog - [expand]
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
module kj(j1,l1,j,k,clock,reset,q,qb,q1,qb1,b);
input j1,l1,j,k,clock,reset;
output reg q1,qb1;
output reg [3:0]q,qb,b,a;
always@(negedge clock)
begin
case({reset,j1,l1})
3'b100 :q1=q1;
3'b101 :q1=0;
3'b110 :q1=1;
3'b111 :q1=~q1;
default :q1=0;
endcase
qb1<=~q1;
end
always@ *
begin
if(q1==q1)
begin
kl JK1(j,k,clock,reset,q[0],qb[0]);
kl JK2(j,k,q[0],reset,q[1],qb[1]);
kl JK3(j,k,q[1],reset,q[2],qb[2]);
kl JK4(j,k,q[2],reset,q[3],qb[3]);
end
end
else if(q1==0)
begin
kl JK5(j,k,d,reset,q[0],qb[0]);
kl JK6(j,k,q[0],reset,q[1],qb[1]);
kl JK7(j,k,q[1],reset,q[2],qb[2]);
kl JK8(j,k,q[2],reset,q[3],qb[3]);
end
 
else if(q1==1)
begin
always@(reset)
begin
if(reset)
q <=4'b0000;
else if(q<4'b0101)
q <= q+1;
else
b=q[1]&&q[3];
end
end
 
else if (q1==~q1)
begin
always@(posedge clock)
begin
if(reset)
q <=4'b0000;
else if(q<4'b0011)
q <= q+1;
else
a=q[2]&&q[3];
end
end
endmodule



this is my verilog code i have some error in this...



my error is above mentioned please help
 
Last edited by a moderator:

Re: How to clear Verilog HDL error

modules are instantiated outside of an always/initial block.
 

Re: How to clear Verilog HDL error

modules are instantiated outside of an always/initial block.


Code Verilog - [expand]
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
module kj(j1,l1,j,k,clock,reset,q,qb,q1,qb1,b);
input j1,l1,j,k,clock,reset;
output reg q1,qb1;
output reg [3:0]q,qb,b,a;
always@(negedge clock)
begin
case({reset,j1,l1})
3'b100 :q1=q1;
3'b101 :q1=0;
3'b110 :q1=1;
3'b111 :q1=~q1;
default :q1=0;
endcase
qb1<=~q1;
end
always@*
begin
if(q1==q1)
 
kl JK1(j,k,clock,reset,q[0],qb[0]);
kl JK2(j,k,q[0],reset,q[1],qb[1]);
kl JK3(j,k,q[1],reset,q[2],qb[2]);
kl JK4(j,k,q[2],reset,q[3],qb[3]);
end
always@*
begin
else if(q1==0)
 
kl JK5(j,k,clock,reset,q[0],qb[0]);
kl JK6(j,k,q[0],reset,q[1],qb[1]);
kl JK7(j,k,q[1],reset,q[2],qb[2]);
kl JK8(j,k,q[2],reset,q[3],qb[3]);
end
 
else if(q1==1)
begin
always@(reset)
begin
if(reset)
q <=4'b0000;
else if(q<4'b0101)
q <= q+1;
else
b=q[1]&&q[3];
end
end
 
else if (q1==~q1)
begin
always@(posedge clock)
begin
if(reset)
q <=4'b0000;
else if(q<4'b0011)
q <= q+1;
else
a=q[2]&&q[3];
end
end
endmodule




error
 
Last edited by a moderator:

Re: How to clear Verilog HDL error

Besides the lack of indentation of the code, which denotes a certain sloppiness, there are several strange stuffs even for those who are not familiar with verilog language.

Code:
begin
else if(q1==0)
Code:
if(q1==q1)

If you really want to be helped, you have to make a little more effort to solve these problems by yourself
 

There are an excessive number of problems with this code, literally too many to point out.
To name just a few:
  • no formatting of the code
  • utterly useless names for everything (other than clock and reset)
  • lack of comments
  • non-Verilog 2001 port syntax
  • a case statement for a simple register description
  • using the negedge of a clock for no good reason
  • using always blocks for instantiating the k1 module
  • the earlier pointed out if (q1==q1), FYI this is always true
etc, there are more but, that is only half way through the file.

Apparently you don't understand that Verilog is a Hardware Description Language (HDL) and you should understand the logic you are trying to describe, not write any random code and hope it can be synthesized to logic.
 

IIRC, (q1 == q1) is false for q1 = 1'bx.

Code:
always@*
begin
if(q1==q1)
 
kl JK1(j,k,clock,reset,q[0],qb[0]);
modules are instantiated outside of an always/initial block.
 

IIRC, (q1 == q1) is false for q1 = 1'bx.

True but for synthesis this is always true and the logic that this if selects would always be done.
 

Re: How to clear Verilog HDL error

Okk sir.. i am the beginner of the verilog so, now only i am just learned about it..anyway thank you sir
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…