所需仪器:
软件:modelsim、quartus。
硬件:实验箱。
步骤
- 在modelsim中新建工程并添加Verilog文件后编写代码;
- 编译并仿真得到波形图;
- 在quarters中新建工程并将Verilog源文件添加进去,编译并运行;
- 设置管脚并连接试验箱进行测试。
代码
** 10输入编码器**:
module bianmaqi(I_L,A_L);
input [9:0] I_L;
output [3:0] A_L;
reg [3:0] A_L;
integer j;
always @ (I_L or A_L)
begin
for(j=0;j<=9;j=j+1)
begin
if(I_L[j]==1)
A_L=j;
end
end
endmodule
七段译码器:
module Vrseg(A_L,EN,SA,SB,SC,SD,SE,SF,SG);
input EN;
input[3:0]A_L;
output SA,SB,SC,SD,SE,SF,SG;
reg SA,SB,SC,SD,SE,SF,SG;
reg [1:7]SS;
always@(A_L or EN)begin
if(EN)
case (A_L)
4'b0000:SS=7'b1111110;
4'b0001:SS=7'b0110000;
4'b0010:SS=7'b1101101;
4'b0011:SS=7'