Me again!
I wrote something SUPER simple in order to demonstrate how entities come together. However, I'm having trouble figuring out why the output of the combined entities never assumes any value (other than U). Here's the code (its super simple, I promise!)
library ieee;
use ieee.std_logic_1164.all;
entity OR_LOGIC is
port(
in_a : in std_logic;
in_b : in std_logic;
out_c : out std_logic
);
end entity;
architecture OR_LOGIC_ARCH of OR_LOGIC is
begin
out_c <= in_a or in_b;
end OR_LOGIC_ARCH;
library ieee;
use ieee.std_logic_1164.all;
entity AND_LOGIC is
port(
in_a : in std_logic;
in_b : in std_logic;
out_c : out std_logic
);
end entity;
architecture AND_LOGIC_ARCH of AND_LOGIC is
begin
out_c <= in_a and in_b;
end AND_LOGIC_ARCH;
library ieee;
use ieee.std_logic_1164.all;
entity COMBO is
port(
in_a : in std_logic;
in_b : in std_logic;
in_c : in std_logic;
out_d : out std_logic
);
end entity;
architecture COMBO_ARCH of COMBO is
signal wire1 : std_logic;
signal wire2 : std_logic;
component OR_LOGIC
port(
in_a : in std_logic;
in_b : in std_logic;
out_c : out std_logic
);
end component;
component AND_LOGIC
port(
in_a : in std_logic;
in_b : in std_logic;
out_c : out std_logic
);
end component;
begin
or1 : OR_LOGIC port map (in_a, in_b, wire1);
and1 : AND_LOGIC port map(in_c, wire1, wire2);
end COMBO_ARCH;
and then:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity TEST_ENTITY is
end entity TEST_ENTITY;
architecture TEST_ENTITY_ARCH of TEST_ENTITY is
component ANDandOR
port(
in_a : in std_logic;
in_b : in std_logic;
in_c : in std_logic;
out_d : out std_logic
);
end component;
signal in_a, in_b, in_c, out_d : std_logic;
begin
combination : ANDandOR port map (in_a, in_b, in_c, out_d);
process
begin
in_a <= '0';
in_b <= '0';
in_c <= '0';
wait for 5ns;
in_a <= '1';
in_b <= '0';
in_c <= '1';
wait for 5ns;
in_a <= '0';
in_b <= '1';
in_c <= '0';
wait for 5ns;
end process;
end architecture TEST_ENTITY_ARCH;
First, you have assigned the output of your AND gate to wire2, but wire2 is floating. You should either assign it to your ouput like this
out_d <= wire2;
OR remove wire2 from your internal signals and assign your output directly.
and1 : AND_LOGIC port map(in_c, wire1, out_d);
Second, your test bench needs to have the proper name of the component COMBO in order to map it properly. Quartus can generate a test bench template for you, that you can then add test code to it.
Processing --> Start --> Start Test Bench Template Writer
It comes very handy :)
Related
I made a state automate for this diagram:
Diagram with states
(not a from diagram represents a='0' and b with horizontal bar above represents b='0')
And I write structural and comportamental automate, structural with mux4:1 and 3 d flip-flops.
I made a testbench file in which i give simulate values for a and b variables like this:
a<='0' after 2ns,'1' after 5ns,'0' after 8ns,'1' after 11ns,'1' after 16ns;--se va incepe dupa rn, dupa 2 ns
b<='1' after 11ns,'0' after 13ns;
, for clock:
process
begin
ck<='0';
wait for 0.5ns;
ck<='1';
wait for 0.5ns;
end process;
and for an asynchronous reset:
rn<='1' after 0ns,'0' after 0.2ns,'1' after 2ns;
with this rn i will be starting showing the states and giving a logic value for a and b only after 2 ns
Test result is wrong
The test shows the wrong states for structural description only for first scrolling, after that is equal to the comportamental description. How I can make to show all the curls for this diagram, not only this which is the complete?
I add there the vhdl code for structural and comportamental description, mux4, d flip-flop and test:
Structural:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity automat is
Port ( ck : in STD_LOGIC;
rn : in STD_LOGIC;
a : in STD_LOGIC;
b : in STD_LOGIC;
q : out STD_LOGIC_VECTOR (2 downto 0));
end automat;
architecture structural of automat is
component mux4 is
Port ( a0 : in STD_LOGIC;
a1 : in STD_LOGIC;
i0 : in STD_LOGIC;
i1 : in STD_LOGIC;
i2 : in STD_LOGIC;
i3: in STD_LOGIC;
Y : out STD_LOGIC);
end component;
component dff is
Port ( d : in STD_LOGIC;
ck : in STD_LOGIC;
rn: in STD_LOGIC;
q : out STD_LOGIC;
qn : out STD_LOGIC);
end component;
signal q2,q1,q0,d2,d1,d0:std_logic;
signal an,bn,q0n:std_logic;
signal net1,net2:std_logic;
begin
q0n<=not q0;
q<=q2& q1& q0;
an<=not a;
bn<=not b;
--cele 5 muxuri necesare descrierii structurale
mux412:mux4 port map(i0=>'1',i1=>'0',i2=>'0',i3=>'0',a1=>q0,a0=>b,y=>net1);
mux41:mux4 port map(i0=>'0',i1=>a,i2=>'1',i3=>net1,a1=>q2,a0=>q1,y=>d2);
mux42:mux4 port map(i0=>'1',i1=>an,i2=>q0,i3=>q0n,a1=>q2,a0=>q1,y=>d1);
mux432: mux4 port map(i0=>'0',i1=>'1',i2=>'0',i3=>'0',a1=>q0,a0=>a,y=>net2);
mux43:mux4 port map(i0=>'1',i1=>an,i2=>net2,i3=>q0n,a1=>q2,a0=>q1,y=>d0);
--cele 3 bistabile d necesare
dff2:dff port map(d=>d2, ck=>ck, rn=>rn, q=>q2);
dff1:dff port map(d=>d1, ck=>ck, rn=>rn, q=>q1);
dff0:dff port map(d=>d0, ck=>ck, rn=>rn, q=>q0);
end architecture;
Mux4:1 :
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--descriere multiplexor 4:1
entity mux4 is
Port ( a0 : in STD_LOGIC;
a1 : in STD_LOGIC;
i0 : in STD_LOGIC;
i1 : in STD_LOGIC;
i2 : in STD_LOGIC;
i3: in STD_LOGIC;
Y : out STD_LOGIC);
end mux4;
architecture Behavioral of mux4 is
signal A : STD_LOGIC_VECTOR(1 downto 0);
begin
--mux4: process (a1,a0,i0,i1,i2,i3)
--begin
A<=a1 & a0;
Y<=i0 when A="00"
else i1 when A="01"
else i2 when A="10"
else i3;
end Behavioral;
D Flip-Flop:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--descriere bistabil d
entity dff is
Port ( d : in STD_LOGIC;
ck : in STD_LOGIC;
rn: in STD_LOGIC;
q : out STD_LOGIC;
qn : out STD_LOGIC);
end dff;
architecture Behavioral of dff is
begin
flip_flop: process(ck,rn)
begin
if rn='0' then
q <= '0';
else
if rising_edge(ck) then
q <= d;
qn <= not d;
end if;
end if;
end process;
end Behavioral;
Comportamental:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity combinat is
Port ( ck : in STD_LOGIC;
rn : in STD_LOGIC;
a : in STD_LOGIC;
b : in STD_LOGIC;
q : out STD_LOGIC_VECTOR (2 downto 0));
end combinat;
architecture Behavioral of combinat is
signal cur_poz,next_poz:std_logic_vector(2 downto 0);
begin
q<=cur_poz;
process(ck,rn)
begin
if rn='0' then
cur_poz<="000";
elsif rising_edge(ck) then
cur_poz<=next_poz;
end if;
end process;
process(cur_poz,a,b)
begin
case cur_poz is
when "000"=>next_poz<="011";
when "011"=>if a='1' then
next_poz<="100";
else
next_poz<="011";
end if;
when "100"=>if a='1' then
next_poz<="101";
else
next_poz<="100";
end if;
when "101"=>next_poz<="110";
when "110"=>if b='1' then
next_poz<="011";
else
next_poz<="111";
end if;
when "111"=>next_poz<="000";
when others=>next_poz<="000";
end case;
end process;
end Behavioral;
Testbench:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity test is
-- Port ( );
end test;
architecture Behavioral of test is
component automat is
Port ( ck : in STD_LOGIC;
rn : in STD_LOGIC;
a : in STD_LOGIC;
b : in STD_LOGIC;
q : out STD_LOGIC_VECTOR (2 downto 0));
end component;
component combinat is
Port ( ck : in STD_LOGIC;
rn : in STD_LOGIC;
a : in STD_LOGIC;
b : in STD_LOGIC;
q : out STD_LOGIC_VECTOR (2 downto 0));
end component;
signal ck,rn,a,b:std_logic;
signal qsec,qcomb:std_logic_vector(2 downto 0);
begin
Testare1: automat port map(ck=>ck,--pentru test descriere structurala
rn=>rn,
a=>a,
b=>b,
q=>qsec);
Testare2:combinat port map(ck=>ck,--pentru test descriere comportamentala
rn=>rn,
a=>a,
b=>b,
q=>qcomb);
rn<='1' after 0ns,'0' after 0.2ns,'1' after 2ns;
process
begin
ck<='0';
wait for 0.5ns;
ck<='1';
wait for 0.5ns;
end process;
a<='0' after 2ns,'1' after 5ns,'0' after 8ns,'1' after 11ns,'1' after 16ns;--se va incepe dupa rn, dupa 2 ns
--evaluarea timpilori si valorilor parametrilor conform buclelor din diagrama gasite
b<='1' after 11ns,'0' after 13ns;
--a<='0' after 2ns,'1' after 4ns,'0' after 6ns,'1' after 8ns,'0' after 16ns;
--b<='1' after 8ns,'0' after 10ns;
verificare:process(qsec)--verificare daca corespund rezultatele celor 2 structuri
begin
if qsec/=qcomb then
report "Rezultat al descrierii structurale diferit fata de cea comportamentale";
end if;
end process;
end Behavioral;
I am trying to write code for a device that can shift right, shift left, circle right and circle left. as you can see in this picture.
The Device
so the i wrote code for the 4x1 MUX and DFlipFlop Modules and used them in my main module with port map. and so when i make a testbench, my Outputs are 'U'.
you can see my code down below:
4x1 Multiplexer:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity MUX4x1 is
Port ( in1 : in std_logic; -- mux input1
in2 : in std_logic; -- mux input2
in3 : in std_logic; -- mux input3
in4 : in std_logic; -- mux input4
sel : in std_logic_vector(1 downto 0); -- selection line
dataout : out std_logic); -- output data
end MUX4x1;
architecture Behavioral of MUX4x1 is
begin
-- This process for mux logic
process (sel, in1, in2, in3, in4)
begin
case SEL is
when "00" => dataout <= in1;
when "01" => dataout <= in2;
when "10" => dataout <= in3;
when "11" => dataout <= in4;
when others => dataout <= '0';
end case;
end process;
end Behavioral;
D FlipFlop:
entity Dflipflop is
port
(
clk : in std_logic;
rst : in std_logic;
pre : in std_logic;
ce : in std_logic;
d : in std_logic;
q : out std_logic
);
end Dflipflop;
architecture Behavioral of Dflipflop is
begin
process (clk) is
begin
if rising_edge(clk) then
if (rst='1') then
q <= '0';
elsif (pre='1') then
q <= '1';
elsif (ce='1') then
if (d ='1') then
q <= '1';
elsif (d ='0') then
q<= '0';
end if;
end if;
end if;
end process;
end Behavioral;
Main Module
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity Main is
port(
--input: in std_logic_vector(3 downto 0);
s: in std_logic_vector(1 downto 0);
clk: in std_logic;
output0: out std_logic;
output1: out std_logic;
output2: out std_logic;
output3: out std_logic
);
end Main;
architecture Behavioral of Main is
component MUX4x1 is
Port (
in1 : in std_logic; -- mux input1
in2 : in std_logic; -- mux input2
in3 : in std_logic; -- mux input3
in4 : in std_logic; -- mux input4
sel : in std_logic_vector(1 downto 0); -- selection line
dataout : out std_logic); -- output data
end component;
component Dflipflop is
port
(
clk : in std_logic;
rst : in std_logic;
pre : in std_logic;
ce : in std_logic;
d : in std_logic;
q : out std_logic
);
end component;
signal temp: std_logic_vector(3 downto 0);
signal A:std_logic_vector(3 downto 0) := "0010";
begin
MUX1: MUX4x1 port map (A(1),'0',A(1),A(3),s,temp(0));
MUX2: MUX4x1 port map (A(2),A(0),A(3),A(1),s,temp(1));
MUX3: MUX4x1 port map (A(3),A(1),A(3),A(1),s,temp(2));
MUX4: MUX4x1 port map (A(0),A(2),A(0),A(2),s,temp(3));
FF1: Dflipflop port map(clk,'0','0','1',temp(0),A(0));
FF2: Dflipflop port map(clk,'0','0','1',temp(1),A(1));
FF3: Dflipflop port map(clk,'0','0','1',temp(2),A(2));
FF4: Dflipflop port map(clk,'0','0','1',temp(3),A(3));
output0<=A(0);
output1<=A(1);
output2<=A(2);
output3<=A(3);
end Behavioral;
and using this testbench i'm getting 'U's for my outputs:
ENTITY TestBench IS
END TestBench;
ARCHITECTURE behavior OF TestBench IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT Main
PORT(
s : IN std_logic_vector(1 downto 0);
clk : IN std_logic;
output0 : OUT std_logic;
output1 : OUT std_logic;
output2 : OUT std_logic;
output3 : OUT std_logic
);
END COMPONENT;
--Inputs
signal s : std_logic_vector(1 downto 0) := (others => '0');
signal clk : std_logic := '0';
--Outputs
signal output0 : std_logic;
signal output1 : std_logic;
signal output2 : std_logic;
signal output3 : std_logic;
-- Clock period definitions
constant clk_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: Main PORT MAP (
s => s,
clk => clk,
output0 => output0,
output1 => output1,
output2 => output2,
output3 => output3
);
-- 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
-- hold reset state for 100 ns.
wait for 100 ns;
wait for clk_period*10;
-- insert stimulus here
wait;
end process;
END;
I am getting this error while trying to implement a D flip-flop and simulate it:
VRFC 10-718] formal port does not exist in entity .
Please compare the definition of block to its component
declaration and its instantiation to detect the mismatch.
I am new to the language and can't figure out why this happening.
Bellow is my VHDL code.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity Interfata is
port(
clk : in std_logic;
data :in std_logic;
Q : out std_logic;
Qnot : out std_logic
);
end Interfata;
architecture Behavioral of Interfata is
component LATCH
port(
set : in std_logic;
reset : in std_logic;
data : out std_logic;
data_not : out std_logic
);
end component;
signal latch_set: std_logic;
signal latch_reset:std_logic;
begin
uut1: latch port map(
set => latch_set,
reset => latch_reset,
data => Q,
data_not => Qnot
);
process(clk,data)
begin
if(clk' event and clk='1') then
latch_set <= data;
latch_reset <= not data;
end if;
end process;
end Behavioral;
here's the latch.vhd code
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity latch is
port(
set : in std_logic;
reset :in std_logic;
data : out std_logic;
data_not : out std_logic
);
end latch;
architecture Behavioral of latch is
signal data_temp : std_logic:='0';
signal data_not_temp : std_logic:='1';
begin
process(set, reset) begin
data_temp <= not(reset or data_not_temp);
data_not_temp <= not(set or data_temp);
data <= data_temp;
data_not <= data_not_temp;
end process;
end Behavioral;
I'm writing TDC based on Vernier method in Vivado. My board is VC707 with virtex 7 core. After I finished writing my vhdl code i started simulation . Unfortunately I'm still learning fpga and vhdl so I stuck with one problem.
At first i wanted to check my my input circuit so i write a simple testbench to simulate. I generate short time interval to check this part of TDC. After i start simulation two of my outputs are uninicialized and other outputs have no sense ( should be high edge but simulation show zeros on the output).
On outputs should be rising edges. This circuit is intended to shape signals for my ring oscillators.
My vhdl desing:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity Uklad_WE is
Port ( Start : in STD_LOGIC;
Stop : in STD_LOGIC;
Reset : in STD_LOGIC;
Pulse_st : out STD_LOGIC;
Pulse_sp : out STD_LOGIC;
Encnt_st : out STD_LOGIC;
Encnt_sp : out STD_LOGIC);
end Uklad_WE;
architecture Behavioral of Uklad_WE is
signal dst1_out : std_logic;
signal dst2_out : std_logic;
signal dsp1_out : std_logic;
signal dsp2_out : std_logic;
signal INV_chain_13_o : std_logic;
signal INV_chain_15_o : std_logic;
signal gate_cnt1_o : std_logic;
signal gate_cnt2_o : std_logic;
signal dcnt1_out : std_logic;
signal dcnt2_out : std_logic;
component ffd
port(
D,CLK,R : in STD_LOGIC;
Q: out STD_LOGIC
);
end component;
component ffd_set
port(
D,S,CLK : in STD_LOGIC;
Q : out STD_LOGIC
);
end component;
component INV_chain_15
port(
input : in STD_LOGIC;
output : out STD_LOGIC;
cnt_sig : inout std_logic
);
end component;
component INV_chain_13
port(
input : in STD_LOGIC;
output : out STD_LOGIC;
cnt_sig : inout std_logic
);
end component;
begin
DST1: ffd port map(
D => '1',
CLK => Start,
R => Reset,
Q => dst1_out);
DST2 : ffd_set port map(
D => '0',
CLK => dst1_out,
S => INV_chain_13_o,
Q => dst2_out);
DSP1 : ffd port map(
D => dst1_out,
CLK => Stop,
R => Reset,
Q => dsp1_out);
DSP2 : ffd_set port map(
D => '0',
CLK => dsp1_out,
S => INV_chain_15_o,
Q => dsp2_out);
DCNT1 : ffd port map(
D => '1',
CLK => gate_cnt1_o,
R => Reset,
Q => dcnt1_out);
DCNT2 : ffd port map(
D => '1',
CLK => gate_cnt2_o,
R => Reset,
Q => dcnt2_out);
INV_chain_st : INV_chain_13 port map(
input => dst2_out,
output => INV_chain_13_o,
cnt_sig => gate_cnt1_o);
INV_chain_sp : INV_chain_15 port map(
input => dsp2_out,
output => INV_chain_15_o,
cnt_sig => gate_cnt2_o);
Pulse_st <= dst2_out;
Pulse_sp <= dsp2_out;
Encnt_st <= dcnt1_out;
Encnt_sp <= dcnt2_out;
end Behavioral;
My testbench :
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_unsigned.ALL;
entity symulacja_tdc_vo is
end symulacja_tdc_vo;
architecture Behavioral of symulacja_tdc_vo is
component Uklad_WE
Port(
Start : in STD_LOGIC;
Stop : in STD_LOGIC;
Reset : in STD_LOGIC;
Pulse_st : out STD_LOGIC;
Pulse_sp : out STD_LOGIC;
Encnt_st : out STD_LOGIC;
Encnt_sp : out STD_LOGIC);
end component;
--inputs
signal Start : STD_LOGIC := '0';
signal Stop : STD_LOGIC := '0';
signal Reset : STD_LOGIC := '0';
--outputs
signal Pulse_st : STD_LOGIC;
signal Pulse_sp : STD_LOGIC;
signal Encnt_st : STD_LOGIC;
signal Encnt_sp : STD_LOGIC;
begin
--uut
uut: Uklad_WE port map(
Start => Start,
Stop => Stop,
Reset => Reset,
Pulse_st => Pulse_st,
Pulse_sp => Pulse_sp,
Encnt_st => Encnt_st,
Encnt_sp => Encnt_sp);
-- stimuluis process
stim_proc1: process
begin
Start <= not Start after 5 ps;
wait for 500 ps;
end process;
stim_proc2: process
begin
Stop <= not Stop after 50 ps;
wait for 500 ps;
end process;
stim_proc3: process
begin
wait for 250 ps;
Reset <= not Reset;
wait for 500 ps;
end process;
end Behavioral;
Components code :
ffd - ffd with reset
library ieee;
use ieee.std_logic_1164.all;
entity ffd is
port (
D, CLK, R : in std_logic;
Q : out std_logic );
end ffd;
architecture Bech of ffd is
begin
process( CLK, R )
begin
if R = '0' then
Q <= '0';
elsif rising_edge(CLK) then
Q <= D;
end if;
end process;
end Bech;
ffd_set - ffd with set
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity ffd_set is
port (
D, CLK, S : in std_logic;
Q : out std_logic );
end ffd_set;
architecture Bech of ffd_set is
begin
process( CLK, S )
begin
if S = '0' then
Q <= '1';
elsif rising_edge(CLK) then
Q <= D;
end if;
end process;
end Bech;
INV_chain_13 - inverters chain
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity INV_chain_13 is
Port ( input : in STD_LOGIC;
output : out STD_LOGIC;
cnt_sig : inout STD_LOGIC);
end INV_chain_13;
architecture Behavioral of INV_chain_13 is
signal gate_o : std_logic_vector(12 downto 0);
begin
gate_o(0) <= input;
inv_g_chain : for i in 1 to gate_o'high generate
gate_o(i) <= not gate_o(i-1);
end generate;
gate_o(1) <= cnt_sig;
output <= gate_o(12);
end Behavioral;
INV_chain_15 - also inverters chain, only number of inv is diffrent
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity INV_chain_15 is
Port ( input : in STD_LOGIC;
output : out STD_LOGIC;
cnt_sig : inout STD_LOGIC);
end INV_chain_15;
architecture Behavioral of INV_chain_15 is
signal gate_o : std_logic_vector(14 downto 0);
begin
gate_o(0) <= input;
inv_g_chain : for i in 1 to gate_o'high generate
gate_o(i) <= not gate_o(i-1);
end generate;
gate_o(1) <= cnt_sig;
output <= gate_o(14);
end Behavioral;
RTL Analysis
This is schematic of my design
RTL form Vivado screenshot
Simulation
And major problem :
Simulation screenshot
Maybe it's vhdl code issue, I don't know every rule of vhdl programming yet, I hope someone with better experience can help me.
I think there is some problem with set and reset in ffd . I try many options but nothing helped.
First of all: you're learning VHDL, and you have a Virtex-7??? I'm programming VHDL for 15 years now, but often only work with spartans... Virtex is just too expensive. Restectp.
But anyhow
inv_g_chain : for i in 1 to gate_o'high generate
gate_o(i) <= not gate_o(i-1);
end generate;
What are you trying to do here? I expect you want to use inverters to get some delay? Only, in VHDL concurrent assignment is instantaneous, so it does not work. You should add the delay manually. E.g.:
gate_o(i) <= not gate_o(i-1) after 10 ns;
by the way, do you know that you could use generics, more links to have a variable inverter delay chain length? Then you could combine INV_chain_13 and INV_chain_15 into one entity.
Then you have multiple drivers for the same signal:
gate_o(1) <= not gate_o(0);
and
gate_o(1) <= cnt_sig;
Multiple drivers does not work properly. And what's up with cnt_sig being of the inout type? <= is not a bidirectional assignment. VHDL is not good at bidirectional assignments, so try a different approach.
You are trying to build an asynchronous system. It is possible, but quite difficult. Please consider making something synchronous first, to get some experience.... Now you're trying to do F1 at your first driving lesson.
How can I make a testbench for this full adder code. I'm a newbie and would appreciate any help.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity Full_Adder is
PORT(a , b , C_In : IN STD_LOGIC; S,C_Out : OUT STD_LOGIC);
end Full_Adder;
architecture Behavioral of Full_Adder is
begin
S <= a XOR b XOR C_In;
C_Out <= (a AND b) OR (a AND C_In) OR (b AND C_In);
end Behavioral;
Here's a good reference, one of the first that came up when I googled how to write a testbench.
You should google first, give it an honest shot, then come back here with more specific questions.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity Full_Adder_tb is
end Full_Adder_tb;
architecture Behavioral of Full_Adder_tb is
component Full_Adder is -- component declaration
port(
a : in std_logic;
b : in std_logic;
C_in : in std_logic;
S : out std_logic;
C_out : out std_logic
);
end component;
signal a: std_logic := '0'; -- signal declarations
signal b: std_logic := '0';
signal C_in: std_logic := '0';
signal S: std_logic;
signal C_out : std_logic;
begin
uut : Full_Adder -- component instantiation
port map(
a => a, -- signal mappings
b => b,
C_in => C_in,
S => S,
C_out => C_out);
process
begin
wait 10 ns; -- wait time
a <= '0'; b <= '0'; C_in <= '1'; -- example test vector
wait 10 ns;
-- Other test vectors and waits here
end process;
end Behavioral;