# how to set pin in verilog (atera)

I am beginner in Altera DE2-115. I am asked to make a project using Verilog language. My idea was connect an infrared sensor and if it is cut with something, a buzzer starts.

The infra has 3 connections: ground , vcc , signal

and the buzzer: vcc and signal

So, for example, if I connect signal1 of infra in to pin 9 and pin 10 for buzzer signal ... all I know is infra has output 0 or 1, so if it is 0, the buzzer should start; if it is 1, the buzzer should stop.

I can code it in C, but I don't know how to code this in Verilog, so I need a code for this idea in Verilog.

• I think before you do anything, you need to learn Verilog. There are many online tutorials, and examples. Start with compiling and running code in simulation, and only once you understand designing for HDL should you move to hardware. HDL is very different from C, in fact it is very different from any procedural language. – Tom Carpenter Dec 9 '15 at 17:30

module fpga_main {
out0,
out1,
// more i/o pins

};

output out0;
output out1;

assign out0 = 1'b0;  //pin low
assign out1 = 1'b1;  //pin high

// other code

endmodule


alternatively for inputs:

module fpga_main {
in0,
in1,
// more i/o pins
};

input in0;
input in1;

// other code

end module


to actually connect the code to the pin you want though you need to use Quartus pin assignment feature to route the out0/1 or in0/1 signals to proper fpga pins

• my question is : if i connect the wire of the signal in pin number 9 i want to say in the code set the pin number 9 as input and how to check whether if it 0 or 1 – Namo Dec 9 '15 at 16:13
• @Namo see edit please – Funkyguy Dec 9 '15 at 16:18
• thanks for help ,, you mean that in0 means there is a wire connected to pin number 0 if i said in9 this mean there is wire to connect to pin 9 ?? – Namo Dec 9 '15 at 16:20
• No, not at all. That is just how you refer to the input signal. It could be called "bacon" for all it really mattered. You use the quartus pin assignment tool to connect internal signals to physical FPGA pins – Funkyguy Dec 9 '15 at 16:21
• okay if now i connected wire from the signal pin of the sensor to on of the pins of fpga for example pin number 11 and i need to set this pin as input in c language i say : int x = 9; // 9 is the number of the pin and then i say pinmode(x,INPUT) ; HOW CAN I SAY THIS IN VERILOG – Namo Dec 9 '15 at 16:24