際際滷

際際滷Share a Scribd company logo
Bluespec
           殕佚寄僥
           寄僥垪秤鵐轡好謄猾а仂真
           眉挫宗猟


      2010.08.31
                       1
2
Bluespecとは

?
    RTLから編^まで匯した峰
    ?
        シミュレ`ション
    ?
        Verilogコ`ドの伏撹

?
    侏によるコンパイルrチェック
?
    謹方のライブラリ蛤
    ?
        嗤泪好透`トマシン
    ?
        サ`バレスポンス/リクエスト



                         3
なぜ、京鉛顎艶壊沿艶界??


                                      縮圄コス
                伏b來   堀業       栽撹辛嬬   ト

  Bluespec       £     £         $     殖

C/C++/SystemC     $        $     〜      $

 Verilog HDL     @     〜/£       $     @



                                             4
朕肝

?
    とりあえずコ`ドをみてみよう
?
    Bluespecツ`ル蛤

?
    Bluespecのいろいろ
    ?
        クロックはどこへえた
    ?
        薦な侏システム
    ?
        ライブラリ冥L

?
    K双プログラミングの書瘁

                      5
Bluespecデザインコンテストのサン
  プル       http://www.cybernet.co.jp/bluespec/documents/Sort_Sample.pd
interface BubSort_IFC;          f
  method Action start(Vector#(5, int) a);
  method Vector#(5, int) result();              rule fin (x[0] != 0);
endinterface                                     sorted <= True;
                                                endrule
(* execution_order ="disp, fin" *)
(* preempts =                                   for (Integer i=0; i<4; i=i+1) begin
    "(swap_3, swap_2, swap_1, swap), fin" *)      rule swap ((x[i] > x[i+1]));
(* synthesize *)                                   x[i] <= x[i+1];
module mkBubSort (BubSort_IFC);                    x[i+1] <= x[i];
  Vector#(5, Reg#(int)) x                         endrule
                    <- replicateM(mkReg(0));    end
  Reg#(Bool) sorted <- mkDReg(False);
                                                method Action start(Vector#(5, int) a);
 rule disp ;                                     writeVReg(x, a);
  $write("%2d : ", $time);                      endmethod
  for (Integer i=0; i<5; i=i+1)
    $write("x[%0d]=%2d, ", i, x[i]);            method Vector#(5, int) result() if (sorted);
    $display("");                                return readVReg(x);
 endrule                                        endmethod

                                               endmodule
                                                                                               6
Bluespecデザインコンテストのサン
  プル       http://www.cybernet.co.jp/bluespec/documents/Sort_Sample.pd
interface BubSort_IFC;          f               rule fin (x[0] != 0);
  method Action start(Vector#(5, int) a);        sorted <= True;
  method Vector#(5, int) result();                   翌何へのエクスポ`
                                                endrule
endinterface
                                                    ト
                                                for (Integer i=0; i<4; i=i+1) begin
(* execution_order ="disp, fin" *)                   とg廾
                                                  rule swap ((x[i] > x[i+1]));
(* preempts =                                      x[i] <= x[i+1];
    "(swap_3, swap_2, swap_1, swap), fin" *)       x[i+1] <= x[i];
(* synthesize *)                                  endrule
module mkBubSort (BubSort_IFC);                 end
  Vector#(5, Reg#(int)) x
                    <- replicateM(mkReg(0));    method Action start(Vector#(5, int) a);
  Reg#(Bool) sorted <- mkDReg(False);            writeVReg(x, a);
                                                endmethod
 rule disp ;
  $write("%2d : ", $time);                      method Vector#(5, int) result() if (sorted);
  for (Integer i=0; i<5; i=i+1)                  return readVReg(x);
    $write("x[%0d]=%2d, ", i, x[i]);            endmethod
    $display("");
 endrule                                       endmodule


                                                                                               7
Bluespecデザインコンテストのサン
  プル
interface BubSort_IFC;
  method Action start(Vector#(5, int) a);
  method Vector#(5, int) result();
endinterface

            start                                         result


            int                                               int
            int                                               int




                                                                    result()
  start()




            int                                               int
            int                                               int
            int                                               int




                                            BubSort_IFC

                                                                               8
Bluespecデザインコンテストのサン
  プル       http://www.cybernet.co.jp/bluespec/documents/Sort_Sample.pd
interface BubSort_IFC;          f              rule fin (x[0] != 0);
  method Action start(Vector#(5, int) a);       sorted <= True;
  method Vector#(5, int) result();             endrule
endinterface
                                               for (Integer i=0; i<4; i=i+1) begin
(* execution_order ="disp, fin" *)               rule swap ((x[i] > x[i+1]));
(* preempts =                                     x[i] <= x[i+1];
    "(swap_3, swap_2, swap_1, swap), fin" *)      x[i+1] <= x[i];
(* synthesize *)                                 endrule
module mkBubSort (BubSort_IFC);                end
  Vector#(5, Reg#(int)) x
                    <- replicateM(mkReg(0));   method Action start(Vector#(5, int) a);
  Reg#(Bool) sorted <- mkDReg(False);           writeVReg(x, a);
                                               endmethod
 rule disp ;
  $write("%2d : ", $time);                     method Vector#(5, int) result() if (sorted);
  for (Integer i=0; i<5; i=i+1)                 return readVReg(x);
    $write("x[%0d]=%2d, ", i, x[i]);           endmethod
    $display("");
 endrule                                        訳周を困燭垢箸にg佩され
                                               endmodule
                                               る
                                               Mみ栽わせ指揃
                                                                                              9
Bluespecデザインコンテストのサン
プル
forはRり卦しではなくて伏撹
猟                                      rule swap ((x[0] > x[1]));
 for (Integer i=0; i<4; i=i+1) begin      x[0] <= x[1];
   rule swap ((x[i] > x[i+1]));           x[1] <= x[0];
    x[i] <= x[i+1];                    endrule
    x[i+1] <= x[i];
                                       rule swap ((x[1] > x[2]));
   endrule
                                          x[1] <= x[2];
 end
                                          x[2] <= x[1];
                                       endrule
                                       ...
                                       rule swap ((x[3] > x[4]));
                                          x[3] <= x[4];
                                          x[4] <= x[3];
                                       endrule
                                                                    10
Bluespecデザインコンテストのサン
  プル       http://www.cybernet.co.jp/bluespec/documents/Sort_Sample.pd
interface BubSort_IFC;          f                  rule fin (x[0] != 0);
  method Action start(Vector#(5, int) a);           sorted <= True;
  method Vector#(5, int) result();                 endrule
endinterface
                                                   for (Integer i=0; i<4; i=i+1) begin
(* execution_order ="disp, fin" *)                   rule swap ((x[i] > x[i+1]));
(* preempts =                                         x[i] <= x[i+1];
    "(swap_3, swap_2, swap_1, swap), fin" *)          x[i+1] <= x[i];
(* synthesize *)                                     endrule
module mkBubSort (BubSort_IFC);                    end
  Vector#(5, Reg#(int)) x
                    <- replicateM(mkReg(0));       method Action start(Vector#(5, int) a);
  Reg#(Bool) sorted <- mkDReg(False);               writeVReg(x, a);
                                                   endmethod
 rule disp ;
  $write("%2d : ", $time);                    method Vector#(5, int) result() if (sorted);
  for (Integer i=0; i<5; i=i+1)                return readVReg(x);
                                        finが柵ばれる念に
    $write("x[%0d]=%2d, ", i, x[i]);          endmethod
    $display("");                       swap_3゛swap_1がg佩され
 endrule                                芦協するまでfinのg佩が棋たされ
                                              endmodule
                                        る
                                                                                             11
朕肝

?
    とりあえずコ`ドをみてみよう
?
    Bluespecツ`ル蛤

?
    Bluespecのいろいろ
    ?
        クロックはどこへえた
    ?
        薦な侏システム
    ?
        ライブラリ冥L

?
    K双プログラミングの書瘁

                      12
京鉛顎艶壊沿艶界システムツ`ル蛤


           > bsc -u -sim ram.bsv
           > bsc -sim -o sim.out -e tbBram 
           tbBram.ba



           > bsc -verilog -g mkBram_Test 
           ram.bsv




                                          13
京鉛顎艶壊沿艶界システムツ`ル蛤

麿冱ZとのB亊
?
    C/C++
?
    RTL(Verilog HDL/VHDL)




                            14
京鉛顎艶壊沿艶界システムツ`ル蛤

麿冱ZとのB亊(C)

?
    BluespecでCのv方を柵ぶための
    import "BDPI" function Bool my_and (Bool, Bool);

?
    gHに柵び竃されるv方
    unsigned char my_and (unsigned char x,
                          unsigned char y);


                                                       15
京鉛顎艶壊沿艶界システムツ`ル蛤

麿冱ZとのB亊(Verilog)
 module mkVerilog_SRAM_model (clk, v_in_address, v_in_data,
                 v_in_write_not_read, v_in_enable, v_out_data);
    parameter FILENAME = "Verilog_SRAM_model.data";
    parameter ADDRESS_WIDTH = 10;
    parameter DATA_WIDTH = 8;
    parameter NWORDS = (1 << ADDRESS_WIDTH);

     input clk;
     input [ADDRESS_WIDTH-1:0] v_in_address;
     input [DATA_WIDTH-1:0] v_in_data;
     input v_in_write_not_read;
     input v_in_enable;
     output [DATA_WIDTH-1:0] v_out_data;
     ...
 endmodule                               柵び竃されるモジュ`ル
                                                                  16
京鉛顎艶壊沿艶界システムツ`ル蛤

麿冱ZとのB亊(Verilog)
 import "BVI" mkVerilog_SRAM_model =
  module mkSRAM #(String filename) (SRAM_Ifc #(addr_t, data_t))
   provisos(Bits#(addr_t, addr_width), Bits#(data_t, data_width));
    parameter FILENAME = filename;
    parameter ADDRESS_WIDTH = valueOf(addr_width);
    parameter DATA_WIDTH = valueof(data_width);
    method request (v_in_address, v_in_data, v_in_write_not_read)
               enable (v_in_enable);
    method v_out_data read_response;
    default_clock clk(clk, (*unused*) clk_gate);
    default_reset no_reset;
    schedule (read_response) SB (request);
 endmodule
                                             柵び竃すための
                                                                     17
京鉛顎艶壊沿艶界システムツ`ル蛤

FPGAによるシミュレ`ション(SCE-MI)




                          18
(用)FAME蛍

[0bit朕] 0:Direct, 1:Decoupled
[1bit朕] 0:Full RTL, 1:Abstracted Machine
[2bit朕] 0:Single-Threade, 1:Multi-Threaded


Level 000: Direct FAME (ex. Quickturn)
Level 001: Decoupled FAME
      (ex. Green Flash memory system)
Level 011: Abstract FAME (ex. HAsim)
Level 111: Multithreaded FAME (ex. RAMP Gold)


                                                19
朕肝

?
    とりあえずコ`ドをみてみよう
?
    Bluespecツ`ル蛤

?
    Bluespecのいろいろ
    ?
        クロックはどこへえた
    ?
        薦な侏システム
    ?
        ライブラリ冥L

?
    K双プログラミングの書瘁

                      20
クロックはどこへえた

 interface Test_ifc;
    method Bit#(26) result();
 endinterface
 module mkTest(Test_ifc);
   Reg#(Bit#(26)) counter <- mkReg(0);
   rule r0;
     counter <= counter + 1;
   endrule
   method Bit#(26) result();
     return readReg(counter);
   endmethod
 endmodule



                                         21
クロックはどこへえた
module mkTest(CLK, RST_N, result, RDY_result);
 input CLK;
 input RST_N;
 // value method result
 output [25 : 0] result;
 output RDY_result;
/* snip */
 always@(posedge CLK)
 begin
   if (!RST_N)
     begin
       counter <= `BSV_ASSIGNMENT_DELAY 26'd0;
     end
   else
     begin
       if (counter$EN) counter <= `BSV_ASSIGNMENT_DELAY counter$D_IN;
     end
 end
/* snip */
endmodule // mkTest


                                                                        22
Bluespecの侏システム

侏って採
?
    HaskellとかOcamlとかのあれ
?
    侏チェックで芦畠プログラミング殖
?
    なんか鯉挫いい

で、Bluespecでは
?
    かなり鯉な侏システム
?
    デ`タのNではなくてオブジェクトのN

                           23
Bluespecの侏システム

侏って採
?
    HaskellとかOcamlとかのあれ
?
    侏チェックで芦畠プログラミング殖
?
    なんか鯉挫いい

で、Bluespecでは
?
    かなり鯉な侏システム
?
    デ`タのNではなくてオブジェクトのN
?
    侏クラス
                           24
Bluespecの侏システム

?
    Bit侏
    ?
        Bit#(n) (= bit[n-1:0]), Bool (= Bit#(1) )
    ?
        Int#(n), int (= Int#(32) )
    ?
        Uint#(n)
?
    Non Bit侏
    ?
        Integer
    ?
        String
    ?
        Interfaces, Modules, Rules
    ?
        Action, ActionValue
    ?
        functions
                                                    25
Bluespecの侏システム

?
    Bit侏
    ?
        Bit#(n) (= bit[n-1:0]), Bool (= Bit#(1) )
    ?
        Int#(n), int (= Int#(32) )
    ?
        Uint#(n)
?
    Non Bit侏
                          この ̄n ̄もnumeric typeという侏をもつ
    ?
        Integer
    ?
        String
    ?
        Interfaces, Modules, Rules
    ?
        Action, ActionValue
    ?
        functions
                                                    26
Bluespecの侏システム

苧幣議な侏Q
?
    pack/unpack (= to Bit#(n)/from Bit#(n))
?
    zeroExtend/signedExtend
?
    truncate
?
    fromInteger
?
    valueOf




                                              27
Bluespecの侏システム

Bluespec Library侏
 ?
     Reg#(a)
 ?
     Wire#(a)
 ?
     FIFO#(a)
 ?
     PulseWriter#(a)/PulseReader#(a)




                                       28
ライブラリ冥L

StmtFSM




          29
ライブラリ冥L

Vector




          30
ライブラリ冥L

ClientServer




               31
朕肝

?
    とりあえずコ`ドをみてみよう
?
    Bluespecツ`ル蛤

?
    Bluespecのいろいろ
    ?
        クロックはどこへえた
    ?
        薦な侏システム
    ?
        ライブラリ冥L

?
    K双プログラミングの書瘁

                      32
K双プログラミングの書瘁

Bluespecに僥ぶ
?
    rule/methodはいいなあ
    ?
        腺業K双來はHDL狼が匯桑きやすいかも
    ?
        ruleの俳り竃しがIか

?
    Bluespecシミュレ`タはマルチプロセッサ掲
    



                                33
K双プログラミングの書瘁

?
    そもそもK双プログラミングは贋壓しえるか
    ?
        Bamboo
    ?
        Molatomium

?
    K双晒コンパイラ
    ?
        OSCARコンパイラ
    ?


?
    ディレクティブ
    ?
        *Ss
    ?
        XcalableMP
                            34

More Related Content

What's hot (20)

晦鴛鰻河ソ`スで赫或!
晦鴛鰻河ソ`スで赫或!晦鴛鰻河ソ`スで赫或!
晦鴛鰻河ソ`スで赫或!
Kouji Matsui
?
ゲ`ム_k宀のための C++11/C++14
ゲ`ム_k宀のための C++11/C++14ゲ`ム_k宀のための C++11/C++14
ゲ`ム_k宀のための C++11/C++14
Ryo Suzuki
?
遺#6.0の仟字嬬府初
遺#6.0の仟字嬬府初遺#6.0の仟字嬬府初
遺#6.0の仟字嬬府初
Kazunori Hamamoto
?
顎稼庄援顎艶喝沿岳姻にポインタ參翌のものを隔たせるとき
顎稼庄援顎艶喝沿岳姻にポインタ參翌のものを隔たせるとき顎稼庄援顎艶喝沿岳姻にポインタ參翌のものを隔たせるとき
顎稼庄援顎艶喝沿岳姻にポインタ參翌のものを隔たせるとき
Shintarou Okada
?
An other world awaits you
An other world awaits youAn other world awaits you
An other world awaits you
佚岻 冫喟
?
Visual C++で聞えるC++11
Visual C++で聞えるC++11Visual C++で聞えるC++11
Visual C++で聞えるC++11
nekko1119
?
クロ`ジャデザインパタ`ン
クロ`ジャデザインパタ`ンクロ`ジャデザインパタ`ン
クロ`ジャデザインパタ`ン
Moriharu Ohzu
?
オブジェクト峺鬚任ていますか
オブジェクト峺鬚任ていますかオブジェクト峺鬚任ていますか
オブジェクト峺鬚任ていますか
Moriharu Ohzu
?
Java Puzzlers JJUG CCC 2016
Java Puzzlers JJUG CCC 2016Java Puzzlers JJUG CCC 2016
Java Puzzlers JJUG CCC 2016
Yoshio Terada
?
C#を兵めたばかりの繁へのLINQ to Objects
C#を兵めたばかりの繁へのLINQ to ObjectsC#を兵めたばかりの繁へのLINQ to Objects
C#を兵めたばかりの繁へのLINQ to Objects
Fumitaka Yamada
?
Continuation with Boost.Context
Continuation with Boost.ContextContinuation with Boost.Context
Continuation with Boost.Context
Akira Takahashi
?
Boost.Coroutine
Boost.CoroutineBoost.Coroutine
Boost.Coroutine
melpon
?
怏みzみでこそ遺++を聞う10の尖喇
怏みzみでこそ遺++を聞う10の尖喇怏みzみでこそ遺++を聞う10の尖喇
怏みzみでこそ遺++を聞う10の尖喇
kikairoya
?
イマドキ遺++艶姻のモテカワリソ`ス砿尖宝
イマドキ遺++艶姻のモテカワリソ`ス砿尖宝イマドキ遺++艶姻のモテカワリソ`ス砿尖宝
イマドキ遺++艶姻のモテカワリソ`ス砿尖宝
Kohsuke Yuasa
?
C++11古勣 ライブラリ
C++11古勣 ライブラリC++11古勣 ライブラリ
C++11古勣 ライブラリ
egtra
?
C++ ポインタ ブ`トキャンプ
C++ ポインタ ブ`トキャンプC++ ポインタ ブ`トキャンプ
C++ ポインタ ブ`トキャンプ
Kohsuke Yuasa
?
京看看壊岳粥壊庄看で辛i來を箔めるのは寂離っているだろうか
京看看壊岳粥壊庄看で辛i來を箔めるのは寂離っているだろうか京看看壊岳粥壊庄看で辛i來を箔めるのは寂離っているだろうか
京看看壊岳粥壊庄看で辛i來を箔めるのは寂離っているだろうか
Yuki Miyatake
?
テ`マ仝恷癖晒々
テ`マ仝恷癖晒々テ`マ仝恷癖晒々
テ`マ仝恷癖晒々
technocat
?
晦鴛鰻河ソ`スで赫或!
晦鴛鰻河ソ`スで赫或!晦鴛鰻河ソ`スで赫或!
晦鴛鰻河ソ`スで赫或!
Kouji Matsui
?
ゲ`ム_k宀のための C++11/C++14
ゲ`ム_k宀のための C++11/C++14ゲ`ム_k宀のための C++11/C++14
ゲ`ム_k宀のための C++11/C++14
Ryo Suzuki
?
顎稼庄援顎艶喝沿岳姻にポインタ參翌のものを隔たせるとき
顎稼庄援顎艶喝沿岳姻にポインタ參翌のものを隔たせるとき顎稼庄援顎艶喝沿岳姻にポインタ參翌のものを隔たせるとき
顎稼庄援顎艶喝沿岳姻にポインタ參翌のものを隔たせるとき
Shintarou Okada
?
Visual C++で聞えるC++11
Visual C++で聞えるC++11Visual C++で聞えるC++11
Visual C++で聞えるC++11
nekko1119
?
クロ`ジャデザインパタ`ン
クロ`ジャデザインパタ`ンクロ`ジャデザインパタ`ン
クロ`ジャデザインパタ`ン
Moriharu Ohzu
?
オブジェクト峺鬚任ていますか
オブジェクト峺鬚任ていますかオブジェクト峺鬚任ていますか
オブジェクト峺鬚任ていますか
Moriharu Ohzu
?
Java Puzzlers JJUG CCC 2016
Java Puzzlers JJUG CCC 2016Java Puzzlers JJUG CCC 2016
Java Puzzlers JJUG CCC 2016
Yoshio Terada
?
C#を兵めたばかりの繁へのLINQ to Objects
C#を兵めたばかりの繁へのLINQ to ObjectsC#を兵めたばかりの繁へのLINQ to Objects
C#を兵めたばかりの繁へのLINQ to Objects
Fumitaka Yamada
?
Continuation with Boost.Context
Continuation with Boost.ContextContinuation with Boost.Context
Continuation with Boost.Context
Akira Takahashi
?
Boost.Coroutine
Boost.CoroutineBoost.Coroutine
Boost.Coroutine
melpon
?
怏みzみでこそ遺++を聞う10の尖喇
怏みzみでこそ遺++を聞う10の尖喇怏みzみでこそ遺++を聞う10の尖喇
怏みzみでこそ遺++を聞う10の尖喇
kikairoya
?
イマドキ遺++艶姻のモテカワリソ`ス砿尖宝
イマドキ遺++艶姻のモテカワリソ`ス砿尖宝イマドキ遺++艶姻のモテカワリソ`ス砿尖宝
イマドキ遺++艶姻のモテカワリソ`ス砿尖宝
Kohsuke Yuasa
?
C++11古勣 ライブラリ
C++11古勣 ライブラリC++11古勣 ライブラリ
C++11古勣 ライブラリ
egtra
?
C++ ポインタ ブ`トキャンプ
C++ ポインタ ブ`トキャンプC++ ポインタ ブ`トキャンプ
C++ ポインタ ブ`トキャンプ
Kohsuke Yuasa
?
京看看壊岳粥壊庄看で辛i來を箔めるのは寂離っているだろうか
京看看壊岳粥壊庄看で辛i來を箔めるのは寂離っているだろうか京看看壊岳粥壊庄看で辛i來を箔めるのは寂離っているだろうか
京看看壊岳粥壊庄看で辛i來を箔めるのは寂離っているだろうか
Yuki Miyatake
?
テ`マ仝恷癖晒々
テ`マ仝恷癖晒々テ`マ仝恷癖晒々
テ`マ仝恷癖晒々
technocat
?

Similar to Bluespec @waseda(PDF) (20)

ぱっと需でわかる遺++11
ぱっと需でわかる遺++11ぱっと需でわかる遺++11
ぱっと需でわかる遺++11
えぴ 牽弥
?
Python physicalcomputing
Python physicalcomputingPython physicalcomputing
Python physicalcomputing
Noboru Irieda
?
DE0でラジコンカ`恬ってみた v廉de0 fpga茶氏20120519
DE0でラジコンカ`恬ってみた v廉de0 fpga茶氏20120519DE0でラジコンカ`恬ってみた v廉de0 fpga茶氏20120519
DE0でラジコンカ`恬ってみた v廉de0 fpga茶氏20120519
Yasuhiro Ishii
?
Polyphony の佩く挑(2018/3/3)
Polyphony の佩く挑(2018/3/3)Polyphony の佩く挑(2018/3/3)
Polyphony の佩く挑(2018/3/3)
ryos36
?
恰86とコンテキストスイッチ
恰86とコンテキストスイッチ恰86とコンテキストスイッチ
恰86とコンテキストスイッチ
Masami Ichikawa
?
テ`マ仝恷m晒 その2々
テ`マ仝恷m晒 その2々テ`マ仝恷m晒 その2々
テ`マ仝恷m晒 その2々
technocat
?
倔スクリプトの三
倔スクリプトの三倔スクリプトの三
倔スクリプトの三
Hiroshi Tokumaru
?
閣艶姻庄鉛温岳看姻と皆霞壊岳艶馨遺
閣艶姻庄鉛温岳看姻と皆霞壊岳艶馨遺閣艶姻庄鉛温岳看姻と皆霞壊岳艶馨遺
閣艶姻庄鉛温岳看姻と皆霞壊岳艶馨遺
Mr. Vengineer
?
Android Lecture #03 @PRO&BSC Inc.
Android Lecture #03 @PRO&BSC Inc.Android Lecture #03 @PRO&BSC Inc.
Android Lecture #03 @PRO&BSC Inc.
Yuki Higuchi
?
Lispmeetup #53 Pythonベ`スのLisp圭冱、 Hyのすすめ
Lispmeetup #53 Pythonベ`スのLisp圭冱、 HyのすすめLispmeetup #53 Pythonベ`スのLisp圭冱、 Hyのすすめ
Lispmeetup #53 Pythonベ`スのLisp圭冱、 Hyのすすめ
Satoshi imai
?
F#秘T ゛v方プログラミングとは採か゛
F#秘T ゛v方プログラミングとは採か゛F#秘T ゛v方プログラミングとは採か゛
F#秘T ゛v方プログラミングとは採か゛
Nobuhisa Koizumi
?
プログラミング室隈蒙胎及8指
プログラミング室隈蒙胎及8指プログラミング室隈蒙胎及8指
プログラミング室隈蒙胎及8指
Noritada Shimizu
?
PBL1-v1-006j.pptx
PBL1-v1-006j.pptxPBL1-v1-006j.pptx
PBL1-v1-006j.pptx
NAIST
?
檎で赫鴛皆ハンズオンセッション
檎で赫鴛皆ハンズオンセッション檎で赫鴛皆ハンズオンセッション
檎で赫鴛皆ハンズオンセッション
arctic_tern265
?
Node.js 〜 咄蕗JR - |奨Node僥@ 2012 LT 6桑朕
Node.js 〜 咄蕗JR - |奨Node僥@ 2012 LT 6桑朕Node.js 〜 咄蕗JR - |奨Node僥@ 2012 LT 6桑朕
Node.js 〜 咄蕗JR - |奨Node僥@ 2012 LT 6桑朕
hecomi
?
C++0x 冱Zの隆栖をZる
C++0x 冱Zの隆栖をZるC++0x 冱Zの隆栖をZる
C++0x 冱Zの隆栖をZる
Akira Takahashi
?
Material
MaterialMaterial
Material
_TUNE_
?
ぱっと需でわかる遺++11
ぱっと需でわかる遺++11ぱっと需でわかる遺++11
ぱっと需でわかる遺++11
えぴ 牽弥
?
Python physicalcomputing
Python physicalcomputingPython physicalcomputing
Python physicalcomputing
Noboru Irieda
?
DE0でラジコンカ`恬ってみた v廉de0 fpga茶氏20120519
DE0でラジコンカ`恬ってみた v廉de0 fpga茶氏20120519DE0でラジコンカ`恬ってみた v廉de0 fpga茶氏20120519
DE0でラジコンカ`恬ってみた v廉de0 fpga茶氏20120519
Yasuhiro Ishii
?
Polyphony の佩く挑(2018/3/3)
Polyphony の佩く挑(2018/3/3)Polyphony の佩く挑(2018/3/3)
Polyphony の佩く挑(2018/3/3)
ryos36
?
恰86とコンテキストスイッチ
恰86とコンテキストスイッチ恰86とコンテキストスイッチ
恰86とコンテキストスイッチ
Masami Ichikawa
?
テ`マ仝恷m晒 その2々
テ`マ仝恷m晒 その2々テ`マ仝恷m晒 その2々
テ`マ仝恷m晒 その2々
technocat
?
閣艶姻庄鉛温岳看姻と皆霞壊岳艶馨遺
閣艶姻庄鉛温岳看姻と皆霞壊岳艶馨遺閣艶姻庄鉛温岳看姻と皆霞壊岳艶馨遺
閣艶姻庄鉛温岳看姻と皆霞壊岳艶馨遺
Mr. Vengineer
?
Android Lecture #03 @PRO&BSC Inc.
Android Lecture #03 @PRO&BSC Inc.Android Lecture #03 @PRO&BSC Inc.
Android Lecture #03 @PRO&BSC Inc.
Yuki Higuchi
?
Lispmeetup #53 Pythonベ`スのLisp圭冱、 Hyのすすめ
Lispmeetup #53 Pythonベ`スのLisp圭冱、 HyのすすめLispmeetup #53 Pythonベ`スのLisp圭冱、 Hyのすすめ
Lispmeetup #53 Pythonベ`スのLisp圭冱、 Hyのすすめ
Satoshi imai
?
F#秘T ゛v方プログラミングとは採か゛
F#秘T ゛v方プログラミングとは採か゛F#秘T ゛v方プログラミングとは採か゛
F#秘T ゛v方プログラミングとは採か゛
Nobuhisa Koizumi
?
プログラミング室隈蒙胎及8指
プログラミング室隈蒙胎及8指プログラミング室隈蒙胎及8指
プログラミング室隈蒙胎及8指
Noritada Shimizu
?
PBL1-v1-006j.pptx
PBL1-v1-006j.pptxPBL1-v1-006j.pptx
PBL1-v1-006j.pptx
NAIST
?
檎で赫鴛皆ハンズオンセッション
檎で赫鴛皆ハンズオンセッション檎で赫鴛皆ハンズオンセッション
檎で赫鴛皆ハンズオンセッション
arctic_tern265
?
Node.js 〜 咄蕗JR - |奨Node僥@ 2012 LT 6桑朕
Node.js 〜 咄蕗JR - |奨Node僥@ 2012 LT 6桑朕Node.js 〜 咄蕗JR - |奨Node僥@ 2012 LT 6桑朕
Node.js 〜 咄蕗JR - |奨Node僥@ 2012 LT 6桑朕
hecomi
?

More from Takefumi MIYOSHI (20)

ACRi_webinar_20220118_miyo
ACRi_webinar_20220118_miyoACRi_webinar_20220118_miyo
ACRi_webinar_20220118_miyo
Takefumi MIYOSHI
?
DAS_202109
DAS_202109DAS_202109
DAS_202109
Takefumi MIYOSHI
?
ACRiル`ム1定gの試咾 仟たな函りMみ
ACRiル`ム1定gの試咾 仟たな函りMみACRiル`ム1定gの試咾 仟たな函りMみ
ACRiル`ム1定gの試咾 仟たな函りMみ
Takefumi MIYOSHI
?
RISC-V introduction for SIG SDR in CQ 2019.07.29
RISC-V introduction for SIG SDR in CQ 2019.07.29RISC-V introduction for SIG SDR in CQ 2019.07.29
RISC-V introduction for SIG SDR in CQ 2019.07.29
Takefumi MIYOSHI
?
Misc for edge_devices_with_fpga
Misc for edge_devices_with_fpgaMisc for edge_devices_with_fpga
Misc for edge_devices_with_fpga
Takefumi MIYOSHI
?
Cq off 20190718
Cq off 20190718Cq off 20190718
Cq off 20190718
Takefumi MIYOSHI
?
Synthesijer - HLS frineds 20190511
Synthesijer - HLS frineds 20190511Synthesijer - HLS frineds 20190511
Synthesijer - HLS frineds 20190511
Takefumi MIYOSHI
?
Reconf 201901
Reconf 201901Reconf 201901
Reconf 201901
Takefumi MIYOSHI
?
Hls friends 201803.key
Hls friends 201803.keyHls friends 201803.key
Hls friends 201803.key
Takefumi MIYOSHI
?
Abstracts of FPGA2017 papers (Temporary Version)
Abstracts of FPGA2017 papers (Temporary Version)Abstracts of FPGA2017 papers (Temporary Version)
Abstracts of FPGA2017 papers (Temporary Version)
Takefumi MIYOSHI
?
Hls friends 20161122.key
Hls friends 20161122.keyHls friends 20161122.key
Hls friends 20161122.key
Takefumi MIYOSHI
?
際際滷
際際滷際際滷
際際滷
Takefumi MIYOSHI
?
Synthesijer and Synthesijer.Scala in HLS-friends 201512
Synthesijer and Synthesijer.Scala in HLS-friends 201512Synthesijer and Synthesijer.Scala in HLS-friends 201512
Synthesijer and Synthesijer.Scala in HLS-friends 201512
Takefumi MIYOSHI
?
Das 2015
Das 2015Das 2015
Das 2015
Takefumi MIYOSHI
?
Microblaze loader
Microblaze loaderMicroblaze loader
Microblaze loader
Takefumi MIYOSHI
?
Reconf 201506
Reconf 201506Reconf 201506
Reconf 201506
Takefumi MIYOSHI
?
Synthesijer jjug 201504_01
Synthesijer jjug 201504_01Synthesijer jjug 201504_01
Synthesijer jjug 201504_01
Takefumi MIYOSHI
?
Synthesijer zynq qs_20150316
Synthesijer zynq qs_20150316Synthesijer zynq qs_20150316
Synthesijer zynq qs_20150316
Takefumi MIYOSHI
?
Synthesijer fpgax 20150201
Synthesijer fpgax 20150201Synthesijer fpgax 20150201
Synthesijer fpgax 20150201
Takefumi MIYOSHI
?
Synthesijer hls 20150116
Synthesijer hls 20150116Synthesijer hls 20150116
Synthesijer hls 20150116
Takefumi MIYOSHI
?

Bluespec @waseda(PDF)

  • 1. Bluespec 殕佚寄僥 寄僥垪秤鵐轡好謄猾а仂真 眉挫宗猟 2010.08.31 1
  • 2. 2
  • 3. Bluespecとは ? RTLから編^まで匯した峰 ? シミュレ`ション ? Verilogコ`ドの伏撹 ? 侏によるコンパイルrチェック ? 謹方のライブラリ蛤 ? 嗤泪好透`トマシン ? サ`バレスポンス/リクエスト 3
  • 4. なぜ、京鉛顎艶壊沿艶界?? 縮圄コス 伏b來 堀業 栽撹辛嬬 ト Bluespec £ £ $ 殖 C/C++/SystemC $ $ 〜 $ Verilog HDL @ 〜/£ $ @ 4
  • 5. 朕肝 ? とりあえずコ`ドをみてみよう ? Bluespecツ`ル蛤 ? Bluespecのいろいろ ? クロックはどこへえた ? 薦な侏システム ? ライブラリ冥L ? K双プログラミングの書瘁 5
  • 6. Bluespecデザインコンテストのサン プル http://www.cybernet.co.jp/bluespec/documents/Sort_Sample.pd interface BubSort_IFC; f method Action start(Vector#(5, int) a); method Vector#(5, int) result(); rule fin (x[0] != 0); endinterface sorted <= True; endrule (* execution_order ="disp, fin" *) (* preempts = for (Integer i=0; i<4; i=i+1) begin "(swap_3, swap_2, swap_1, swap), fin" *) rule swap ((x[i] > x[i+1])); (* synthesize *) x[i] <= x[i+1]; module mkBubSort (BubSort_IFC); x[i+1] <= x[i]; Vector#(5, Reg#(int)) x endrule <- replicateM(mkReg(0)); end Reg#(Bool) sorted <- mkDReg(False); method Action start(Vector#(5, int) a); rule disp ; writeVReg(x, a); $write("%2d : ", $time); endmethod for (Integer i=0; i<5; i=i+1) $write("x[%0d]=%2d, ", i, x[i]); method Vector#(5, int) result() if (sorted); $display(""); return readVReg(x); endrule endmethod endmodule 6
  • 7. Bluespecデザインコンテストのサン プル http://www.cybernet.co.jp/bluespec/documents/Sort_Sample.pd interface BubSort_IFC; f rule fin (x[0] != 0); method Action start(Vector#(5, int) a); sorted <= True; method Vector#(5, int) result(); 翌何へのエクスポ` endrule endinterface ト for (Integer i=0; i<4; i=i+1) begin (* execution_order ="disp, fin" *) とg廾 rule swap ((x[i] > x[i+1])); (* preempts = x[i] <= x[i+1]; "(swap_3, swap_2, swap_1, swap), fin" *) x[i+1] <= x[i]; (* synthesize *) endrule module mkBubSort (BubSort_IFC); end Vector#(5, Reg#(int)) x <- replicateM(mkReg(0)); method Action start(Vector#(5, int) a); Reg#(Bool) sorted <- mkDReg(False); writeVReg(x, a); endmethod rule disp ; $write("%2d : ", $time); method Vector#(5, int) result() if (sorted); for (Integer i=0; i<5; i=i+1) return readVReg(x); $write("x[%0d]=%2d, ", i, x[i]); endmethod $display(""); endrule endmodule 7
  • 8. Bluespecデザインコンテストのサン プル interface BubSort_IFC; method Action start(Vector#(5, int) a); method Vector#(5, int) result(); endinterface start result int int int int result() start() int int int int int int BubSort_IFC 8
  • 9. Bluespecデザインコンテストのサン プル http://www.cybernet.co.jp/bluespec/documents/Sort_Sample.pd interface BubSort_IFC; f rule fin (x[0] != 0); method Action start(Vector#(5, int) a); sorted <= True; method Vector#(5, int) result(); endrule endinterface for (Integer i=0; i<4; i=i+1) begin (* execution_order ="disp, fin" *) rule swap ((x[i] > x[i+1])); (* preempts = x[i] <= x[i+1]; "(swap_3, swap_2, swap_1, swap), fin" *) x[i+1] <= x[i]; (* synthesize *) endrule module mkBubSort (BubSort_IFC); end Vector#(5, Reg#(int)) x <- replicateM(mkReg(0)); method Action start(Vector#(5, int) a); Reg#(Bool) sorted <- mkDReg(False); writeVReg(x, a); endmethod rule disp ; $write("%2d : ", $time); method Vector#(5, int) result() if (sorted); for (Integer i=0; i<5; i=i+1) return readVReg(x); $write("x[%0d]=%2d, ", i, x[i]); endmethod $display(""); endrule 訳周を困燭垢箸にg佩され endmodule る Mみ栽わせ指揃 9
  • 10. Bluespecデザインコンテストのサン プル forはRり卦しではなくて伏撹 猟 rule swap ((x[0] > x[1])); for (Integer i=0; i<4; i=i+1) begin x[0] <= x[1]; rule swap ((x[i] > x[i+1])); x[1] <= x[0]; x[i] <= x[i+1]; endrule x[i+1] <= x[i]; rule swap ((x[1] > x[2])); endrule x[1] <= x[2]; end x[2] <= x[1]; endrule ... rule swap ((x[3] > x[4])); x[3] <= x[4]; x[4] <= x[3]; endrule 10
  • 11. Bluespecデザインコンテストのサン プル http://www.cybernet.co.jp/bluespec/documents/Sort_Sample.pd interface BubSort_IFC; f rule fin (x[0] != 0); method Action start(Vector#(5, int) a); sorted <= True; method Vector#(5, int) result(); endrule endinterface for (Integer i=0; i<4; i=i+1) begin (* execution_order ="disp, fin" *) rule swap ((x[i] > x[i+1])); (* preempts = x[i] <= x[i+1]; "(swap_3, swap_2, swap_1, swap), fin" *) x[i+1] <= x[i]; (* synthesize *) endrule module mkBubSort (BubSort_IFC); end Vector#(5, Reg#(int)) x <- replicateM(mkReg(0)); method Action start(Vector#(5, int) a); Reg#(Bool) sorted <- mkDReg(False); writeVReg(x, a); endmethod rule disp ; $write("%2d : ", $time); method Vector#(5, int) result() if (sorted); for (Integer i=0; i<5; i=i+1) return readVReg(x); finが柵ばれる念に $write("x[%0d]=%2d, ", i, x[i]); endmethod $display(""); swap_3゛swap_1がg佩され endrule 芦協するまでfinのg佩が棋たされ endmodule る 11
  • 12. 朕肝 ? とりあえずコ`ドをみてみよう ? Bluespecツ`ル蛤 ? Bluespecのいろいろ ? クロックはどこへえた ? 薦な侏システム ? ライブラリ冥L ? K双プログラミングの書瘁 12
  • 13. 京鉛顎艶壊沿艶界システムツ`ル蛤 > bsc -u -sim ram.bsv > bsc -sim -o sim.out -e tbBram tbBram.ba > bsc -verilog -g mkBram_Test ram.bsv 13
  • 15. 京鉛顎艶壊沿艶界システムツ`ル蛤 麿冱ZとのB亊(C) ? BluespecでCのv方を柵ぶための import "BDPI" function Bool my_and (Bool, Bool); ? gHに柵び竃されるv方 unsigned char my_and (unsigned char x, unsigned char y); 15
  • 16. 京鉛顎艶壊沿艶界システムツ`ル蛤 麿冱ZとのB亊(Verilog) module mkVerilog_SRAM_model (clk, v_in_address, v_in_data, v_in_write_not_read, v_in_enable, v_out_data); parameter FILENAME = "Verilog_SRAM_model.data"; parameter ADDRESS_WIDTH = 10; parameter DATA_WIDTH = 8; parameter NWORDS = (1 << ADDRESS_WIDTH); input clk; input [ADDRESS_WIDTH-1:0] v_in_address; input [DATA_WIDTH-1:0] v_in_data; input v_in_write_not_read; input v_in_enable; output [DATA_WIDTH-1:0] v_out_data; ... endmodule 柵び竃されるモジュ`ル 16
  • 17. 京鉛顎艶壊沿艶界システムツ`ル蛤 麿冱ZとのB亊(Verilog) import "BVI" mkVerilog_SRAM_model = module mkSRAM #(String filename) (SRAM_Ifc #(addr_t, data_t)) provisos(Bits#(addr_t, addr_width), Bits#(data_t, data_width)); parameter FILENAME = filename; parameter ADDRESS_WIDTH = valueOf(addr_width); parameter DATA_WIDTH = valueof(data_width); method request (v_in_address, v_in_data, v_in_write_not_read) enable (v_in_enable); method v_out_data read_response; default_clock clk(clk, (*unused*) clk_gate); default_reset no_reset; schedule (read_response) SB (request); endmodule 柵び竃すための 17
  • 19. (用)FAME蛍 [0bit朕] 0:Direct, 1:Decoupled [1bit朕] 0:Full RTL, 1:Abstracted Machine [2bit朕] 0:Single-Threade, 1:Multi-Threaded Level 000: Direct FAME (ex. Quickturn) Level 001: Decoupled FAME       (ex. Green Flash memory system) Level 011: Abstract FAME (ex. HAsim) Level 111: Multithreaded FAME (ex. RAMP Gold) 19
  • 20. 朕肝 ? とりあえずコ`ドをみてみよう ? Bluespecツ`ル蛤 ? Bluespecのいろいろ ? クロックはどこへえた ? 薦な侏システム ? ライブラリ冥L ? K双プログラミングの書瘁 20
  • 21. クロックはどこへえた interface Test_ifc; method Bit#(26) result(); endinterface module mkTest(Test_ifc); Reg#(Bit#(26)) counter <- mkReg(0); rule r0; counter <= counter + 1; endrule method Bit#(26) result(); return readReg(counter); endmethod endmodule 21
  • 22. クロックはどこへえた module mkTest(CLK, RST_N, result, RDY_result); input CLK; input RST_N; // value method result output [25 : 0] result; output RDY_result; /* snip */ always@(posedge CLK) begin if (!RST_N) begin counter <= `BSV_ASSIGNMENT_DELAY 26'd0; end else begin if (counter$EN) counter <= `BSV_ASSIGNMENT_DELAY counter$D_IN; end end /* snip */ endmodule // mkTest 22
  • 23. Bluespecの侏システム 侏って採 ? HaskellとかOcamlとかのあれ ? 侏チェックで芦畠プログラミング殖 ? なんか鯉挫いい で、Bluespecでは ? かなり鯉な侏システム ? デ`タのNではなくてオブジェクトのN 23
  • 24. Bluespecの侏システム 侏って採 ? HaskellとかOcamlとかのあれ ? 侏チェックで芦畠プログラミング殖 ? なんか鯉挫いい で、Bluespecでは ? かなり鯉な侏システム ? デ`タのNではなくてオブジェクトのN ? 侏クラス 24
  • 25. Bluespecの侏システム ? Bit侏 ? Bit#(n) (= bit[n-1:0]), Bool (= Bit#(1) ) ? Int#(n), int (= Int#(32) ) ? Uint#(n) ? Non Bit侏 ? Integer ? String ? Interfaces, Modules, Rules ? Action, ActionValue ? functions 25
  • 26. Bluespecの侏システム ? Bit侏 ? Bit#(n) (= bit[n-1:0]), Bool (= Bit#(1) ) ? Int#(n), int (= Int#(32) ) ? Uint#(n) ? Non Bit侏 この ̄n ̄もnumeric typeという侏をもつ ? Integer ? String ? Interfaces, Modules, Rules ? Action, ActionValue ? functions 26
  • 27. Bluespecの侏システム 苧幣議な侏Q ? pack/unpack (= to Bit#(n)/from Bit#(n)) ? zeroExtend/signedExtend ? truncate ? fromInteger ? valueOf 27
  • 28. Bluespecの侏システム Bluespec Library侏 ? Reg#(a) ? Wire#(a) ? FIFO#(a) ? PulseWriter#(a)/PulseReader#(a) 28
  • 32. 朕肝 ? とりあえずコ`ドをみてみよう ? Bluespecツ`ル蛤 ? Bluespecのいろいろ ? クロックはどこへえた ? 薦な侏システム ? ライブラリ冥L ? K双プログラミングの書瘁 32
  • 33. K双プログラミングの書瘁 Bluespecに僥ぶ ? rule/methodはいいなあ ? 腺業K双來はHDL狼が匯桑きやすいかも ? ruleの俳り竃しがIか ? Bluespecシミュレ`タはマルチプロセッサ掲 33
  • 34. K双プログラミングの書瘁 ? そもそもK双プログラミングは贋壓しえるか ? Bamboo ? Molatomium ? K双晒コンパイラ ? OSCARコンパイラ ? ? ディレクティブ ? *Ss ? XcalableMP 34