Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
21615 Discussions

Newbie . Error 10170 every time I use ''if''

Altera_Forum
Honored Contributor II
3,311 Views

Hey people ,  

I'm new to fpga programming and been having a hard time fixing error 10170.  

 

module button  

input wire s3, s4, s5, s6, 

output reg [6:0]seg ,  

output wire select ); 

assign select = 1'b0;  

if(~s3) 

begin 

seg=7'b0111111; 

end 

else begin 

seg=7'b0000000; 

end 

if(~s4) 

begin 

seg=7'b0000110; 

end 

else begin 

seg=7'b0000000; 

end 

if(~s5) 

begin 

seg=7'b1011011; 

end 

else begin 

seg=7'b0000000; 

end 

if(~s6) 

begin 

seg=7'b1011111; 

end 

else begin 

seg=7'b0000000; 

end 

endmodule 

 

I keep on getting :  

Error (10170): Verilog HDL syntax error at Adder.v(7) near text "if"; expecting "endmodule" 

 

I'm using examples I found in books and on the web. 

 

If I delete the 1st if statement , I get the same error again for the next if statement .  

 

Any help will be very much appreciated.
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
2,132 Views

 

--- Quote Start ---  

I'm using examples I found in books and on the web. 

--- Quote End ---  

 

I guess, not exactly. if is a sequential statement, that must be placed in a sequential block. 

 

always begin ... end
0 Kudos
Altera_Forum
Honored Contributor II
2,132 Views

Thanks for the reply . It finally worked. It seems the literature I was using was only showing portions of the whole code .

0 Kudos
Reply