Nếu bạn muốn tổng hợp thiết kế của bạn cho một FPGA thực hoặc ASIC, bạn sẽ phải suy nghĩ của VHDL về phần cứng thực sự (dây, flip flops, cửa, vv) Ngoài ra, nếu bạn muốn thực hiện một phát triển cạnh thực sự tăng trong phần cứng , bạn sẽ cần một đồng hồ hệ thống mà ổ đĩa flip flop.Với mẫu mã ban đầu của bạn, nó không có vẻ là zbroji hoặc oduzmi là đồng hồ hệ thống, nhưng chỉ std_logic tín hiệu.Tôi đã viết ví dụ mã này giả định chức năng cơ bản từ ví dụ của bạn, hy vọng , bạn có thể lấy mã và nhận xét của tôi và hoàn thành những gì bạn cần.
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity example is
port (Reset : in std_logic;
SysClk : in std_logic;
zbroji : in std_logic;
oduzmi : in std_logic;
ulaz_broj : in std_logic;
oduzima : out std_logic;
ucitanPrvi : out std_logic;
broj1 : out std_logic
);
end example;
architecture Behavioral of example is
-- Delayed version of input signals (1 clock cycle delay)
signal zbroji_d : std_logic;
signal oduzmi_d : std_logic;
signal zbrojiRE : std_logic;
signal oduzmiRE : std_logic;
begin
-- Generate 1 clock cycle delayed version of
-- signals we want to detect the rising edge
-- Assumes active high reset
-- Note: You should only use the rising_edge macro
-- on an actual global or regional clock signal. FPGA's and
-- ASICs place timing constraints on defined clock signals
-- that make it possible to use rising_edge, otherwise, we have
-- to generate our own rising edge signals by comparing delayed
-- versions of a signal with the current signal.
-- Also, with any respectable synthesizer/simulator using
-- rising_edge is almos exactly the same as (clk'event and clk='1')
-- except rising_edge only returns a '1' when the clock makes a
-- valid '0' to '1' transition. (see link below)
EdgeDetectProc : process (Reset, SysClk)
begin
if Reset = '1' then
zbroji_d <= '0';
oduzmi_d <= '0';
elsif rising_edge(SysClk) then
zbroji_d <= zbroji;
oduzmi_d <= oduzmi;
end if;
end process EdgeDetectProc;
-- Assert risinge edge signals for one clock cycle
zbrojiRE <= '1' when zbroji = '1' and zbroji_d = '0' else '0';
oduzmiRE <= '1' when oduzmi = '1' and oduzmi_d = '0' else '0';
-- Assumes that you want a single cycle pulse on ucitanPrvi on the
-- rising edege of zbroji or oduzmi;
ucitanPrvi <= zbrojiRE or oduzmiRE;
-- Based on your example, I can't tell what you want to do with the
-- broj1 signal, but this logic will drive broj1 with ulaz_broj on
-- either the zbroji or oduzmi rising edge, otherwise '0'.
broj1 <= ulaz_broj when zbrojiRE = '1' else
ulaz_broj when oduzmiRE = '1' else
'0';
-- Finally, it looks like you want to clear oduzima on the rising
-- edge of zbroji and assert oduzima on the rising edge of
-- oduzmi
LatchProc : process (Reset, SysClk)
begin
if Reset = '1' then
oduzima <= '0';
elsif rising_edge(SysClk) then
if zbrojiRE = '1' then
oduzima <= '0';
elsif oduzmiRE = '1' then
oduzima <= '1';
end if;
end if;
end process LatchProc;
end Behavioral;
Mã trước giả sử bạn có đồng hồ hệ thống. Trong một mô phỏng như ModelSim (miễn phí phiên bản sinh viên), bạn có thể tạo ra một chiếc đồng hồ 100 MHz với mã testbench phi synthesizable như thế này ...
ClockProc : process
begin
SysClk <= '0';
wait for 5 ns;
SysClk <= '1';
wait for 5 ns;
end process ClockProc;
trong một FPGA/ASIC thực hiện thực tế, có thể bạn sẽ muốn sử dụng một bộ dao động bên ngoài mà bạn chạy vào chip của bạn, đưa tín hiệu vào DCM (Trình quản lý đồng hồ kỹ thuật số), sẽ tạo ra một tín hiệu đồng hồ rất sạch sẽ cho tất cả logic VHDL của bạn, vì vậy bạn có thể có một thiết kế miễn phí.
Và cuối cùng, đây là một lời giải thích rất lớn về sự khác biệt giữa rising_edge và (clk'event và CLK = '1')
http://vhdlguru.blogspot.com/2010/04/difference-between-risingedgeclk-and.html
Hy vọng rằng sẽ giúp.
Đồng hồ odzumi và zbroji hay chỉ là tín hiệu? –
Chúng chỉ là tín hiệu – xx77aBs