实验要求
对下列四段代码: (1)分别新建工程文件(工程名:_学号_chap2_4_X),新建 verilog HDL 文件,将代码输入; (2)选择菜单 Processing--Start Compilation,分析并综合电路,若有错误请自行更正,打印 代码和编译报告(Flow Summary); (3)选择菜单 Tools—Netlist Viewers—RTL Viewer,查看逻辑电路图并截图打印; (4)将文件 Waveform.vwf(群文件中下载)拷贝到新建的工程文件夹中(也可自行建立该文 件),打开该文件,并选择菜单 Simulation—Run Functional Simulation,分析仿真结果; 注:每一步都需要截图、打印、分析 (5)对比分析 4 段代码、电路和仿真结果的共同点和差异。
模块代码
// 代码 1: Gate-level description of a 2-to-1-line multiplexer
module ljq_2344_chap2_4_1 (
A, B, SEL, OUT
);
input A, B, SEL; // 定义输入信号
output OUT; // 定义输出信号
wire selnot, A1, B1; // 定义内部节点信号数据类型
not U1(selnot, SEL);
and U2(A1, A, selnot);
and U3(B1, B, SEL);
or U4(OUT, A1, B1);
endmodule //ljq_2344_chap2_4_1
// 代码 2: Gate-level description of a 2-to-1-line multiplexer
module ljq_2344_chap2_4_2 (
A, B, SEL, L
);
input A, B, SEL; // 定义输入信号
output L; // 定义输出信号
tri L; // 定义三态逻辑输出信号 L
bufif0(L, A, SEL); // 低电平使能三态缓冲器
bufif1(L, B, SEL); // 高电平使能三态缓冲器
endmodule
// 代码 3: Dataflow description of a 2-to-1-line multiplexer
module ljq_2344_chap2_4_3 (
A, B, SEL, L
);
input A, B, SEL; // 定义输入信号
output L; //定义输出信号
assign L = SEL?B:A; // 三目选择运算符,生成数据选择器
endmodule
// 代码 4: Behavioral description of a 2-to-1-line multiplexer
module ljq_2344_chap2_4_4 (
A, B, SEL, L
);
input A, B, SEL; // 定义输入信号
output L; // 定义输出信号
reg L; // 定义寄存器变量
always @(SEL or A or B) begin // 行为描述
if(SEL==1) L=B; // 或 if(SEL) L=B;
else L=A;
end
endmodule