VHDL寄存器组设计.docx
- 文档编号:25298773
- 上传时间:2023-06-07
- 格式:DOCX
- 页数:11
- 大小:540.03KB
VHDL寄存器组设计.docx
《VHDL寄存器组设计.docx》由会员分享,可在线阅读,更多相关《VHDL寄存器组设计.docx(11页珍藏版)》请在冰豆网上搜索。
VHDL寄存器组设计
本存放器组设计需要以下四个代码模块实现
--以下为VHDL存放器组代码
libraryIEEE;
useIEEE.STD_LOGIC_1164.ALL;
entityregfileis
Port(DR:
instd_logic_vector(1downto0);
--SR:
instd_logic_vector(1downto0);
reset:
instd_logic;
DRWr:
instd_logic;
clk:
instd_logic;
d_input:
instd_logic_vector(15downto0);
DR_data:
outstd_logic_vector(15downto0)
--SR_data:
outstd_logic_vector(15downto0)
);
endregfile;
architecturestructofregfileis
--ponents
--16bitRegisterforregisterfile
ponentreg
port(
clr:
instd_logic;
D:
instd_logic_vector(15downto0);
clock:
instd_logic;
write:
instd_logic;
sel:
instd_logic;
Q:
outstd_logic_vector(15downto0)
);
endponent;
--2to4Decoder
ponentdecoder_2_to_4
port(
sel:
instd_logic_vector(1downto0);
sel00:
outstd_logic;
sel01:
outstd_logic;
sel02:
outstd_logic;
sel03:
outstd_logic
);
endponent;
--4to1linemultiplexer
ponentmux_4_to_1
port(
input0,
input1,
input2,
input3:
instd_logic_vector(15downto0);
sel:
instd_logic_vector(1downto0);
out_put:
outstd_logic_vector(15downto0)
);
endponent;
signalreg00,reg01,reg02,reg03
:
std_logic_vector(15downto0);
signalsel00,sel01,sel02,sel03
:
std_logic;
begin
Areg00:
regportmap(
clr=>reset,
D=>d_input,
clock=>clk,
write=>DRWr,
sel=>sel00,
Q=>reg00
);
Areg01:
regportmap(
clr=>reset,
D=>d_input,
clock=>clk,
write=>DRWr,
sel=>sel01,
Q=>reg01
);
Areg02:
regportmap(
clr=>reset,
D=>d_input,
clock=>clk,
write=>DRWr,
sel=>sel02,
Q=>reg02
);
Areg03:
regportmap(
clr=>reset,
D=>d_input,
clock=>clk,
write=>DRWr,
sel=>sel03,
Q=>reg03
);
--decoder
des_decoder:
decoder_2_to_4portmap
(
sel=>DR,
sel00=>sel00,
sel01=>sel01,
sel02=>sel02,
sel03=>sel03
);
mux1:
mux_4_to_1PORTMAP(
Input0=>reg00,
Input1=>reg01,
Input2=>reg02,
Input3=>reg03,
sel=>DR,
out_put=>DR_data
);
--mux2:
mux_4_to_1PORTMAP(
--input0=>reg00,
--input1=>reg01,
--input2=>reg02,
--input3=>reg03,
--sel=>SR,
--out_put=>SR_data
--);
endstruct;
以下为VHDL存放器代码
libraryieee;
useieee.std_logic_1164.all;
entityregis
port
(
clr:
instd_logic;
D:
instd_logic_vector(15downto0);
clock:
instd_logic;
write:
instd_logic;
sel:
instd_logic;
Q:
outstd_logic_vector(15downto0)
);
endreg;
architecturebehavofregis
signalreg:
std_logic_vector(15downto0):
="0000000000000000";
begin
process(clr,clock,reg)
begin
ifclr='0'then
Q<=reg;
elsif(clock'eventandclock='1')then
ifsel='1'andwrite='1'then
reg<=D;
Q<=reg;
elsifsel='1'andwrite='0'then
Q<=reg;
endif;
endif;
endprocess;
endbehav;
以下为VHDL四选一代码
libraryieee;
useieee.std_logic_1164.all;
entitymux_4_to_1is
port(
input0,
input1,
input2,
input3:
instd_logic_vector(15downto0);
sel:
instd_logic_vector(1downto0);
out_put:
outstd_logic_vector(15downto0)
);
endmux_4_to_1;
architecturebehavofmux_4_to_1is
begin
process(sel)
begin
if(sel="00")then
out_put<=input0;
elsif(sel="01")then
out_put<=input1;
elsif(sel="10")then
out_put<=input2;
elsif(sel="11")then
out_put<=input3;
endif;
endprocess;
endbehav;
以下为VHDL二四译码器代码
libraryieee;
useieee.std_logic_1164.all;
entitydecoder_2_to_4is
port(
sel:
instd_logic_vector(1downto0);
sel00:
outstd_logic;
sel01:
outstd_logic;
sel02:
outstd_logic;
sel03:
outstd_logic
);
enddecoder_2_to_4;
architecturebehavofdecoder_2_to_4is
begin
process(sel)
begin
if(sel="00")then
sel00<='1';
sel01<='0';
sel02<='0';
sel03<='0';
elsif(sel="01")then
sel00<='0';
sel01<='1';
sel02<='0';
sel03<='0';
elsif(sel="10")then
sel00<='0';
sel01<='0';
sel02<='1';
sel03<='0';
elsif(sel="11")then
sel00<='0';
sel01<='0';
sel02<='0';
sel03<='1';
endif;
endprocess;
endbehav;
实验截图:
仿真结果:
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- VHDL 寄存器 设计