با سللام من یه جمع و تفریق کننده با فول ادر 4 بیتی می خوام برنامشو با vhdl بنویسم کسی میتونه کمکم کنه؟اگه کسی میتونه بگه تا توضیح بیشتری بدم ممنون میشم
اطلاعیه
Collapse
No announcement yet.
حل تمرین vhdl جمع و تفریق کننده
Collapse
X
-
پاسخ : حل تمرین
سلام
3 تا کد میزارم که بصورت استراکچرال تو هم استفاده شده و جمع و تفریق رو انجام میده. 3 تا فایل VHD بساز و فایل ADDER رو تاپ ماژول کن
HALF ADDER
FULL ADDER
ADDER 4 BIT
HALF ADDER:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity ha is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
s : out STD_LOGIC;
c : out STD_LOGIC);
end ha;
architecture Behavioral of ha is
begin
s<=a xor b;
c<=a and b;
end Behavioral;
FULL ADDER:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity fa is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
ci : in STD_LOGIC;
s : out STD_LOGIC;
co : out STD_LOGIC);
end fa;
architecture Behavioral of fa is
component ha is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
s : out STD_LOGIC;
c : out STD_LOGIC);
end component;
signal sig1, sig2, sig3: std_logic;
begin
u1: ha port map (a,b,sig1,sig2);
u2: ha port map (sig1,ci,s,sig3);
co<= sig3 or sig2;
end Behavioral;
ADDER
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity adder is
Port ( x : in STD_LOGIC_VECTOR (3 downto 0);
y : in STD_LOGIC_VECTOR (3 downto 0);
m : in STD_LOGIC;
f : out STD_LOGIC_VECTOR (3 downto 0);
co : out STD_LOGIC);
end adder;
architecture Behavioral of adder is
component fa is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
ci : in STD_LOGIC;
s : out STD_LOGIC;
co : out STD_LOGIC);
end component;
signal sxor: std_logic_vector(3 downto 0);
signal sco: std_logic_vector(2 downto 0);
begin
u1: fa port map(x(0),sxor(0),m,f(0),sco(0));
u2: fa port map(x(1),sxor(1),sco(0),f(1),sco(1));
u3: fa port map(x(2),sxor(2),sco(1),f(2),sco(2));
u4: fa port map(x(3),sxor(3),sco(2),f(3),co);
sxor(0)<=m xor y(0);
sxor(1)<=m xor y(1);
sxor(2)<=m xor y(2);
sxor(3)<=m xor y(3);
end Behavioral;
موفق باشید
خدا گفت : به جهنم ببریدش، او برگشت و با تعجب به خدا نگاه کرد. خدا گفت : به بهشت ببریدش. فرشتگان پرسیدند: چرا؟! خدا گفت : او هنوز به من امیدوار است...
-
پاسخ : حل تمرین VHDL با توجه به تصویر پیوست
خیلی ممنون از زحمات تون من نیاز دارم یه عکس بزارم تا تمرین رو شرح بده یه جاهاییش درسته دقیقا همونی که می خوام ولی یه جاهایی تغییر داره ببخشید که از اول عکس و نزاشتم تازه رسید به دستم سوال ممنون میشم بزرگواری کنید
https://drive.google.com/file/d/0B0Ho5c2Clkm8NlJhQ1NvSFJ6YjA/view?usp=sharing
دیدگاه
-
پاسخ : حل تمرین vhdl جمع و تفریق کننده
سلام دوستان من هرچی میخوام کامپایل کنم این ارورو میده :
# Warning: DAGGEN_0523: The source is compiled without the -dbg switch. Line breakpoints and assertion debug will not be available.
# Error: VLM_0040: VHDL unit cannot be compiled as the target library name is not a legal VHDL identifier.
میگه library مشکل داره ولی بیا اینم برنامم:
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity full_adder is
port(
a : in STD_LOGIC;
b : in STD_LOGIC;
cin : in STD_LOGIC;
s : out STD_LOGIC;
c : out STD_LOGIC
);
end full_adder;
--}} End of automatically maintained section
architecture full_adder of full_adder is
begin
s<=(a xor b)xor cin;
c<=(a and b)or(cin and (a xor b));
end full_adder;
حالا به نظرتون مشکل چیه؟
دیدگاه
دیدگاه