1
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?

MachXO2(FPGA)の内蔵オシレータの使用方法

Posted at

概要

LATTICE社製のFPGA、MachXO2シリーズにはクロック源が内蔵されていますので、使用方法についてまとめます。

参照資料

LATTICEのテクニカルノート(TN1199)に詳細が記されていいます。

ポイント

  • machxo2 のライブラリを読み込む必要があります
  • コンポーネント宣言の部分のコメント-- synthesis translate_offは省略してはいけないようです
  • スタンバイ入力は1でスタンバイなので、基本的に0固定でOKです
  • スタンバイにすることて電力を抑えたりの作用はありそうですが、バックグラウンドのフラッシュアップデートなどが出来なくなるので、要注意
  • 設定可能な周波数は以下のものからしか選択できない
  • 実際に使用したい周波数の指定はインスタンス記述の部分でgeneric map(NOM_FREQ => "20.46")のように指定します
2.08 4.16 8.31 15.65
2.15 4.29 8.58 16.63
2.22 4.43 8.87 17.73
2.29 4.59 9.17 19.00
2.38 4.75 9.50 20.46
2.46 4.93 9.85 22.17
2.56 5.12 10.23 24.18
2.66 5.32 10.64 26.60
2.77 5.54 11.08 29.56
2.89 5.78 11.57 33.25
3.02 6.05 12.09 38.00
3.17 6.33 12.67 44.33
3.33 6.65 13.30 53.20
3.50 7.00 14.00 66.50
3.69 7.39 14.78 88.67
3.91 7.82 15.65 133.00

サンプルソース

内蔵クロックでLチカを試したときのサンプルです

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;

library machxo2;
use machxo2.all;

entity TOP_MDL is
    Port(
    o_LED       :out    std_logic_vector(0 to 3)--モニタ用LED
    );
end entity;

architecture RTL of TOP_MDL is

   --内蔵オシレータ
    component OSCH
    --    synthesis translate_off
    generic (NOM_FREQ: string := "2.56");
--    synthesis translate_on
    port
        (STDBY  :in     std_logic
        ;OSC    :out    std_logic
        ;SEDSTDBY:out   std_logic
        );
    end component;
    attribute NOM_FREQ : string;
    attribute NOM_FREQ of OSCinst0 : label is "133.00";--周波数設定

signal osc_standby :std_logic;
signal osc_clk      :std_logic;
signal dummy_cnt    :std_logic_vector(24 downto 0);


begin
    -----------------------------------------------
    --内蔵オシレータ
    -----------------------------------------------
    osc_standby <= '0';
    OSCInst0:OSCH
        -- synthesis translate_off
        generic map(NOM_FREQ => "20.46")
        -- synthesis translate_on
        port map
        (STDBY      => osc_standby
        ,OSC        => osc_clk
        ,SEDSTDBY   => open
        );
        
    --ダミーカウンタ
    process(osc_clk)begin
        if(rising_edge(osc_clk))then
            dummy_cnt	<=dummy_cnt+1;
        end if;
    end process;

    o_LED(0) <=dummy_cnt(20);
    o_LED(1) <=dummy_cnt(21);
    o_LED(2) <=dummy_cnt(22);
    o_LED(3) <=dummy_cnt(23);

end architecture;

シミュレーション

ModelSimのLATTICEエディションでは、machxo2のライブラリが含まれていますので普通にシミュレーションできます。

image.png

※LATTICEのDiamondのバージョンアップが入ってModelsimからQuestaに切り替わった様子なので、Modelsimを使いたいひとはバージョン3.13をお勧めします。
FreeライセンスだとまだQuestaが起動しないとかいう状況みたいです。(2025年1月時点で)

1
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
1
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?