-1

VHDL を使用して可変ビット カウンター (リングやジョンソンなどの任意のカウンター) を設計するさまざまな方法を試みましたが、すべて無駄でした。

誰かがこれを克服するのを手伝ってくれますか?

4

2 に答える 2

1

VHDL の場合:

最初にカウンターのピンを記述する必要があります。

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity counter
port (
  clk    : in std_ulogic;
  resetn : in std_ulogic;
  count  : out unsigned
);

次に、それがどのように動作するかを説明します。

architecture behaviour of counter is

begin
  process(clk) -- run this process whenever CLK changes
  begin
    if rising_edge(clk) then -- only on the rising edges, run the code
      if reset = '1' then    
        count <= (others => '0'); -- set count to all bits 0
      else
        count <= count + 1; -- you'll need VHDL-2008 switched on to do this as it is reading an output signal
      end if;
    end if;
  end process;
end architecture;

このカウンターを使用すると、カウント信号は、より高いレベルで接続されている信号から正しいビット数を継承します。

于 2013-09-20T09:56:57.597 に答える
0

ウィキペディアの回路図によるジョンソンカウンターは、次のLSBが反転MSBである単なるシフトレジスタです。

module johnson_counter #(
  parameter WIDTH = 4
) (
  input                  clk,
  input                  rst_n,
  output reg [WIDTH-1:0] state
);
always @(posedge clk or negedge rst_n) begin
  if (~rst_n) begin
    state <= {WIDTH{1'b0}}; //Replication to extend 1'b0
  end
  else begin
    //Shift Left 1, bit LSB becomes inverted MSB
    state <= {state[WIDTH-2:0], ~state[WIDTH-1]}; //Concatination
  end
endmodule
于 2013-09-20T06:44:07.920 に答える