Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

verilog error expecting endmodule found if

Status
Not open for further replies.

vveerendra

Newbie level 5
Newbie level 5
Joined
Apr 2, 2013
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,358
module disp1(A,P,Q,K,CLK,bclock,bclocko);
input [3:0]P;
input [3:0]Q;
output [3:0]K;
input CLK;
output [6:0]A;
reg [6:0]A;
reg [3:0]K;
output bclock;
output bclocko;
reg bclock;
reg bclocko;
integer count=0;
integer counto=0;
if (bclock)
begin
K <= 4'b1110;
case(P)
0:A<=7'b0000001;
1:A<=7'b1001111;
2:A<=7'b0010010;
3:A<=7'b0000110;
4:A<=7'b1001100;
5:A<=7'b0100100;
6:A<=7'b0100000;
7:A<=7'b0001111;
8:A<=7'b0000000;
9:A<=7'b0001100;
endcase
end
else
begin
K<=4'b1101;
case(Q)
0:A<=7'b0000001;
1:A<=7'b1001111;
2:A<=7'b0010010;
3:A<=7'b0000110;
4:A<=7'b1001100;
5:A<=7'b0100100;
6:A<=7'b0100000;
7:A<=7'b0001111;
8:A<=7'b0000000;
9:A<=7'b0001100;
endcase
end
always @(posedge CLK)
if (count < 42666) count = count+1;
else
begin
bclock <= !bclock;
count=0;
end
endmodule

/*ERROR:line 15 expecting 'endmodule', found 'if'
how to fix the error*/
 

Well the if need to be in a process,"assign(*)"
 

Try this

Code:
module disp1(
  output reg [6:0] A,
  input [3:0] P,
  input [3:0] Q,
  output reg [3:0] K,
  input CLK,
  output reg bclock,
  output reg bclocko
);
integer count=0;
integer counto=0;
always @(bclock or P or Q)
  if ( bclock ) begin
      K = 4'b1110;
      case(P)
        0:A=7'b0000001;
        1:A=7'b1001111;
        2:A=7'b0010010;
        3:A=7'b0000110;
        4:A=7'b1001100;
        5:A=7'b0100100;
        6:A=7'b0100000;
        7:A=7'b0001111;
        8:A=7'b0000000;
        9:A=7'b0001100;
      endcase
    end
  else
    begin
        K=4'b1101;
        case(Q)
           0:A=7'b0000001;
           1:A=7'b1001111;
           2:A=7'b0010010;
           3:A=7'b0000110;
           4:A=7'b1001100;
           5:A=7'b0100100;
           6:A=7'b0100000;
           7:A=7'b0001111;
           8:A=7'b0000000;
           9:A=7'b0001100;
        endcase
     end
always @(posedge CLK)
    if (count < 42666) 
        count <= count+1;
    else
      begin
        bclock <= !bclock;
        count=0;
      end
endmodule
 
Try this

Code:
module disp1(
  output reg [6:0] A,
  input [3:0] P,
  input [3:0] Q,
  output reg [3:0] K,
  input CLK,
  output reg bclock,
  output reg bclocko
);
integer count=0;
integer counto=0;
always @(bclock or P or Q)
  if ( bclock ) begin
      K = 4'b1110;
      case(P)
        0:A=7'b0000001;
        1:A=7'b1001111;
        2:A=7'b0010010;
        3:A=7'b0000110;
        4:A=7'b1001100;
        5:A=7'b0100100;
        6:A=7'b0100000;
        7:A=7'b0001111;
        8:A=7'b0000000;
        9:A=7'b0001100;
      endcase
    end
  else
    begin
        K=4'b1101;
        case(Q)
           0:A=7'b0000001;
           1:A=7'b1001111;
           2:A=7'b0010010;
           3:A=7'b0000110;
           4:A=7'b1001100;
           5:A=7'b0100100;
           6:A=7'b0100000;
           7:A=7'b0001111;
           8:A=7'b0000000;
           9:A=7'b0001100;
        endcase
     end
always @(posedge CLK)
    if (count < 42666) 
        count <= count+1;
    else
      begin
        bclock <= !bclock;
        count=0;
      end
endmodule

thank you for your help :D
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top