Forum Discussion
interface code
Hello friends,
I have 2 circuits viz cir1 and cir 3. Now i want to link these 2 circuits via an independent entity say-cir2. In other words cir2 will act as a bridge between cir1 and cir3. i have independent vhdl files for both cir1 and cir3 i.e cir1.vhd and cir3.vhd. How do i write the code for cir2? How can i call the 2 circuits i.e cir1 and cir3 via the cir2 code? Pls assist me. Thanks, Vinod.15 Replies
- Altera_Forum
Honored Contributor
you would be doing that by forcing x1,y1,z1. I think you are confusing yourself by calling the inputs to cir2 x1,y1,z1 when the inputs to cir1 are a,b,c. Maybe change the names of the top level inputs to a,b,c and the internal signals to x,y,z
- Altera_Forum
Honored Contributor
Wow. i did not even think about that sir. but is there any way i can test this whole circuit. in other words , i just provide the i/ps a,b and c and i get the o/p p,q,r and s?
Regards, Vinod. - Altera_Forum
Honored Contributor
you need to force x1,y1,z1 as these are the top level inputs. Not a/b/c. a,b,c are just interconnect wires between two entities. You are not seeing any waves because x2,y2 and z2 are the outputs. p,q,r,s do not exist in cir2, they only exist in cir3
- Altera_Forum
Honored Contributor
Dear Sir,
Thanks again. i shall show the code that i used. There are no errors on comilation. but on simulating no waves are generated cir1.vhd library ieee; use ieee.std_logic_1164.all; entity cir1 is port(a,b,c:in std_logic; x,y,z:out std_logic); end cir1; architecture behavioural of cir1 is begin x <= (not a and not b) or (not b and not c) or (a and not c); y <= (not a and not b) or (not a and not c); z <= (not a and not b) or (a and b); end behavioural; cir3.vhd library ieee; use ieee.std_logic_1164.all; entity cir3 is port(x,y,z:in std_logic; p,q,r,s:out std_logic); end cir3; architecture behavioural of cir3 is begin p <= (not z ) or (not x and not y and z); q <= (not x and not y and z) or (x and y and z); r <= (not x and y) or (x and not y and not z); s <= not x; end behavioural; cir2.vhd library ieee; use ieee.std_logic_1164.all; entity cir2 is port(x1,y1,z1:in std_logic; x2,y2,z2:out std_logic); end cir2; architecture struct of cir2 is signal a,b,c,p,q,r,s:std_logic; begin cir1_inst : entity work.cir1 port map (x1,y1,z1,a,b,c); cir2_inst : entity work.cir2 port map (a,b,c,x2,y2,z2); end struct; my cir2.do file is also pasted quit -sim vsim cir3 view wave add wave a add wave b add wave c add wave p add wave q add wave r add wave s force a 0 50,0 100,0 150,0 200,1 250,1 300,1 350,1 400 -repeat 400 force b 0 50,0 100,1 150,1 200,0 250,0 300,1 350,1 400 -repeat 400 force c 0 50,1 100,0 150,1 200,0 250,1 300,0 350,1 400 -repeat 400 run 800ns .I don't get any o/ps. Again , thanks for ur time. I really appreciate it sir. Regards, Vinod Karuvat. - Altera_Forum
Honored Contributor
architecture struct of cir2 is
signal a,b,c : std_lgoic; begin cir1_inst : entity work.cir1 port map (x1,y1,z1, a,b,c); --- sir pls note this step. Where can i map a,b and c ? cir3_inst : entity work.cir3 port map (a,b,c, x2,y2,z2); - Altera_Forum
Honored Contributor
Yes sir.u r right. so how do I go about with this port map pls? cld u kindly give me a sample code for this pls?
Regards, Vinod. - Altera_Forum
Honored Contributor
- Altera_Forum
Honored Contributor
Hello Sir,
a,b,c ,p,q,r, and s are floating. the code i wrote was - library ieee; use ieee.std_logic_1164.all; entity cir2 is port(x1,y1,z1:in std_logic; x2,y2,z2:out std_logic); end cir2; architecture struct of cir2 is begin cir1_inst : entity work.cir1 port map (x1,y1,z1); --- sir pls note this step. Where can i map a,b and c ? cir3_inst : entity work.cir3 port map (x2,y2,z2); -- Likewise here where can I map x1,y1 and z1? Sorry to trouble u sir. Regards, Vinod. - Altera_Forum
Honored Contributor
there are no floting inputs or outputs in that diagram.
- Altera_Forum
Honored Contributor