Altera DE0のピンアサインメント

さてAltera DE0 & Quartus IIはVerilogの学習キットとしては最適なのだが、いろいろ手続きが面倒なところもある。
たとえばピンアサインメント。
これはスイッチやLED、GPIOヘッダなどが接続されているCyclone IIIのピンと、Verilog上でのinput、outputをマッピングするものだ。
面倒だとは言ってもGUIもあるし、それほどやりにくくはない。
しかしモジュールを書いてそのテストをして、とその度にプロジェクトを起こしてピンアサインメントを設定するのはおっくうだ。
なので、以下のようなファイルを"pin_assignment.qsf"として保存しておく。


set_location_assignment PIN_F1 -to in_button[2]
set_location_assignment PIN_G3 -to in_button[1]
set_location_assignment PIN_H2 -to in_button[0]
set_location_assignment PIN_G21 -to in_clk
set_location_assignment PIN_D2 -to in_switch[9]
set_location_assignment PIN_E4 -to in_switch[8]
set_location_assignment PIN_E3 -to in_switch[7]
set_location_assignment PIN_H7 -to in_switch[6]
set_location_assignment PIN_J7 -to in_switch[5]
set_location_assignment PIN_G5 -to in_switch[4]
set_location_assignment PIN_G4 -to in_switch[3]
set_location_assignment PIN_H6 -to in_switch[2]
set_location_assignment PIN_H5 -to in_switch[1]
set_location_assignment PIN_J6 -to in_switch[0]
set_location_assignment PIN_B1 -to out_led[9]
set_location_assignment PIN_B2 -to out_led[8]
set_location_assignment PIN_C2 -to out_led[7]
set_location_assignment PIN_C1 -to out_led[6]
set_location_assignment PIN_E1 -to out_led[5]
set_location_assignment PIN_F2 -to out_led[4]
set_location_assignment PIN_H1 -to out_led[3]
set_location_assignment PIN_J3 -to out_led[2]
set_location_assignment PIN_J2 -to out_led[1]
set_location_assignment PIN_J1 -to out_led[0]
set_location_assignment PIN_D13 -to seven_segment_0[7]
set_location_assignment PIN_F13 -to seven_segment_0[6]
set_location_assignment PIN_F12 -to seven_segment_0[5]
set_location_assignment PIN_G12 -to seven_segment_0[4]
set_location_assignment PIN_H13 -to seven_segment_0[3]
set_location_assignment PIN_H12 -to seven_segment_0[2]
set_location_assignment PIN_F11 -to seven_segment_0[1]
set_location_assignment PIN_E11 -to seven_segment_0[0]
set_location_assignment PIN_B15 -to seven_segment_1[7]
set_location_assignment PIN_A15 -to seven_segment_1[6]
set_location_assignment PIN_E14 -to seven_segment_1[5]
set_location_assignment PIN_B14 -to seven_segment_1[4]
set_location_assignment PIN_A14 -to seven_segment_1[3]
set_location_assignment PIN_C13 -to seven_segment_1[2]
set_location_assignment PIN_B13 -to seven_segment_1[1]
set_location_assignment PIN_A13 -to seven_segment_1[0]
set_location_assignment PIN_A18 -to seven_segment_2[7]
set_location_assignment PIN_F14 -to seven_segment_2[6]
set_location_assignment PIN_B17 -to seven_segment_2[5]
set_location_assignment PIN_A17 -to seven_segment_2[4]
set_location_assignment PIN_E15 -to seven_segment_2[3]
set_location_assignment PIN_B16 -to seven_segment_2[2]
set_location_assignment PIN_A16 -to seven_segment_2[1]
set_location_assignment PIN_D15 -to seven_segment_2[0]
set_location_assignment PIN_G16 -to seven_segment_3[7]
set_location_assignment PIN_G15 -to seven_segment_3[6]
set_location_assignment PIN_D19 -to seven_segment_3[5]
set_location_assignment PIN_C19 -to seven_segment_3[4]
set_location_assignment PIN_B19 -to seven_segment_3[3]
set_location_assignment PIN_A19 -to seven_segment_3[2]
set_location_assignment PIN_F15 -to seven_segment_3[1]
set_location_assignment PIN_B18 -to seven_segment_3[0]
プロジェクトを起こしたあとに、"Assginments" -> "Import Assignments"からこのファイルを読み込めば、各プロジェクトに反映される。
トップモジュールを

module test_aho(
input in_clk,
input [9:0] in_switch,
input [2:0] in_button,
output [9:0] out_led,
output[7:0] seven_segment_0,
output[7:0] seven_segment_1,
output[7:0] seven_segment_2,
output[7:0] seven_segment_3);
のように起こせば、マッピング完了となる。