第一题:构建工程,实现 8 选 1 的数据选择器 74HC151,编写仿真代码进行测试,将该工程并生成 IP 核。(必须)
使用软件: Vivado
开发板: EGO1采用Xilinx Artix-7系列XC7A35T-1CSG324C FPGA
`timescale 1ns / 1ps
//
// Module Name: v_74hc151
// Revision 0.01 - File Created
// Additional Comments:
//
//
//文章有用的话记得给靓仔点个赞表示鼓励哟~
module v_74hc151(E_,S,D,Y,Y_);
/*
E_:使能
S[2]:选择
D[7]:输入
Y、Y_:输出
*/
input E_;
input[2:0] S;
input[7:0] D;
output Y,Y_;
reg Y=0;
reg Y_=1;
always @(E_ or S or D)
begin
if(E_ == 1)
begin
Y=0;
Y_=1;
end
else
begin
case (S)
0:Y=D[0];
1:Y=D[1];
2:Y=D[2];
3:Y=D[3];
4:Y=D[4];
5:Y=D[5];
6:Y=D[6];
7:Y=D[7];
endcase
end
Y_=~Y;//按位取反
end
endmodule
`timescale 1ns / 1ps
//
// Module Name: sim_74hc151
// Revision 0.01 - File Created
// Additional Comments:
//
//
//文章有用的话记得给靓仔点个赞表示鼓励哟~
module sim_74hc151(
);
reg E_;
reg[2:0] S;
reg[7:0] D;
wire Y,Y_;
v_74hc151 simt(E_,S,D,Y,Y_);
initial begin
E_=1;
S=0;
D=0;
# 100 //延时100ns
E_=0;
D=8'b01010101;
end
always #20 S=S+1;
endmodule
注意:生成bit流文件时报错可能是约束语句出现问题
使能控制:E_采用拨码开关:P5
选择控制:S采用拨码开关:P4,P3,P2
输入控制:D采用DIP开关:U3,U2,V2,V5,V4,R3,T3,T5
输出显示:Y采用LED灯F6,Y_采用LED灯G4
## Switch
set_property PACKAGE_PIN P5 [get_ports E_]
set_property IOSTANDARD LVCMOS33 [get_ports E_]
set_property PACKAGE_PIN P4 [get_ports {S[2]}]
set_property IOSTANDARD LVCMOS33 [get_ports {S[2]}]
set_property PACKAGE_PIN P3 [get_ports {S[1]}]
set_property IOSTANDARD LVCMOS33 [get_ports {S[1]}]
set_property PACKAGE_PIN P2 [get_ports {S[0]}]
set_property IOSTANDARD LVCMOS33 [get_ports {S[0]}]
set_property PACKAGE_PIN U3 [get_ports {D[7]}]
set_property IOSTANDARD LVCMOS33 [get_ports {D[7]}]
set_property PACKAGE_PIN U2 [get_ports {D[6]}]
set_property IOSTANDARD LVCMOS33 [get_ports {D[6]}]
set_property PACKAGE_PIN V2 [get_ports {D[5]}]
set_property IOSTANDARD LVCMOS33 [get_ports {D[5]}]
set_property PACKAGE_PIN V5 [get_ports {D[4]}]
set_property IOSTANDARD LVCMOS33 [get_ports {D[4]}]
set_property PACKAGE_PIN V4 [get_ports {D[3]}]
set_property IOSTANDARD LVCMOS33 [get_ports {D[3]}]
set_property PACKAGE_PIN R3 [get_ports {D[2]}]
set_property IOSTANDARD LVCMOS33 [get_ports {D[2]}]
set_property PACKAGE_PIN T3 [get_ports {D[1]}]
set_property IOSTANDARD LVCMOS33 [get_ports {D[1]}]
set_property PACKAGE_PIN T5 [get_ports {D[0]}]
set_property IOSTANDARD LVCMOS33 [get_ports {D[0]}]
## LED
set_property PACKAGE_PIN F6 [get_ports Y]
set_property IOSTANDARD LVCMOS33 [get_ports Y]
set_property PACKAGE_PIN G4 [get_ports Y_]
set_property IOSTANDARD LVCMOS33 [get_ports Y_]