0

サーモメトリック デコーダーのこの Verilog コードを見つけました (コード エンコーダーで、これは間違っています)。

そこからネットリストを生成するために、ケイデンスに合わせたいと思います。私の問題は、実際のコードが [7:0] + 1 入力と [3:0] 出力をケイデンスで生成することです。

私が欲しいのは、8 + 1 の単一入力と 4 つの単一出力を備えたモジュールです。

module thermometer_encoder_8bit(
 out0,out1,out2,out3, //  4-bit binary Output
 in0,in1,in2,in3,in4,in5,in6,in7, //  8-bit Input
 enable       //  Enable for the encoder
 );

 input  enable;
 input in0,in1,in2,in3,in4,in5,in6,in7;
 output out0,out1,out2,out3;

 reg out0,out1,out2,out3;
 ... 

これは実際の、適応されていないコードです。

module thermometer_encoder_8bit(
  binary_out , //  4 bit binary Output
  encoder_in , //  8-bit Input
  enable       //  Enable for the encoder
  );
  output [3:0] binary_out  ;
  input  enable ; 
  input [7:0] encoder_in ; 

  reg [3:0] binary_out ;

  always @ (enable or encoder_in)
  begin
  binary_out = 0;                 // 0000 0000
  if (enable) begin
     case (encoder_in) 

       8'b00000001 : binary_out = 1;  // 0000 0001
       8'b00000011 : binary_out = 2;  // 0000 0011
       8'b00000111 : binary_out = 3;  // 0000 0111
       8'b00001111 : binary_out = 4;  // 0000 1111
       8'b00011111 : binary_out = 5;  // 0001 1111
       8'b00111111 : binary_out = 6;  // 0011 1111
       8'b01111111 : binary_out = 7;  // 0111 1111
       8'b11111111 : binary_out = 8;  // 0000 1111

     endcase
   end
  end

endmodule

これを簡単な方法で行う可能性はありますか?

ごきげんよう、ダホーマー

4

2 に答える 2

0

まず、defaultステートメントが表示されません。

encoder_incaseステートメントに記載されている数字のみが含まれていることが確実な場合は、次のようなものを使用できます。binary_out = $clog2(encoder_in + 1)

于 2016-06-28T06:38:59.270 に答える