-- DCM module
library ieee;
use ieee.std_logic_1164.all;
-- pragma translate_off
library unisim;
use unisim.vcomponents.all;
-- pragma translate_on
library work;
entity dcm_inst is
port (
clkin : in std_logic;
reset : in std_logic;
clkout : out std_logic;
clk90 : out std_logic;
locked : out std_logic
);
end dcm_inst;
architecture RTL of dcm_inst is
component DCM
generic (
CLKDV_DIVIDE : real := 2.0;
CLKFX_DIVIDE : integer := 1;
CLKFX_MULTIPLY : integer := 4;
CLKIN_DIVIDE_BY_2 : boolean := false;
CLKIN_PERIOD : real := 10.0;
CLKOUT_PHASE_SHIFT : string := "NONE";
CLK_FEEDBACK : string := "1X";
DESKEW_ADJUST : string := "SYSTEM_SYNCHRONOUS";
DFS_FREQUENCY_MODE : string := "LOW";
DLL_FREQUENCY_MODE : string := "LOW";
DSS_MODE : string := "NONE";
DUTY_CYCLE_CORRECTION : boolean := true;
FACTORY_JF : bit_vector := X"C080";
PHASE_SHIFT : integer := 0;
SIM_MODE : string := "SAFE";
STARTUP_WAIT : boolean := false
);
port ( CLKIN : in std_logic;
CLKFB : in std_logic;
DSSEN : in std_logic;
PSINCDEC : in std_logic;
PSEN : in std_logic;
PSCLK : in std_logic;
RST : in std_logic;
CLK0 : out std_logic;
CLK90 : out std_logic;
CLK180 : out std_logic;
CLK270 : out std_logic;
CLK2X : out std_logic;
CLK2X180 : out std_logic;
CLKDV : out std_logic;
CLKFX : out std_logic;
CLKFX180 : out std_logic;
LOCKED : out std_logic;
PSDONE : out std_logic;
STATUS : out std_logic_vector(7 downto 0)
);
end component;
component BUFG
port (
I : in std_logic;
O : out std_logic
);
end component;
component IBUFG
port (
I : in std_logic;
O : out std_logic
);
end component;
signal clk_ibuf : std_logic;
signal clkfb : std_logic;
signal gnd, clk_node : std_logic;
signal clkdv_node, clkdv_bufg : std_logic;
signal clk_node2, clk90_node : std_logic;
signal clk90_bufg, clk_bufg : std_logic;
signal dcm1_locked : std_logic;
signal dcm2_reset : std_logic;
begin
gnd <= '0';
ibufg_inst : ibufg port map(
i => clkin,
o => clk_ibuf
);
dcm1 : dcm generic map(
CLKFX_DIVIDE => 4,
CLKFX_MULTIPLY => 1,
CLKDV_DIVIDE => 4.0
)port map(
clkin => clk_ibuf,
clkfb => clkfb,
dssen => gnd,
psincdec => gnd,
psen => gnd,
psclk => clk_ibuf,
rst => reset,
clk0 => clk_node,
clk90 => open,
clk180 => open,
clk270 => open,
clk2x => open,
clk2x180 => open,
clkdv => clkdv_node,
clkfx => open,
clkfx180 => open,
locked => dcm1_locked,
psdone => open,
status => open
);
bufg_inst : bufg port map(
i => clk_node,
o => clkfb
);
-- clkout <= clkfb;
bufg_clkdv : bufg port map(
i => clkdv_node,
o => clkdv_bufg
);
dcm2_reset <= not dcm1_locked;
dcm2 : dcm generic map(
CLKDV_DIVIDE => 4.0
)port map(
clkin => clkdv_bufg,
clkfb => clk_bufg,
dssen => gnd,
psincdec => gnd,
psen => gnd,
psclk => clk_ibuf,
rst => dcm2_reset,
clk0 => clk_node2,
clk90 => clk90_node,
clk180 => open,
clk270 => open,
clk2x => open,
clk2x180 => open,
clkdv => open,
clkfx => open,
clkfx180 => open,
locked => locked,
psdone => open,
status => open
);
bufg_clk0_2 : bufg port map(
i => clk_node2,
o => clk_bufg
);
bufg_clk90 : bufg port map(
i => clk90_node,
o => clk90_bufg
);
clkout <= clk_bufg;
clk90 <= clk90_bufg;
end RTL;
SRL16E_inst : SRL16E
generic map (
INIT => X"0000")
port map (
Q => Q, -- SRL data output
A0 => A0, -- Select[0] input
A1 => A1, -- Select[1] input
A2 => A2, -- Select[2] input
A3 => A3, -- Select[3] input
CE => CE, -- Clock enable input
CLK => CLK, -- Clock input
D => D -- SRL data input
);
-- DCM module
library ieee;
use ieee.std_logic_1164.all;
library unisim;
use unisim.vcomponents.all;
library work;
entity dcm_inst is
port (
clkin : in std_logic;
reset : in std_logic;
clkout : out std_logic;
clk90 : out std_logic;
locked : out std_logic
);
end dcm_inst;
architecture RTL of dcm_inst is
component DCM
generic (
CLKDV_DIVIDE : real := 2.0;
CLKFX_DIVIDE : integer := 2;
CLKFX_MULTIPLY : integer := 4;
CLKIN_DIVIDE_BY_2 : boolean := false;
CLKIN_PERIOD : real := 10.0;
CLKOUT_PHASE_SHIFT : string := "NONE";
CLK_FEEDBACK : string := "1X";
DESKEW_ADJUST : string := "SYSTEM_SYNCHRONOUS";
DFS_FREQUENCY_MODE : string := "LOW";
DLL_FREQUENCY_MODE : string := "LOW";
DSS_MODE : string := "NONE";
DUTY_CYCLE_CORRECTION : boolean := true;
FACTORY_JF : bit_vector := X"C080";
PHASE_SHIFT : integer := 0;
SIM_MODE : string := "SAFE";
STARTUP_WAIT : boolean := false
);
port ( CLKIN : in std_logic;
CLKFB : in std_logic;
DSSEN : in std_logic;
PSINCDEC : in std_logic;
PSEN : in std_logic;
PSCLK : in std_logic;
RST : in std_logic;
CLK0 : out std_logic;
CLK90 : out std_logic;
CLK180 : out std_logic;
CLK270 : out std_logic;
CLK2X : out std_logic;
CLK2X180 : out std_logic;
CLKDV : out std_logic;
CLKFX : out std_logic;
CLKFX180 : out std_logic;
LOCKED : out std_logic;
PSDONE : out std_logic;
STATUS : out std_logic_vector(7 downto 0)
);
end component;
component BUFG
port (
I : in std_logic;
O : out std_logic
);
end component;
component IBUFG
port (
I : in std_logic;
O : out std_logic
);
end component;
signal clk_ibuf : std_logic;
signal clkfb : std_logic;
signal gnd, clk_node : std_logic;
signal clkdv_node, clkdv_bufg : std_logic;
signal clk_node2, clk90_node : std_logic;
signal clk90_bufg, clk_bufg : std_logic;
signal dcm1_locked : std_logic;
signal dcm2_reset : std_logic;
signal dcm2_reset_SRL16E : std_logic;
begin
gnd <= '0';
ibufg_inst : ibufg port map(
i => clkin,
o => clk_ibuf
);
dcm1 : dcm generic map(
CLKFX_DIVIDE => 8,
CLKFX_MULTIPLY => 2,
CLKDV_DIVIDE => 4.0
)port map(
clkin => clk_ibuf,
clkfb => clkfb,
dssen => gnd,
psincdec => gnd,
psen => gnd,
psclk => clk_ibuf,
rst => reset,
clk0 => clk_node,
clk90 => open,
clk180 => open,
clk270 => open,
clk2x => open,
clk2x180 => open,
clkdv => clkdv_node,
clkfx => open,
clkfx180 => open,
locked => dcm1_locked,
psdone => open,
status => open
);
bufg_inst : bufg port map(
i => clk_node,
o => clkfb
);
-- clkout <= clkfb;
bufg_clkdv : bufg port map(
i => clkdv_node,
o => clkdv_bufg
);
dcm2_reset <= not dcm1_locked;
SRL16E_inst : SRL16E generic map(
INIT => X"FFFF")
port map(
Q => dcm2_reset_SRL16E,
A0 => '0',
A1 => '0',
A2 => '1',
A3 => '1',
CE => '1',
CLK => clk_ibuf,
D => dcm2_reset
);
dcm2 : dcm generic map(
CLKDV_DIVIDE => 4.0
)port map(
clkin => clkdv_bufg,
clkfb => clk_bufg,
dssen => gnd,
psincdec => gnd,
psen => gnd,
psclk => clk_ibuf,
rst => dcm2_reset_SRL16E,
clk0 => clk_node2,
clk90 => clk90_node,
clk180 => open,
clk270 => open,
clk2x => open,
clk2x180 => open,
clkdv => open,
clkfx => open,
clkfx180 => open,
locked => locked,
psdone => open,
status => open
);
bufg_clk0_2 : bufg port map(
i => clk_node2,
o => clk_bufg
);
bufg_clk90 : bufg port map(
i => clk90_node,
o => clk90_bufg
);
clkout <= clk_bufg;
clk90 <= clk90_bufg;
end RTL;
library unisim;
use unisim.vcomponents.all;
`default_nettype none
`timescale 1ns / 1ps
module init_test(
input clk,
input enable,
output [15:0] cnt_out
);
reg [15:0] cnt = 16'd1; // 初期化(ここの値がFFの初期値になっていればOK)
always @(posedge clk) begin
if (enable)
cnt <= cnt + 1;
end
assign cnt_out = cnt;
endmodule
n_mem_data_oe <= not mem_data_oe;
MEM_DATA_GEN : for i in 15 downto 0 generate
IOBUF_inst : IOBUF port map(
O => input_mem_data(i),
IO => mem_data(i),
I => mem_data_out(i),
T => n_mem_data_oe
);
end generate MEM_DATA_GEN;
-- n_mem_we, mem_data_oe を生成する。48MHzのステートマシンで出力
process(clk48) begin
if clk48'event and clk48='1' then
if reset='1' then
cs_we <= idle_we;
else
cs_we <= ns_we;
end if;
end if;
end process;
process(cs_we, r_w, cam_href_3d) begin
case cs_we is
when idle_we =>
n_mem_we_node <= '1';
mem_data_oe <= '0';
if r_w='0' and cam_href_3d='1' then -- hrefの間だけSRAMにWriteする
ns_we <= we_active;
else
ns_we <= idle_we;
end if;
when we_active => -- r_w が1時48MHzクロック1クロック間だけ n_mem_we を0にする
n_mem_we_node <= '0';
mem_data_oe <= '1';
ns_we <= we_holdoff;
when we_holdoff => -- この時はまだr_wが0
n_mem_we_node <= '1';
mem_data_oe <= '0';
ns_we <= idle_we;
end case;
end process;
n_mem_we <= n_mem_we_node;
signal mem_data_node : std_logic_vector(15 downto 0);
signal next_mem_data_oe : std_logic;
attribute iob : string;
attribute iob of n_mem_data_oe : signal is "TRUE";
attribute keep : string;
attribute keep of n_mem_data_oe : signal is "TRUE";
attribute keep of next_mem_data_oe : signal is "TRUE";
begin
.....
-- n_mem_we, mem_data_oe を生成する。48MHzのステートマシンで出力
process(clk48) begin
if clk48'event and clk48='1' then
if reset='1' then
cs_we <= idle_we;
else
cs_we <= ns_we;
end if;
end if;
end process;
process(cs_we, r_w, cam_href_3d) begin
case cs_we is
when idle_we =>
n_mem_we_node <= '1';
if r_w='0' and cam_href_3d='1' then -- hrefの間だけSRAMにWriteする
ns_we <= we_active;
next_mem_data_oe <= '1';
else
ns_we <= idle_we;
next_mem_data_oe <= '0';
end if;
when we_active => -- r_w が1時48MHzクロック1クロック間だけ n_mem_we を0にする
n_mem_we_node <= '0';
ns_we <= we_holdoff;
next_mem_data_oe <= '0';
when we_holdoff => -- この時はまだr_wが0
n_mem_we_node <= '1';
ns_we <= idle_we;
next_mem_data_oe <= '0';
when others =>
n_mem_we_node <= '1';
ns_we <= idle_we;
next_mem_data_oe <= '0';
end case;
end process;
n_mem_we <= n_mem_we_node;
-- mem_data_oeの出力
process(clk48) begin
if clk48'event and clk48='1' then
if reset='1' then
n_mem_data_oe <= (others => '1');
else
for i in 15 downto 0 loop
n_mem_data_oe(i) <= not next_mem_data_oe;
end loop;
end if;
end if;
end process;
MEM_DATA_GEN : for i in 15 downto 0 generate
IOBUF_inst : IOBUF port map(
O => input_mem_data(i),
IO => mem_data(i),
I => mem_data_out(i),
T => n_mem_data_oe(i)
);
end generate MEM_DATA_GEN;
diff_cal_val <= "011"*(cam_ydata_2d) - ("000"&bram_data_1d) - ("000"&bram_data) - ("000"&y_data_1d);
Laplacian_cal_val <= "01000"*(XnYn) - ("00000"&Xnm1Ynm1) - ("00000"&XnYnm1) - ("00000"&Xnp1Ynm1) - ("00000"&Xnm1Yn) - ("00000"&Xnp1Yn) - ("00000"&Xnm1Ynp1) - ("00000"&XnYnp1) - ("00000"&Xnp1Ynp1) ;
-- マトリクスの絶対値
`timescale 1ns / 1ps
module IOB_Delay_test(
input clk,
input reset,
input testin,
output testout
);
(* IOB="TRUE" *)reg in_ff;
// reg in_ff;
reg in2_ff;
always @(posedge clk) begin
if (reset) begin
in_ff <= 1'b0;
in2_ff <= 1'b0;
end else begin
in_ff <= testin;
in2_ff <= in_ff;
end
end
assign testout = in2_ff;
endmodule
IFD_DELAY_VALUE = 0 1.51ns - 0.67ns = 0.84ns
IFD_DELAY_VALUE = 8 6.73ns - 3.81ns = 2.92ns
`timescale 1ns / 1ps
module IOB_Delay_test(
input clk,
input reset,
input testin,
output testout
);
reg in_ff, in2_ff;
wire ibuf_out, clk_bufg;
IBUF_DLY_ADJ #(
.DELAY_OFFSET("OFF"), // Enable Initial Delay Offset, "OFF" or "ON"
.IOSTANDARD("DEFAULT") // Specify the input I/O standard
)IBUF_DLY_ADJ_inst (
.O(ibuf_out), // Buffer output
.I(clk), // Buffer input (connect directly to top-level port)
.S(3'b000) // 3-bit buffer delay select input
);
BUFG BUFG_inst (
.O(clk_bufg),
.I(ibuf_out)
);
always @(posedge clk_bufg) begin
if (reset) begin
in_ff <= 1'b0;
in2_ff <= 1'b0;
end else begin
in_ff <= testin;
in2_ff <= in_ff;
end
end
assign testout = in2_ff;
endmodule
`timescale 1ns / 1ps
module IOB_Delay_test(
input clk,
input reset,
input testin,
output testout
);
reg in_ff, in2_ff;
always @(posedge clk) begin
if (reset) begin
in_ff <= 1'b0;
in2_ff <= 1'b0;
end else begin
in_ff <= testin;
in2_ff <= in_ff;
end
end
assign testout = in2_ff;
endmodule
NET "clk" TNM_NET = clk;
TIMESPEC TS_clk = PERIOD "clk" 8 ns HIGH 50%;
NET "testin" OFFSET = IN 5 ns BEFORE "clk" RISING;
NET "testout" OFFSET = OUT 7 ns AFTER "clk";
`timescale 1ns / 1ps
module IOB_Delay_test(
input clk,
input reset,
input testin,
output testout
);
reg in_ff, in2_ff;
wire ibuf_out;
IBUF_DLY_ADJ #(
.DELAY_OFFSET("OFF"), // Enable Initial Delay Offset, "OFF" or "ON"
.IOSTANDARD("DEFAULT") // Specify the input I/O standard
)IBUF_DLY_ADJ_inst (
.O(ibuf_out), // Buffer output
.I(clk), // Buffer input (connect directly to top-level port)
.S(3'b000) // 3-bit buffer delay select input
);
always @(posedge ibuf_out) begin
if (reset) begin
in_ff <= 1'b0;
in2_ff <= 1'b0;
end else begin
in_ff <= testin;
in2_ff <= in_ff;
end
end
assign testout = in2_ff;
endmodule
日 | 月 | 火 | 水 | 木 | 金 | 土 |
---|---|---|---|---|---|---|
- | - | - | - | - | 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |