I am new to VHDL and having an issue trying to port map to ground.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity msPC4 is
Port ( b : in STD_LOGIC_VECTOR (3 downto 0);
clk : in STD_LOGIC;
reset : in STD_LOGIC;
a : out STD_LOGIC_VECTOR (3 downto 0);
co : out STD_LOGIC);
end msPC4;
architecture Structure of msPC4 is
component msdff4
Port ( d : in STD_LOGIC_VECTOR (3 downto 0);
clk : in STD_LOGIC;
q : out STD_LOGIC_VECTOR (3 downto 0));
end component;
component msFA4bit
Port ( a : in STD_LOGIC_VECTOR (3 downto 0);
b : in STD_LOGIC_VECTOR (3 downto 0);
ci : in STD_LOGIC;
s : out STD_LOGIC_VECTOR (3 downto 0);
co : out STD_LOGIC);
end component;
component ms21mux4
Port ( d1 : in STD_LOGIC_VECTOR (3 downto 0);
d0 : in STD_LOGIC_VECTOR (3 downto 0);
s : in STD_LOGIC;
z : out STD_LOGIC_VECTOR (3 downto 0));
end component;
signal w0, w1, w2, w3: STD_LOGIC_VECTOR (3 downto 0);
signal w4 : STD_LOGIC;
w4 <= '0';
w3 <= '0000';
begin
gmsPC4g1: msdff4 port map (w1,clk,w2);
gmsPC4g2: msFA4bit port map (w2,b,w4,w0,co);
gmsPC4g3: ms21mux4 port map (w0,w3,clk,w1);
a <= w2;
end Structure;
So if you'll notice, I have 3 components, a couple signals to connect everything and such.
What I REALLY want, is for signals w3 and w4 to be SET to ground (tied to logic low, as it were), but for whatever reason, I cannot for the life of me figure out how I am supposed to do this.
FWIW I'm an EE so I'm more accustomed to seeing this from the hardware end. Also, this project specifically has to be done with port maps and not the behavioral stuff. Sorry about that.
Edit: The error is being thrown at lines where w3 is set to '0', w4 is set to '0000'. Double quotes do not fix this error. Moving it inside begin does not fix the error. Inside the begin set I get an "UNEXPECTED TICK" and outside the begin set I get a "UNEXPECTED IDENTIFIER". It just really doesn't want to let me decide the value of something.
Changing your code:
-- w4 <= '0';
-- w3 <= '0000';
begin
w4 <= '0';
w3 <= "0000";
Allows successful analysis, noting there are no other drivers from w4 or w3.
Alternatively you can provide default values in the declarations:
signal w0, w1, w2: STD_LOGIC_VECTOR (3 downto 0);
signal w3: STD_LOGIC_VECTOR (3 downto 0) := "0000";
signal w4 : STD_LOGIC := '0';
-- w4 <= '0';
-- w3 <= '0000';
This also analyzes.
The default value represents the value of a signal prior to a signal assignment.
You can also supply values directly:
gmsPC4g1: msdff4 port map (w1,clk,w2);
gmsPC4g2: msFA4bit port map (w2,b,'0',w0,co); -- w4
gmsPC4g3: ms21mux4 port map (w0,"0000",clk,w1); -- w3
This analyzes.
Or provide constant values:
signal w0, w1, w2: STD_LOGIC_VECTOR (3 downto 0);
constant w3: std_logic_vector(3 downto 0) := "0000";
constant w4 : STD_LOGIC := '0';
-- w4 <= '0';
-- w3 <= '0000';
begin
gmsPC4g1: msdff4 port map (w1,clk,w2);
gmsPC4g2: msFA4bit port map (w2,b,w4,w0,co);
gmsPC4g3: ms21mux4 port map (w0,w3,clk,w1);
which also analyzes.
Notice the double quotes used in string literal values ("0000"). Single quotation marks (ticks) are used for character literals with graphical representation.
You are not using either package std_logic_arith nor std_logic_unisigned. Their use clauses are superfluous.
Related
Please help me,I am trying to develop a 8 by 32 bit read/write memory using structural modelling. I've developed the following modules
0) output_array_types (package)
1) register_32_bit
2) dmux_1by8
3) mux_8by1 (32 bit wide)
4) xor_1bit (not relevant to my problem)
5) data_memory_2pow3_32 (this is where my problem occurs)
All modules have been tested independently and they all work except the main file (5th one), due to some lack of understanding about vhdl syntax the mux_8by1 used in the main file gives unknown output for a 2d signal input (which contains all 8 register values of the memory) from which the mux is supposed to pick the row based on the address asserted at the selection line to get that row value as the output.
I've attached the code and output below. Please help where in the main file i'm going wrong, I'm particularly doubtful about the "unit11" in the main file.
thanks in advance
output_array_types.vhd
library ieee;
use ieee.std_logic_1164.all;
package output_array_types is
type op_arr is array(0 to 7) of STD_LOGIC;
type op_arr_32bit is array(0 to 7) of STD_LOGIC_VECTOR(31 downto 0);
end package output_array_types;
register_32_bit.vhd
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity register_32_bit is
port(
rst: in STD_LOGIC;
enable: in STD_LOGIC;
load: in STD_LOGIC;
data_in: in STD_LOGIC_VECTOR(31 downto 0);
data_out: out STD_LOGIC_VECTOR(31 downto 0)
);
end register_32_bit;
architecture behavioral of register_32_bit is
begin
process(rst,enable,load)
begin
if (rst = '0') then
data_out<=STD_LOGIC_VECTOR(to_unsigned(0, 32));
elsif (enable = '1') then
if (load = '1') then
data_out<=data_in;
end if;
end if;
end process;
end behavioral;
dmux_1by8.vhd
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.output_array_types.all;
entity dmux_1by8 is
port(data_in: in STD_LOGIC;
sel: in STD_LOGIC_VECTOR(2 downto 0);
data_out: out op_arr
);
end dmux_1by8;
architecture behavioral of dmux_1by8 is
begin
process(sel)
begin
data_out<= (others =>'0');
data_out(to_integer(unsigned(sel)))<= data_in;
end process;
end behavioral;
mux_8by1.vhd
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.output_array_types.all;
entity mux_8by1 is
port(data_in: in op_arr_32bit;
sel: in STD_LOGIC_VECTOR(2 downto 0);
data_out: out STD_LOGIC_VECTOR(31 downto 0)
);
end mux_8by1;
architecture behavioral of mux_8by1 is
begin
process(sel)
begin
data_out<= data_in(to_integer(unsigned(sel)));
end process;
end behavioral;
xor_1bit.vhd
library ieee;
use ieee.std_logic_1164.all;
entity xor_1bit is
port(op: in STD_LOGIC_VECTOR(1 downto 0);
result: out STD_LOGIC
);
end xor_1bit;
architecture behavioral of xor_1bit is
begin
process(op)
begin
if(op = "00") then
result<= '0';
elsif(op = "01") then
result<= '1';
elsif(op = "10") then
result<= '1';
elsif(op = "11") then
result<= '0';
end if;
end process;
end behavioral;
data_memory_2pow3_32.vhd
library ieee,work;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.output_array_types.all;
entity data_memory_2pow3_32 is
port(mem_write: in STD_LOGIC := '1';
mem_read: in STD_LOGIC := '0';
address: in STD_LOGIC_VECTOR(31 downto 0) := (others => '0');
write_data: in STD_LOGIC_VECTOR(31 downto 0) := (others => '0');
read_data: out STD_LOGIC_VECTOR(31 downto 0);
mem_rst: in STD_LOGIC := '1'
);
end data_memory_2pow3_32;
architecture structural of data_memory_2pow3_32 is
component register_32_bit is
port(
rst: in STD_LOGIC;
enable: in STD_LOGIC;
load: in STD_LOGIC;
data_in: in STD_LOGIC_VECTOR(31 downto 0);
data_out: out STD_LOGIC_VECTOR(31 downto 0)
);
end component;
component dmux_1by8 is
port(data_in: in STD_LOGIC;
sel: in STD_LOGIC_VECTOR(2 downto 0);
data_out: out op_arr
);
end component;
component mux_8by1 is
port(data_in: in op_arr_32bit;
sel: in STD_LOGIC_VECTOR(2 downto 0);
data_out: out STD_LOGIC_VECTOR(31 downto 0)
);
end component;
component xor_1bit is
port(op: in STD_LOGIC_VECTOR(1 downto 0);
result: out STD_LOGIC
);
end component;
signal dmux_1by8_out : op_arr;
signal mux_8by1_in : op_arr_32bit;
signal read_xor_write: STD_LOGIC;
signal mux_8by1_out: STD_LOGIC_VECTOR(31 downto 0);
alias address_0to2 is address(2 downto 0);
begin
unit0: xor_1bit port map(op(0) => mem_write, op(1) => mem_read, result => read_xor_write);
unit1: dmux_1by8 port map(data_in => mem_write, sel => address_0to2, data_out => dmux_1by8_out);
unit: for i in 0 to 7 generate
unit2to9: register_32_bit port map(rst => mem_rst ,enable => read_xor_write ,load => dmux_1by8_out(i),data_in => write_data,data_out => mux_8by1_in(i));
end generate;
--Till here everything works, after this when the mux_8by1_in (2d signal
--array) is mapped to the mux_8by1 below, the output read_data
--turns out to be unknown whereas there's no problem in mux_8by1 module
--when tested independently. Hence there must be some erroneous mapping
--being performed here.
unit11: mux_8by1 port map(data_in => mux_8by1_in, sel => address_0to2, data_out => read_data);
end structural;
[1 [output i got in modelsim]]: https://i.stack.imgur.com/McvV4.png
[2 [diagram of memory architecture I'm using]]: https://i.stack.imgur.com/hJb7n.jpg
I'm trying to generate a memory for on FPGA, but I'm having some questions related to how I should approach the stored data.
When I'd like to update data, do I need to use a new_q1 signal or not? (like I tried to apply in my code (version 1 and 3)).
I was told that I need a new q1 signal (I don't exactly know why) and that I always should have an 'else' statement to prevent 'don't cares'.
Version 1 is the version with a new q1 signal, however, there is no initial value for new_q1. Version 2 is the version I actually started with but I received a comment that this is not the correct approach for some reason I don't quite understand.
Version 3 is the version that is fully working like it was explained to me, however, in my opinion, it is way too much and the synthesizer is rejecting my new_q1 constructions.
What version should I go with and can somembody clarify that what I'm being told is correct or not and why?
Version 1:
entity memory is
port(
clk : in std_logic;
reset : in std_logic;
selector : in std_logic_vector(5 downto 0);
write : in std_logic;
value : out std_logic
);
end memory;
architecture behaviour of memory is
signal q1, new_q1 : std_logic_vector(63 downto 0);
begin
process(clk, reset) is
begin
if( clk'event AND clk = '1') then
if(reset = '1') then
q1 <= (others => '0');
else
q1 <= new_q1;
end if;
end if;
end process;
process(q1) is
if(write = '1') then
new_q1(to_integer(unsigned(selector)) <= '1';
else
new_q1 <= q1;
end if;
end process;
value <= q1(to_integer(unsigned(selector));
end behaviour;
Version 2:
entity memory is
port(
clk : in std_logic;
reset : in std_logic;
selector : in std_logic_vector(5 downto 0);
write : in std_logic;
value : out std_logic
);
end memory;
architecture behaviour of memory is
signal q1 : std_logic_vector(63 downto 0);
begin
process(clk, reset) is
begin
if( clk'event AND clk = '1') then
if(reset = '1') then
q1 <= (others => '0');
else
if(write = '1') then
q1(to_integer(unsigned(selector)) <= '1';
else
....
end if;
end if;
end if;
end process;
value <= q1(to_integer(unsigned(selector));
end behaviour;
Version 3:
entity memory is
port(
clk : in std_logic;
reset : in std_logic;
selector : in std_logic_vector(5 downto 0);
write : in std_logic;
value : out std_logic
);
end memory;
architecture behaviour of memory is
signal q1 : std_logic_vector(63 downto 0);
begin
process(clk, reset) is
begin
if( clk'event AND clk = '1') then
if(reset = '1') then
q1 <= (others => '0');
else
q1 <= new_q1;
end if;
end if;
end process;
process(q1, write) is
if(write = '1') then
if(unsigned(selector) < 63) then
new_q1 <= q1(63 downto to_integer(unsigned(selector))) & '1' & q1(to_integer(unsigned(selector)) downto 0);
else
new_q1 <= '1' & q1(to_integer(unsigned(selector)) downto 0);
end if;
else
new_q1 <= q1;
end if;
end process;
value <= q1(to_integer(unsigned(selector));
end behaviour;
Based on some assumptions about operation, as noted in the port list, a design may look like below. Implementation in a FPGA is likely to be made using flip-flops, and not internal memories, due to size and the special function, so the name memory may be misleading through.
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity memory is
port(
clk : in std_logic;
reset : in std_logic; -- Synchronous, assumed to be applied initially
selector : in std_logic_vector(5 downto 0);
write : in std_logic; -- Write set bit only, synchronous
value : out std_logic -- Read value, asynchronous
);
end memory;
architecture behaviour of memory is
signal q1 : std_logic_vector(63 downto 0);
begin
-- Reset and write set, synchronous
process (clk) is
begin
if (clk'event and clk = '1') then -- Rising clock
if (reset = '1') then -- Reset, synchronous
q1 <= (others => '0'); -- Clear all bits
elsif (write = '1') then -- Write to set for selector bit
q1(to_integer(unsigned(selector))) <= '1'; -- Set single bit
end if;
end if;
end process;
-- Read, asynchronous
value <= q1(to_integer(unsigned(selector))); -- Read single bit
end behaviour;
I'm trying to implement a memory controller that can read/write to either a sram, scratch register, or led register (basically a scratch reg that blinks a led). I need to use a bidirectional bus, but it outputs an 'X' wherever a 1 should be. This usually happens when you have two different things driving the same signal, but I don't see where that is happening in my code.
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity mem_control is
port(
clk : in std_logic;
write_en : in std_logic;
read_en : in std_logic;
bus_address : in std_logic_vector(11 downto 0);
bus_data : inout std_logic_vector(31 downto 0);
write_en_sram : out std_logic;
read_en_led : out std_logic;
write_en_led : out std_logic;
write_en_scratch : out std_logic;
bus_in_sram : in std_logic_vector(31 downto 0);
bus_out_sram : out std_logic_vector(31 downto 0);
bus_in_led : in std_logic_vector(31 downto 0);
bus_out_led : out std_logic_vector(31 downto 0);
bus_in_scratch : in std_logic_vector(31 downto 0);
bus_out_scratch : out std_logic_vector(31 downto 0);
addr_out : out std_logic_vector(11 downto 0)
);
end mem_control;
architecture bhv of mem_control is
--buffer signals
signal bus_out : std_logic_vector(31 downto 0) := (others => '0');
--processes begin
begin
mem_write : process(clk) is
begin
if rising_edge(clk) then
if write_en = '1' and read_en ='0' then --writing logic
case To_integer(unsigned(bus_address)) is
when 16#000# to 16#3FF# =>
write_en_sram <= '1';
write_en_led <= '0';
write_en_scratch <= '0';
bus_out_sram <= bus_data;
addr_out <= bus_address;
when 16#400# =>
write_en_sram <= '0';
write_en_led <= '1';
write_en_scratch <= '0';
bus_out_led <= bus_data;
when 16#404# =>
write_en_sram <= '0';
write_en_led <= '0';
write_en_scratch <= '1';
bus_out_scratch <= bus_data;
when others =>
null;
end case;
end if;
end if;
end process mem_write;
mem_read : process(clk) is
begin
if rising_edge(clk) then
if read_en = '1' and write_en = '0' then --reading logic
case To_integer(unsigned(bus_address)) is
when 16#000# to 16#3FF# =>
bus_out <= bus_in_sram;
read_en_led <= '0';
addr_out <= bus_address;
when 16#400# =>
bus_out <= bus_in_led;
read_en_led <= '1';
when 16#404# =>
bus_out <= bus_in_scratch;
read_en_led <= '0';
when others =>
null;
end case;
end if;
end if;
end process mem_read;
--led register and tristate buffers
bus_data <= bus_out when(write_en = '0' and read_en = '1') else (others => 'Z');
end bhv;
I am trying to read and write from DDR3 ram, connected to my FPGA Artix-7. I am using MIG-7, to build my IP in Vivado 2015.1.
The IP needs has two input clocks, reference clock and system clock.
I use internal IP (FPGA internal PLL) to make a 400 Mhz clock and I have connected the clock to them.
The circuit doesn't work and ui_clk_sync_rst is '0', and init_calib_complete never goes high!
How should I assign these clock signals?
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_unsigned.all;
entity Main_Prg is
Port (
-- Inouts
ddr3_dq : inout std_logic_vector(7 downto 0);
ddr3_dqs_p : inout std_logic_vector(0 downto 0);
ddr3_dqs_n : inout std_logic_vector(0 downto 0);
-- Outputs
ddr3_addr : out std_logic_vector(13 downto 0);
ddr3_ba : out std_logic_vector(2 downto 0);
ddr3_ras_n : out std_logic;
ddr3_cas_n : out std_logic;
ddr3_we_n : out std_logic;
ddr3_reset_n : out std_logic;
ddr3_ck_p : out std_logic_vector(0 downto 0);
ddr3_ck_n : out std_logic_vector(0 downto 0);
ddr3_cke : out std_logic_vector(0 downto 0);
ddr3_cs_n : out std_logic_vector(0 downto 0);
ddr3_odt : out std_logic_vector(0 downto 0);
LEDV6 : out STD_LOGIC;
LEDV7 : out STD_LOGIC;
clk25 : in STD_LOGIC);
end Main_Prg;
architecture Behavioral of Main_Prg is
component Clock_IP
port
(
clk_in : in std_logic;
clk_out : out std_logic
);
end component Clock_IP;
component DDR3_RAM
port(
ddr3_dq : inout std_logic_vector(7 downto 0);
ddr3_dqs_p : inout std_logic_vector(0 downto 0);
ddr3_dqs_n : inout std_logic_vector(0 downto 0);
ddr3_addr : out std_logic_vector(13 downto 0);
ddr3_ba : out std_logic_vector(2 downto 0);
ddr3_ras_n : out std_logic;
ddr3_cas_n : out std_logic;
ddr3_we_n : out std_logic;
ddr3_reset_n : out std_logic;
ddr3_ck_p : out std_logic_vector(0 downto 0);
ddr3_ck_n : out std_logic_vector(0 downto 0);
ddr3_cke : out std_logic_vector(0 downto 0);
ddr3_cs_n : out std_logic_vector(0 downto 0);
ddr3_odt : out std_logic_vector(0 downto 0);
app_addr : in std_logic_vector(27 downto 0);
app_cmd : in std_logic_vector(2 downto 0);
app_en : in std_logic;
app_wdf_data : in std_logic_vector(63 downto 0);
app_wdf_end : in std_logic;
app_wdf_wren : in std_logic;
app_rd_data : out std_logic_vector(63 downto 0);
app_rd_data_end : out std_logic;
app_rd_data_valid : out std_logic;
app_rdy : out std_logic;
app_wdf_rdy : out std_logic;
app_sr_req : in std_logic;
app_ref_req : in std_logic;
app_zq_req : in std_logic;
app_sr_active : out std_logic;
app_ref_ack : out std_logic;
app_zq_ack : out std_logic;
ui_clk : out std_logic;
ui_clk_sync_rst : out std_logic;
init_calib_complete : out std_logic;
-- System Clock Ports
sys_clk_i : in std_logic;
-- Reference Clock Ports
clk_ref_i : in std_logic;
sys_rst : in std_logic
);
end component DDR3_RAM;
signal cntr01 : std_logic_vector(50 downto 0) := (others=>'0');
signal cntr02 : std_logic_vector(50 downto 0) := (others=>'0');
signal ck25 : std_logic ;
signal ck400 : std_logic ;
signal app_addr : std_logic_vector(27 downto 0) := (others=>'0') ;
signal app_cmd : std_logic_vector(2 downto 0) := (others=>'0') ;
signal app_en : std_logic := '0';
signal app_wdf_data : std_logic_vector(63 downto 0) := (others=>'0') ;
signal app_wdf_end : std_logic := '0';
signal app_wdf_wren : std_logic := '0';
signal app_rd_data : std_logic_vector(63 downto 0) := (others=>'0') ;
signal app_rd_data_end : std_logic;
signal app_rd_data_valid : std_logic;
signal app_rdy : std_logic;
signal app_wdf_rdy : std_logic;
signal app_sr_active : std_logic;
signal app_ref_ack : std_logic;
signal app_zq_ack : std_logic;
signal clk : std_logic;
signal rst : std_logic;
signal init_calib_complete_s : std_logic;
signal app_rdy_i : std_logic;
signal app_wdf_rdy_i : std_logic;
signal app_rd_data_valid_i : std_logic;
signal init_calib_complete_i : std_logic;
signal app_addr_i : std_logic_vector(27 downto 0) := (others=>'0') ;
begin
ck25 <= clk25 ;
U1: process(clk)
begin
if rising_edge(clk) then
cntr01 <= cntr01 + 1 ;
end if;
end process;
--U2: process(ck400)
--begin
-- if rising_edge(ck400) then
-- if cntr02(28) = '0' then
-- cntr02 <= cntr02 + 1 ;
-- end if;
-- end if;
--end process;
Uclk: Clock_IP port map
( clk_in => ck25,
clk_out=> ck400);
LEDV6 <= init_calib_complete_i ; -- cntr01(25);
LEDV7 <= cntr01(25);
u_DDR3_RAM : DDR3_RAM
port map (
-- Memory interface ports
ddr3_addr => ddr3_addr,
ddr3_ba => ddr3_ba,
ddr3_cas_n => ddr3_cas_n,
ddr3_ck_n => ddr3_ck_n,
ddr3_ck_p => ddr3_ck_p,
ddr3_cke => ddr3_cke,
ddr3_ras_n => ddr3_ras_n,
ddr3_reset_n => ddr3_reset_n,
ddr3_we_n => ddr3_we_n,
ddr3_dq => ddr3_dq,
ddr3_dqs_n => ddr3_dqs_n,
ddr3_dqs_p => ddr3_dqs_p,
init_calib_complete => init_calib_complete_s,
ddr3_cs_n => ddr3_cs_n,
ddr3_odt => ddr3_odt,
-- Application interface ports
app_addr => app_addr,
app_cmd => app_cmd,
app_en => app_en,
app_wdf_data => app_wdf_data,
app_wdf_end => app_wdf_end,
app_wdf_wren => app_wdf_wren,
app_rd_data => app_rd_data,
app_rd_data_end => app_rd_data_end,
app_rd_data_valid => app_rd_data_valid,
app_rdy => app_rdy,
app_wdf_rdy => app_wdf_rdy,
app_sr_req => '0',
app_ref_req => '0',
app_zq_req => '0',
app_sr_active => app_sr_active,
app_ref_ack => app_ref_ack,
app_zq_ack => app_zq_ack,
ui_clk => clk,
ui_clk_sync_rst => rst,
-- System Clock Ports
sys_clk_i => ck400,
-- Reference Clock Ports
clk_ref_i => ck400,
sys_rst => cntr02(28)
);
-- End of User Design top instance
end Behavioral;
In case you have an ocsillator that is not not suitable for your MIG, you can create a clock with two outputs (from Clocking Wizard) and then connect the 1st clock to MIG's system clock and the 2nd clock to reference clock.
In MIG's settings reference and system clocks must be set to "No Buffer" type.
Reference clock must be 200 MHz. If system clock is 200 MHz, then you can select "Use system clock".
The sys_clk can't be generated under the FPGA. You have to provide it from an external oscillator.
Follow the example of AC701 Artix7 kit, it use a differential clock at 200Mhz.
I have aproblem with mapping the clock_div_1hz_aux with aux.
I need to map those two ports (aux with clock_div_1hz_aux) and i don't know how. All the others are mapped, as I described in image
Here is the code I used:
entity controler is
Port ( reset : in STD_LOGIC;
clock : in STD_LOGIC;
....................
);
end controler;
component numarator
Port (
clk_num : in std_logic;
reset_num : in std_logic;
count : out std_logic_vector (3 downto 0)
);
end component;
component div_num
Port (
clock_div: in std_logic;
reset_div : in std_logic;
clock_div_1hz: buffer std_logic;
clock_bla : out std_logic
);
end component;
num1: div_num PORT MAP(
clock_div=>clock,
clock_div_1hz => clk1hz,
reset_div => reset
);
num2: numarator PORT MAP(
clk_num =>clk1hz,
reset_num =>reset,
count=>sensor_count
);
Thank you!
To avoid using buffer in the component (div_num), you can declare the buffer as an output parameter and add an intermediate signal to the architecture of (div_num).
Just work with the intermediate signal in your design and assign it to the output parameter as a concurrent statement. For example (architecture of div_num):
architecture ... of ... is
begin
output_parameter <= intermediate_parameter;
process(...)
begin
-- use the intermediate_paramter instead of output_parameter
end process;
end architecture;
After the above changes : It seems that you have 3 components (div_num , numerator , controler).
If you want to connect the output parameter (clock_div_1hz_aux) to (aux), just declare an interface signal (clk1hz_aux) and add it to the components (div_num and controler).
For example :
signal clk1hz_aux : std_logic;
component div_num
Port(
clock_div : in std_logic;
reset_div : in std_logic;
clock_div_1hz : out std_logic;
clock_div_1hz_aux : out std_logic
);
end component;
component numarator
Port(
clk_num : in std_logic;
reset_num : in std_logic;
count : out std_logic_vector (3 downto 0)
);
end component;
component controler
Port(
clock : in std_logic;
count : in std_logic_vector (3 downto 0)
aux : in std_logic;
reset : in std_logic;
-- declare output parameters of controler block
);
end component;
num1 : div_num PORT MAP(clock,reset,clk1hz,clk1hz_aux);
num2 : numarator PORT MAP(clk1hz,reset,sensor_count);
cntr : controler PORT MAP(clock,sensor_count,clk1hz_aux,reset,....);
Amir, wouldn't be ok to use this type of mapping?
entity mapare is
Port (
reset : in STD_LOGIC;
clock : in STD_LOGIC;
aux : in std_logic;
...........
);
end mapare;
architecture Behavioral of mapare is
component numarator is
Port (
clk_num : in std_logic;
reset_num : in std_logic;
count : out std_logic_vector (3 downto 0)
);
end component;
component div_num is
Port (
clock_div: in std_logic;
reset_div : in std_logic;
clock_div_1hz: out std_logic;
clock_div_1hz_aux: out std_logic
);
end component;
component controler is
Port (
clock: in std_logic;
reset: in std_logic;
aux : in std_logic;
...........
);
end component;
signal sensor_count : STD_LOGIC_VECTOR (3 downto 0);
signal clk1hz: std_logic := '0';
signal aux1 : std_logic ;
begin
num1: div_num PORT MAP(
clock_div=>clock,
clock_div_1hz => clk1hz,
reset_div => reset,
clock_div_1hz_aux => aux1
);
num2: numarator PORT MAP(
clk_num =>clk1hz,
reset_num =>reset,
count=>sensor_count
);
num3: controler PORT MAP (
reset => reset,
clock => clock,
...........
aux=> aux1
);
end Behavioral;