0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

EBAZ4205 FPGA Xilinx編 第2版 演習2-4-1

Posted at

SWでLEDパターンを切り替える課題

  • どうせなら、自分で仕様を決めて作ってみます。
  • SWを押すとLED点灯パターンをバイナリカウンタからグレイコードカウンタに変化させます。
  • githubにアップしています https://github.com/ShigeoYakuno/EBAZ4205

拡張ボードの入手

まず演習するにあたり、SWなどを拡張したい
HDMIの課題に向け購入していた拡張ボードを使用した。

image.png

  • アダプタボードの回路図は、わかりにくいが以下の通り
  • SWは、KEY1~5を使う
    image.png

- 使いそうなポートは以下の通り。HDMI,LED,SW。

image.png

スイッチはSW3とSW1を使用。

  • 拡張ボードのSWは5つあり、うち1つはリセット(真ん中のSW3)を使う。
  • 他に4つ使えるが、今回はSW1(上)を使う。

image.png

グレイコードカウンタの特徴

  • 点灯パターンとして使用するグレイコードカウンタについて
  • 各遷移で1ビットしか変わらない
  • 周回(ループ)させても常に1ビット差
  • 誤動作やラッチアップが起きづらい

バイナリ➡グレイコードの変換

  • G = B >> 1 ^ B (G:グレイコード B:バイナリ)
  • 例 B= 3'b111 なら B>>1=3'b011 で 3'b111^3'b011で3'b100に変換できる
assign gray = bin ^ (bin >> 1);
  • 今回は以下の表をべた書きした

image.png

EBAZ4205での変更点

  • RST(SW3)が、例と反転しているので下記のように冒頭に1行付け加えた
  • あとは例題のRSTの箇所を「rstn」に変更する。debounce.vも同様に変更すること
module blinkpat (
    input               CLK,
    input               RST,
    input       [0:0]   BTN,
    output  reg [2:0]   LED_123
);

// @yaku EBAZ4205 負論理 RST を正論理に変換
wire rstn = ~RST;

/* チャタリング除去回路を接続 */
wire btnon;
debounce d0 (.CLK(CLK), .RST(RST), .BTNIN(BTN), .BTNOUT(btnon));

今日はここまで

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?