Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
library ieee;
use ieee.std_logic_1164.all;
entity andgate is
port(
a:in std_ulogic;
b: in std_ulogic;
c: out std_ulogic
);
end andgate;
architecture behavior of andgate is
begin
c <= a and b;
end behavior;
** ## AND GATE TESTBENCH
library ieee;
use ieee.std_logic_1164.all;
entity andgate_tb is
---> no content
end andgate_tb;
architecture test of andgate_tb is
component andgate
port(
a,b: in std_logic;
c: out std_logic
);
end component;
signal ak,bk,ck: std_logic;
begin
and_gate: andgate port map(a=>ak, b=>bk, c=>ck);
process begin
ak <= '0';
bk <= '0';
wait for 1 ns;
ak <= '0';
bk <= '1';
wait for 1 ns;
ak <= '1';
bk <= '0';
wait for 1 ns;
ak <= '1';
bk <= '1';
wait for 1 ns;
assert false report "Completed successfully";
wait;
end process;
end test;
**## FULL ADDER
library ieee;
use ieee.std_logic_1164.all;
entity fa is
port(
a: in std_ulogic;
b: in std_ulogic;
cin: in std_ulogic;
cout: out std_ulogic;
s: out std_ulogic
);
end fa;
architecture behave of fa is
begin
s <= (a xor b) xor cin;
cout <= ((a xor b) and cin) or (a and b);
end behave;
**##FULL ADDER TEST BENCH
library ieee;
use ieee.std_logic_1164.all;
entity fa_testbench is
end fa_testbench;
architecture test of fa_testbench is
component fa
port(
a: in std_ulogic;
b: in std_ulogic;
cin: in std_ulogic;
cout: out std_ulogic;
s: out std_ulogic
);
end component;
signal ain, bin, cin, cout, sum : std_logic;
begin
full_adder: fa port map (a => ain, b => bin, cin => cin, cout => cout, s => sum);
process begin
ain <= '0';
bin <= '0';
cin <= '0';
wait for 1 ns;
ain <= '0';
bin <= '0';
cin <= '1';
wait for 1 ns;
ain <= '0';
bin <= '1';
cin <= '0';
wait for 1 ns;
ain <= '0';
bin <= '1';
cin <= '1';
wait for 1 ns;
ain <= '1';
bin <= '0';
cin <= '0';
wait for 1 ns;
ain <= '1';
bin <= '0';
cin <= '1';
wait for 1 ns;
ain <= '1';
bin <= '1';
cin <= '0';
wait for 1 ns;
ain <= '1';
bin <= '1';
cin <= '1';
wait for 1 ns;
assert false report "Reached end of test";
wait;
end process;
end test;
**## HALF ADDER
library ieee;
use ieee.std_logic_1164.all;
entity ha is
port
(
a: in std_ulogic;
b: in std_ulogic;
s: out std_ulogic;
c: out std_ulogic
);
end ha;
architecture behave of ha is
begin
s <= a xor b;
c <= a and b;
end behave;
**## HALF ADDER TEST BENCH
library ieee;
use ieee.std_logic_1164.all;
entity ha_tb is
end ha_tb;
architecture test of ha_tb is
component ha
port
(
a: in std_ulogic;
b: in std_ulogic;
c: out std_ulogic;
s: out std_ulogic
);
end component;
signal a,b,s,c: std_logic;
begin
half_adder: ha port map (a=>a, b=>b ,c=>c, s=>s);
process begin
a <= '0';
b <= '0';
wait for 1 ns;
a <= '0';
b <= '1';
wait for 1 ns;
a <= '1';
b <= '0';
wait for 1 ns;
a <= '1';
b <= '1';
wait for 1 ns;
assert false report "Reached end of test";
wait;
end process;
end test;
**## NAND GATE
library ieee;
use ieee.std_logic_1164.all;
entity nandgate is
port(
a,b:in std_logic;
c: out std_logic
);
end nandgate;
architecture behavior of nandgate is
begin
c <= not (a and b);
end behavior;
**## NAND GATE TEST BENCH
library ieee;
use ieee.std_logic_1164.all;
entity nandgate_testbench is
---> no content
end nandgate_testbench;
architecture test of nandgate_testbench is
component nandgate
port(
a,b: in std_logic;
c: out std_logic
);
end component;
signal a,b,c: std_logic;
begin
nand_gate: nandgate port map(a=>a, b=>b, c=>c);
process begin
a <= '0';
b <= '0';
wait for 1 ns;
a <= '0';
b <= '1';
wait for 1 ns;
a <= '1';
b <= '0';
wait for 1 ns;
a <= '1';
b <= '1';
wait for 1 ns;
assert false report "Completed successfully";
wait;
end process;
end test;
**## NOT GATE
library ieee;
use ieee.std_logic_1164.all;
entity notgate is
port(
a: in std_logic;
b: out std_logic
);
end notgate;
architecture behavior of notgate is
begin
b <= not a;
end behavior;
**## NOT GATE TEST BENCH
library ieee;
use ieee.std_logic_1164.all;
entity notgate is
port(
a: in std_logic;
b: out std_logic
);
end notgate;
architecture behavior of notgate is
begin
b <= not a;
end behavior;
**## OR GATE
library ieee;
use ieee.std_logic_1164.all;
entity orgate is
port(
a,b:in std_logic;
c: out std_logic
);
end orgate;
architecture behavior of orgate is
begin
c <= a or b;
end behavior;
**## ORGATE TEST BENCH
library ieee;
use ieee.std_logic_1164.all;
entity orgate_testbench is
---> no content
end orgate_testbench;
architecture test of orgate_testbench is
component orgate
port(
a,b: in std_logic;
c: out std_logic
);
end component;
signal a,b,c: std_logic;
begin
or_gate: orgate port map(a=>a, b=>b, c=>c);
process begin
a <= '0';
b <= '0';
wait for 1 ns;
a <= '0';
b <= '1';
wait for 1 ns;
a <= '1';
b <= '0';
wait for 1 ns;
a <= '1';
b <= '1';
wait for 1 ns;
assert false report "Successfully Completed !";
wait;
end process;
end test;
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team