赞
踩
此系列记录FPGA在学校的学习过程。
FPGA系列
需要用到的软硬件:
软件:Quartus II 15.0 (64-bit)
硬件:
5CEBA4F23C7芯片
链接:
FPGA在校学习记录系列—新建一个FPGA工程编写程序并仿真(Verilog HDL)
创建的工程名字为:mux8_1
在.v文件中添加需要实现的代码
//mux8_1.v文件 module mux8_1 (in1, in2, in3, in4, in5, in6, in7, in8, sel, out); input in1, in2, in3, in4, in5, in6, in7, in8; input[2:0]sel; output out; reg out; always@(sel or in1 or in2 or in3 or in4 or in5 or in6 or in7 or in8) begin case(sel) 3'b000 : out = in1; 3'b001 : out = in2; 3'b010 : out = in3; 3'b011 : out = in4; 3'b100 : out = in5; 3'b101 : out = in6; 3'b110 : out = in7; 3'b111 : out = in8; endcase end endmodule
根据上面的链接文章步骤生成.vt文件,并在启动项里添加初始值
//mux8_1.vt文件(写在启动里面) initial begin // code that executes only once // insert code here --> begin sel = 3'b000; in1 = 1; in2 = 0; in3 = 0; in4 = 0; in5 = 0; in6 = 0; in7 = 0; in8 = 0; #50 sel = 3'b001; in1 = 0; in2 = 1; in3 = 0; in4 = 0; in5 = 0; in6 = 0; in7 = 0; in8 = 0; #50 sel = 3'b010; in1 = 0; in2 = 0; in3 = 1; in4 = 0; in5 = 0; in6 = 0; in7 = 0; in8 = 0; #50 sel = 3'b011; in1 = 0; in2 = 0; in3 = 0; in4 = 1; in5 = 0; in6 = 0; in7 = 0; in8 = 0; #50 sel = 3'b100; in1 = 0; in2 = 0; in3 = 0; in4 = 0; in5 = 1; in6 = 0; in7 = 0; in8 = 0; #50 sel = 3'b101; in1 = 0; in2 = 0; in3 = 0; in4 = 0; in5 = 0; in6 = 1; in7 = 0; in8 = 0; #50 sel = 3'b110; in1 = 0; in2 = 0; in3 = 0; in4 = 0; in5 = 0; in6 = 0; in7 = 1; in8 = 0; #50 sel = 3'b111; in1 = 0; in2 = 0; in3 = 0; in4 = 0; in5 = 0; in6 = 0; in7 = 0; in8 = 1; #50 // --> end
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。