library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity ggg is
port(clk:in std_logic;
outp0,outp1:out std_logic);
end entity ggg;
architecture bh of ggg is
begin
process(clk)
variable sum:std_logic_vector(1 downto 0);
begin
if rising_edge(clk)then
sum:=sum+1;
outp0<=sum(0);
outp1<=sum(1);
if sum=4 then
sum:="00";
end if;
end if;
end process;
end architecture bh;
VHDL手把手起步

关键词: 手把手 起步

library ieee;
use ieee.std_logic_1164.all;
entity ggg is
port(D,clk,clr:in std_logic;
Q:out std_logic);
end entity ggg;
architecture one of ggg is
begin
process(clk,D,clr)
begin
if clk'event and clk='1' then
if clr='1' then
Q<='0';
else
Q<=D;
end if;
end if;
end process;
end architecture one;

library ieee;
use ieee.std_logic_1164.all;
entity ggg is
port(D,clk,clr:in std_logic;
Q:out std_logic);
end entity ggg;
architecture one of ggg is
begin
process(clk,D,clr)
begin
if clr='1' then
Q<='0';
elsif clk'event and clk='1' then
Q<=D;
end if;
end process;
end architecture one;

----------------------------------------------------
-- 全减器 --
----------------------------------------------------
entity full_sub is
port(x, y : in bit;--std_logic;
sub_in : in bit;--std_logic;--低借位
diffr : out bit;--std_logic; --差
sub_out: out bit);--std_logic);--高借位
end entity full_sub;
----------------------------------------------------
--
architecture b of full_sub is
begin
process(x,y,sub_in) is
subtype std3bit is bit_vector(0 to 2);
begin
case std3bit'(x&y&sub_in) is
when "000" => diffr <= '0'; sub_out <= '0';
when "001" => diffr <= '1'; sub_out <= '1';
when "010" => diffr <= '1'; sub_out <= '1';
when "011" => diffr <= '0'; sub_out <= '1';
when "100" => diffr <= '1'; sub_out <= '0';
when "101" => diffr <= '0'; sub_out <= '0';
when "110" => diffr <= '0'; sub_out <= '0';
when "111" => diffr <= '1'; sub_out <= '1';
end case;
end process;
end architecture b;
-----------------------------------------------------
-----------------------------------------------------
--结构化描述
architecture str of full_sub is
signal tempD, tempC1,tempC2 :bit;
component half_sub
port(x, y : in bit;
d, c : out bit);
end component;
component orgate
port(x, y : in bit;
z : out bit);
end component;
begin
u0: half_sub port map(x,y,tempD,tempC1);
u1: half_sub port map(tempD,sub_in,diffr,tempC2);
u2: orgate port map(tempC1,tempC2,sub_out);
end architecture str;
-----------------------------------------------------
--配置
configuration xw of full_sub is
for b
end for;
end configuration xw;
configuration jgh of full_sub is
for str
end for;
end configuration jgh;
-----------------------------------------------------
-----------------------------------------------------
--半减器
-----------------------------------------------------
entity half_sub is
port(x,y : in bit;
d,c : out bit); --d 差,c 高借位
end entity half_sub;
architecture a of half_sub is
begin
process(x,y)
begin
d <= x xor y;
c <=(not x) and y;
end process;
end architecture a;
-----------------------------------------------------
-----------------------------------------------------
--或门
-----------------------------------------------------
entity orgate is
port(x,y : in bit;
z : out bit);
end entity orgate;
architecture a of orgate is
begin
z<= x or y;
end architecture a;
-----------------------------------------------------
-----------------------------------------------------

library ieee;
use ieee.std_logic_1164.all;
entity bcdtoled is
port(bcd : in std_logic_vector(3 downto 0);
led : out std_logic_vector(6 downto 0));--(6:0 is a,b,c,d,e,f,g);
end entity bcdtoled;
architecture a of bcdtoled is
begin
with bcd select
led <= "1111110" when "0000",
"0110000" when "0001",
"1101101" when "0010",
"1111001" when "0011",
"0110011" when "0100",
"1011011" when "0101",
"1011111" when "0110",
"1110000" when "0111",
"1111111" when "1000",
"1111011" when "1001",
"1110111" when "1010",
"0011111" when "1011",
"1001110" when "1100",
"0111101" when "1101",
"1001111" when "1110",
"1000111" when "1111",
"0000000" when others;
end architecture a;
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
Buck电路工作在CCM模式下电感电流的计算公式是什么?被打赏5分 | |
buck电路工作原理被打赏5分 | |
基于MSPM0L1306的MODBUS-RTU协议通讯实验被打赏50分 | |
每周了解几个硬件知识+485硬件知识分享被打赏10分 | |
【换取手持示波器】树莓派PICOW网页烟花被打赏18分 | |
【换取手持示波器】树莓派PICO逻辑分析仪被打赏16分 | |
【分享评测,赢取加热台】教你五分钟本地部署蒸馏版本的DeepSeekR1-7B被打赏12分 | |
【换取手持示波器】蓝牙音箱更换电池被打赏8分 | |
【换取手持示波器】鼠标更换微动开关被打赏10分 | |
【我要开发板】4.传感器移植被打赏50分 |