Posts Tagged with "BSV"

既に発行済みのブログであっても適宜修正・追加することがあります。
We may make changes and additions to blogs already published.

色変換回路 (4)

posted by sakurai on October 20, 2023 #682

試行錯誤した結果、always_readyは解決しました。WireでなくDWireを用いるとうまく消えることがわかりました。ソースにおいて修正点のみを示すと、

(* synthesize, always_enabled = "setInputs", always_ready = "getRO, getGO, getBO" *)

及び

    Wire#(Bit#(1)) r_reg <- mkDWire(?);
    Wire#(Bit#(1)) g_reg <- mkDWire(?);
    Wire#(Bit#(1)) b_reg <- mkDWire(?);

の2か所を修正するだけです。生成されたverilogはかなりスッキリしてきており、後は未使用のCLK及びRST_Nを削除する方法だけですが、(* no_default_clock, no_default_reset *) とすれば良いようです。

module mkColorConverter(CLK,
            RST_N,
            RI,
            GI,
            BI,
            RO,
            GO,
            BO);
  input  CLK;
  input  RST_N;

  // action method setInputs
  input  RI;
  input  GI;
  input  BI;

  // value method getRO
  output [3 : 0] RO;
  // value method getGO
  output [3 : 0] GO;
  // value method getBO
  output [3 : 0] BO;

  // signals for module outputs
  reg [3 : 0] BO, GO, RO;
  // remaining internal signals
  wire [2 : 0] x__h322;

  // value method getRO
  always@(x__h322)
  begin
    case (x__h322)
      3'b0: RO = 4'h9;
      3'b001: RO = 4'hD;
      3'b010: RO = 4'h5;
      default: RO = 4'hC;
    endcase
  end

  // value method getGO
  always@(x__h322)
  begin
    case (x__h322)
      3'b0: GO = 4'h4;
      3'b001: GO = 4'h8;
      3'b010: GO = 4'hB;
      default: GO = 4'hC;
    endcase
  end

  // value method getBO
  always@(x__h322)
  begin
    case (x__h322)
      3'b0: BO = 4'h1;
      3'b001: BO = 4'h4;
      3'b010: BO = 4'h5;
      default: BO = 4'hC;
    endcase
  end

  // remaining internal signals
  assign x__h322 = { RI, GI, BI } ;
endmodule  // mkColorConverter

左矢前のブログ 次のブログ右矢


ページ: