Professional Documents
Culture Documents
HDL 9
HDL 9
Presented by:
Ms.Sejal Rathod
Masters of Engineering,
Electronics & Communication
BINARY TO GREY
Xor gate entity arechitecture……
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY bin2grey IS
PORT (bin : IN std_logic_vector(3 DOWNTO 0);
grey : OUT std_logic_vector(3 DOWNTO 0));
END bin2grey;
endmodule
// Code your testbench // since en and i are input values,
module tb; en=1;i=128;#5
reg en; en=1;i=64;#5
reg [7:0]i; en=1;i=32;#5
wire [2:0]y; en=1;i=16;#5
en=1;i=8;#5
// instantiate the model: creating en=1;i=4;#5
priorityenoder83_dataflow dut(en,i,y); en=1;i=2;#5
initial en=1;i=1;#5
begin en=0;i=8'bx;#5
$dumpfile("dump.vcd");$dumpvars(1); $finish;
$monitor("en=%b i=%b y=%b",en,i,y); end
endmodule
VHDL (Dataflow: Four-Bit Adder)
-- Dataflow description of four-bit adder
entity binary_adder is
port (Sum: out Std_Logic_Vector (3 downto 0);
C_out: out Std_Logic; A, B: in Std_Logic_Vector (3 downto 0); C_in: in Std_Logic);
end binary_adder;