両方ともUSBから内蔵フラッシュメモリに回路を書き込み可能で,クロック内蔵なので,これだけで動きます.
UserGuideに簡単なチュートリアルのあったTinyFPGA BXから試してみました.macから簡単に使うことができます.しかも,ボード上に1個だけ使えるLEDが搭載されているので,macにmicroUSBケーブルでつなげるだけで,外付け回路一切無しで使用可能です.
開発環境は,Atomというエディタを使います.add-onを追加することで,このエディタだけでプログラムのチップへの書き込みまでできます.とりあえず,チュートリアルのページの通りに動きました.
プログラムの書き込みは,なぜかリセットボタンを押しても1回では成功せず,2回目で書き込めました.
サンプルプログラムはVerilogで書かれているのですが,SOSをモールス信号でLED表示するという,少し複雑なものだったので,もっと簡単なサンプルプログラムを作成しました.1秒ごとにLEDがON/OFFします.
// look in pins.pcf for all the pin names on the TinyFPGA BX board
module top (
input CLK, // 16MHz clock
output LED, // User/boot LED next to power LED
output USBPU // USB pull-up resistor
);
// drive USB pull-up resistor to '0' to disable USB
assign USBPU = 0;
////////
// 1 sec blink circuit
////////
// keep track of time and location in blink_pattern
reg [31:0] blink_counter;
// 16,000,000 (clock = 16MHz)
wire [23:0] onesec = 24'b111101000010010000000000;
reg [0:0] out_data;
// increment the blink_counter every clock
always @(posedge CLK) begin
blink_counter <= blink_counter + 1;
// 1秒経ったら
if ( blink_counter == onesec ) begin
// カウンターを0に戻す
blink_counter <= 0;
// 0->1, 1->0
out_data <= ~out_data;
//if文だと以下のように書いて良い
//if (out_data == 0) begin
// out_data <= 1;
//end else begin
// out_data <= 0;
//end
end
end
// light up the LED according to the pattern
assign LED = out_data;
endmodule
こんな感じで動きました.
