Skip to content

Instantly share code, notes, and snippets.

@tejainece
Created January 29, 2014 14:12
Show Gist options
  • Save tejainece/8688765 to your computer and use it in GitHub Desktop.
Save tejainece/8688765 to your computer and use it in GitHub Desktop.
Read output ports in Verilog and VHDL. This was written for my blog post.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity ReadOutputCorrect is
PORT (
in1 : IN STD_LOGIC;
in2 : IN STD_LOGIC;
in3 : IN STD_LOGIC;
o1 : OUT STD_LOGIC;
o2 : OUT STD_LOGIC
);
end ReadOutputCorrect;
architecture Behavioral of ReadOutputCorrect is
SIGNAL tmp1_o1 : STD_LOGIC;
begin
tmp1_o1 <= in1 and in2;
o1 <= tmp1_o1;
o2 <= tmp1_o1 and in3;
end Behavioral;
entity ReadOutputWrong is
PORT (
in1 : IN STD_LOGIC;
in2 : IN STD_LOGIC;
in3 : IN STD_LOGIC;
o1 : OUT STD_LOGIC;
o2 : OUT STD_LOGIC
);
end ReadOutputWrong;
architecture Behavioral of ReadOutputWrong is
begin
o1 <= in1 and in2;
o2 <= o1 and in3;
end Behavioral;
module ReadTheOut(
in1, in2, in3, o1, o2
);
input in1, in2, in3;
output o1, o2;
assign o1 = in1 & in2;
assign o2 = o1 & in3;
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment