1

vhdl で心拍センサーのカウンターを作成したいと考えています。ハートビートごとに点灯するセンサーがあります。点灯した回数を数えたいのですが、コードにビートがありません。

私のコード

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;

entity pulse is port(
    heartin : in std_logic;
    clk : in std_logic;
    reset : in std_logic;
    F : out std_logic_vector ( 6 downto 0)
);
end pulse;

architecture Behavioral of pulse is

    component clkdivider is Port (
        clkin: in std_logic;
        clkout:out std_logic
    );
    end component;
    signal x : std_logic_vector (3 downto 0):= "0000";
    signal y : std_logic_vector (6 downto 0);
    signal wire: std_logic;

begin
    L2:clkdivider port map (clkin=>clk, clkout=>wire);

    process(wire) 
    begin
        if rising_edge (wire) then
            if reset = '1' then
                x <= "0000";
            elsif heartin = '1' then
                x <= (x + "0001");
            end if;
        end if;
    end process;

    process(x,y)
    begin
        case x is
            when "0000"=> y<="1000000";  -- '0'
            when "0001"=> y<="1111001";  -- '1'
            when "0010"=> y<="0100100";  -- '2'
            when "0011"=> y<="0110000";  -- '3'
            when "0100"=> y<="0011001";  -- '4' 
            when "0101"=> y<="0010010";  -- '5'
            when "0110"=> y<="0000010";  -- '6'
            when "0111"=> y<="1111000";  -- '7'
            when "1000"=> y<="0000000";  -- '8'
            when "1001"=> y<="0010000";  -- '9'
            when "1010"=> y<="0001000";  -- 'A'
            when "1011"=> y<="0000011";  -- 'b'
            when "1100"=> y<="1000110";  -- 'C'
            when "1101"=> y<="0100001";  -- 'd'
            when "1110"=> y<="0000110";  -- 'E'
            when others=> y<="0001110";  -- 'F'     

        end case;   
    end process;

    F <= y;

end Behavioral;

Clkdivider コード:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity clkdivider is Port (
    clkin: in std_logic;
    clkout:out std_logic
);
end clkdivider;

architecture Behavioral of clkdivider is
    signal int_clock:std_logic;
begin
    clkout<=int_clock;
    process(clkin)
        variable var:integer range 0 to 2200000 :=0;
    begin
        if (clkin'event and clkin = '1') then
            if var = 2200000 then
                int_clock <= not int_clock;
                var := 0;
            else
                var := var+1;
            end if;
        end if;
    end process;
end Behavioral;
4

1 に答える 1

0

ここに私の考えがあります:

  • クロック分周器は、たとえば 8ns ごとに遷移するクロックを、はるかに少ない頻度で遷移するクロックに取ります。
  • のではなく のの場合heartin = 1はどうなりますか?rising_edgeclk_inrising_edgewire
  • そもそもなぜクロックを分割しているのか、私には明らかではありません。心拍はどのくらいのペースで発生しますか?

あなたのコードが現在のように見えない理由は明らかではありませんが、clkdivider をすべてスキップして、より高速なクロックでカウンター ロジックを実行するだけです。

于 2012-12-12T18:41:06.663 に答える