; Sample memory initialization file for Single Port Block Memory,
; v3.0 or later.
;
; This .COE file specifies initialization values for a block
; memory of depth=16, and width=8. In this case, values are
; specified in hexadecimal format.
memory_initialization_radix=16;
memory_initialization_vector=
ff,
ab,
f0,
11,
11,
00,
01,
aa,
bb,
cc,
dd,
ef,
ee,
ff,
00,
ff;
assign cam_rgb_data = {{8{1'b0}}, cam_red, cam_green, cam_blue};
// MIGとの接続用非同期FIFO
cam2mig_fifo cam2mig_afifo_inst (
.wr_clk(clk_cam), // input wr_clk
.wr_rst(reset_cam | ~frame_valid_1d), // input wr_rst
.rd_clk(clk_ddr2), // input rd_clk
.rd_rst(reset_ddr2 | ~frame_v_1d_ddr2_2), // input rd_rst
.din(cam_rgb_data), // input [31 : 0] din
.wr_en(cam_data_ena & capt_ena), // input wr_en
.rd_en(data_enable), // input rd_en
.dout(data_out), // output [127 : 0] dout
.full(cmfifo_full), // output full
.almost_full(cmfifo_almost_full), // output almost_full
.overflow(cmfifo_overflow), // output overflow
.empty(cmfifo_empty), // output empty
.almost_empty(cmfifo_almost_empty), // output almost_empty
.underflow(cmfifo_underflow), // output underflow
.rd_data_count(cmfifo_rd_data_count) // output [3 : 0] rd_data_count
);
-- Write Data Path
wr_fifo_din <= wr_address & wr_data;
wr_fifo_rd_en_node <= wr_fifo_rd_en;
wr_fifo_inst : write_fifo port map(
clk => clk,
srst => reset,
din => wr_fifo_din,
wr_en => wr_enable,
rd_en => wr_fifo_rd_en,
dout => wr_fifo_dout,
full => open,
almost_full => wr_fifo_full,
empty => wr_fifo_empty,
almost_empty => wr_fifo_almost_empty,
data_count => wr_fifo_count
);
-- Read Data Path
rd_fifo_rd_en_node <= rd_fifo_rd_en;
rd_fifo_inst : read_fifo port map(
clk => clk,
srst => reset,
din => rd_address,
wr_en => rd_enable,
rd_en => rd_fifo_rd_en,
dout => rd_fifo_dout,
full => open,
almost_full => rd_fifo_full,
empty => rd_fifo_empty,
almost_empty => rd_fifo_almost_empty,
data_count => rd_fifo_count
);
-- SRAMのRead, Write 用ステートマシン(Read優先)
process(clk) begin
if clk'event and clk='1' then
if reset='1' then
cs_SRAM_RW <= SRAM_RW_STATE'(idle);
wr_fifo_rd_en <= '0';
rd_fifo_rd_en <= '0';
else
case cs_SRAM_RW is
when SRAM_RW_STATE'(idle) =>
if rd_fifo_empty='0' then
cs_SRAM_RW <= READ_STATE;
rd_fifo_rd_en <= '1';
elsif wr_fifo_empty='0' then
cs_SRAM_RW <= WRITE_STATE1;
end if;
when READ_STATE =>
if rd_fifo_almost_empty='0' then -- まだRead用FIFOに残っている
cs_SRAM_RW <= READ_STATE;
else
cs_SRAM_RW <= SRAM_RW_STATE'(idle);
rd_fifo_rd_en <= '0';
end if;
when WRITE_STATE1 =>
cs_SRAM_RW <= WRITE_STATE2;
wr_fifo_rd_en <= '1';
when WRITE_STATE2 =>
wr_fifo_rd_en <= '0';
if rd_fifo_empty='0' then -- Read優先, ReadとWriteの間は1クロック間を空ける。
cs_SRAM_RW <= SRAM_RW_STATE'(idle);
elsif wr_fifo_almost_empty='0' then -- まだWrite用FIFOに残っている
cs_SRAM_RW <= WRITE_STATE1;
else
cs_SRAM_RW <= SRAM_RW_STATE'(idle);
end if;
end case;
end if;
end if;
end process;
-- Write Data Path
wr_fifo_din <= wr_address & wr_data;
wr_fifo_rd_en_node <= wr_fifo_rd_en;
wr_fifo_inst : write_fifo port map(
clk => clk,
srst => reset,
din => wr_fifo_din,
wr_en => wr_enable,
rd_en => wr_fifo_rd_en_node,
dout => wr_fifo_dout,
full => open,
almost_full => wr_fifo_full,
empty => wr_fifo_empty,
almost_empty => wr_fifo_almost_empty,
data_count => wr_fifo_count
);
-- Read Data Path
rd_fifo_rd_en_node <= rd_fifo_rd_en;
rd_fifo_inst : read_fifo port map(
clk => clk,
srst => reset,
din => rd_address,
wr_en => rd_enable,
rd_en => rd_fifo_rd_en_node,
dout => rd_fifo_dout,
full => open,
almost_full => rd_fifo_full,
empty => rd_fifo_empty,
almost_empty => rd_fifo_almost_empty,
data_count => rd_fifo_count
);
-- Divider Test(Divider_test.vhd)
library IEEE;
use IEEE.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity Divider_test is
port (
clk: IN std_logic;
ce: IN std_logic;
rfd: OUT std_logic;
dividend: IN std_logic_VECTOR(22 downto 0);
quotient: OUT std_logic_VECTOR(22 downto 0);
fractional: OUT std_logic_VECTOR(14 downto 0)
);
end Divider_test;
architecture RTL of Divider_test is
component divider_per
port (
clk: IN std_logic;
ce: IN std_logic;
rfd: OUT std_logic;
dividend: IN std_logic_VECTOR(22 downto 0);
divisor: IN std_logic_VECTOR(14 downto 0);
quotient: OUT std_logic_VECTOR(22 downto 0);
fractional: OUT std_logic_VECTOR(14 downto 0));
end component;
signal divisor: std_logic_VECTOR(14 downto 0);
begin
divider_per_inst : divider_per port map (
clk => clk,
ce => ce,
rfd => rfd,
dividend => dividend,
divisor => divisor,
quotient => quotient,
fractional => fractional
);
divisor <= "110000000000000";
end RTL;
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY Divider_test_tb IS
END Divider_test_tb;
ARCHITECTURE behavior OF Divider_test_tb IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT Divider_test
PORT(
clk : IN std_logic;
ce : IN std_logic;
rfd : OUT std_logic;
dividend : IN std_logic_vector(22 downto 0);
quotient : OUT std_logic_vector(22 downto 0);
fractional : OUT std_logic_vector(14 downto 0)
);
END COMPONENT;
--Inputs
signal clk : std_logic := '0';
signal ce : std_logic := '0';
signal dividend : std_logic_vector(22 downto 0) := (others => '0');
--Outputs
signal rfd : std_logic;
signal quotient : std_logic_vector(22 downto 0);
signal fractional : std_logic_vector(14 downto 0);
-- Clock period definitions
constant clk_period : time := 40 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: Divider_test PORT MAP (
clk => clk,
ce => ce,
rfd => rfd,
dividend => dividend,
quotient => quotient,
fractional => fractional
);
-- Clock process definitions
clk_process :process
begin
clk <= '0';
wait for clk_period/2;
clk <= '1';
wait for clk_period/2;
end process;
-- Stimulus process
stim_proc: process
begin
ce <= '0';
dividend <= "00000000000000000000000";
wait for clk_period*2;
ce <= '1';
dividend <= "00000000110000000000000";
wait for clk_period*2;
ce <= '1';
dividend <= "00000011100000000000000";
wait for clk_period*10;
wait;
end process;
END;
日 | 月 | 火 | 水 | 木 | 金 | 土 |
---|---|---|---|---|---|---|
- | - | - | - | 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 | - |