番茄花园-4-bitALU-PPT精选

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
由S[1:0],C0共同组成3bit的控制信 号sel[2:0]
保证敏感列表完备,即包含条件表 达式涉及的信号sel, 赋值语句等号 右边的信号XIN, YIN
是否可以写成 {C1,OUT}=XIN+(~YIN); ?
5
ALU模块(Top)
module alu (s, c0, m, a, b, out, cout); input [1:0]s; input [3:0]a; input [3:0]b; input c0,m; output [3:0]out; output cout; wire [3:0] outlogic,outarith; wire coutlogic,coutarith;
Number of ports:
17
Number of nets:
26
Number of cells:
7
Number of references:
4
Combinational area: 589.000000
Noncombinational area: 0.000000
Net Interconnect area: undefined (No wire load specified)
义成reg类型 保证敏感列表完备,即包含条件表达
式涉及的信号S, 赋值语句等号右边 的信号XIN, YIN
Logic模块没有进位输出,所以令 C1=0
模块结束
4
Arithmetic子模块
module funcarith (S, C0, XIN, YIN, OUT, C1);
input C0; input [1:0]S; input [3:0]XIN;
func1 与 funclogic有相同逻辑 funclogic模块的端口 S, XIN,YIN,OUT,C1分别对应到func1模块的s,a,b,outlogic,coutlogic

funcarith func2(.S(s),.C0(c0),.XIN(a),.YIN(b),.OUT(outarith),.C1(coutarith));

2'b01: OUT = XIN | YIN;

2'b10: OUT = XIN ^ YIN;

2'b11: OUT = XIN ^~YIN;

endcase

end

assign C1= 1'b0;
endmodule
2019/8/9
模块名: funclogic 控制信号: S (S1, S0) 数据输入: XIN[3:0] 数据输入: YIN[3:0] 数据输出: OUT[3:0] 进位输出: C1 OUT出现在always语句中,必须定
reg [3:0]A,B;
reg C0;
wire COUT;
wire [3:0] OUT; initial
给定初始值

begin

MODE = 0;

C0 = 0;

S = 0;

A = 4'b0101;

B = 4'b1100;

end

always #5 C0 = ~C0;
2019/8/9
9
Simulation - modelsim
2019/8/9
10
综合
DC command .setup .scr
DC report Area report Timing report
2019/8/9
11
DC command
/* .synopsys_dc.setup */

assign out = m?outarith:outlogic; assign cout = m?coutarith:coutlogic;

模块名 alu
数据输入 a[3:0] 数据输入 b[3:0] 注意,在子模块中并没有
用到m选择信号 数据输出 进位输出 cout 定义logic子模块和
read -f verilog -f VHDL -f edif
Current_design: 定义要综合的逻 辑
set_load 5 * load_of (csmc06core/ND02D1/A) all_outputs()
compile -map medium/high/low High speed, high area cost Balance speed & area Low speed,
set_load 5 * load_of (csmc06core/ND02D1/A) all_outputs() compile -map medium
write -f verilog -h -o alu report_area report_timing -delay max quit
4-bit ALU
2019/8/9
1
Agenda
Spec 說明 代码 仿真 综合 Gate level 仿真 RTL view
2019/8/9
2
Spec 說明
2019/8/9
Input信号:
控制信号S1,S0,C0,M 数据A[3:0],B[3:0]
Output信号

3'b000: {C1,OUT}={1'b0,XIN};

3'b001: {C1,OUT}=XIN+1;

3'b010: {C1,OUT}=XIN+YIN;

3'b011: {C1,OUT}=XIN+YIN+1;

3'b100: {C1,OUT}=XIN+{1'b0,~YIN};

3'b101: {C1,OUT}=XIN+{1'b0,~YIN}+1;
X[3:0], C1
从功能上可分为两部分
M=0时, 完成logic功能, 结 果从logic模块输出
M=1时,完成arithmetic功 能,结果从算术模块输出
分析结果: 采用自下而上的设计 方法分别完成每个子模块
3
Logic子模块
module funclogic(S, XIN, YIN, OUT, C1);
report_area report_timing (max delay)
2019/8/9
14
DC report – report_area
Information: Updating design information... (UID-85)

****************************************
Assign target LIB for design complier to transfer
12
创建 “alu.scr”
read -f verilog 4bitalu.v
/* read in verilog netlist */
current_design = alu
/* assign design block */

3'b110: {C1,OUT}={1'b0,~XIN}+YIN;

3'b111: {C1,OUT}={1'b0,~XIN}+YIN+1;
endcase
endmodule
2019/8/9
模块名 funcarith 进位输入: C0 控制信号:S[1:0], 高位S1低位S0 数据输入:XIN[3:0], 4bit 数据输入:YIN[3:0], 4bit 数据输出:OUT[3:0],4bit 进位输出:C1


funcarith func2(.S(s),.C0(c0),.XIN(a),.YIN(b),.OUT(outarith),.C1(coutarith)); 调用funcarith子模块

Endmodule
2019/8/9
6
ALU模块(Top)continue
funclogic func1(.S(s),.XIN(a),.YIN(b),.OUT(outlogic),.C1(coutlogic));
input [3:0]YIN;
output [3:0]OUT; output C1; wire [2:0] sel;
reg [3:0] OUT;
reg C1;

assign sel={S[1:0],C0};
always (XIN or YIN or sel)
case (sel)
每5个时间单位,C0取反

always #10 S = S + 1;
每10个时间单位,S加1

always #40 MODE = ~MODE;
每40个时间单位,mode取

always #20 A = A + 2;


always #20 B = B + 1;
每20个时间单位,A加2
arithmetic子模块的输出 为wire型数据,出现在 assign语句中 m=0,数据输出outlogic m=1,数据输出outarith
funclogic func1(.S(s),.XIN(a),.YIN(b),.OUT(outlogic),.C1(coutlogic));
调用funclogic子模块
{S[1:0],C0} = 010
t=150ns时
{S[1:0],C0} = 011
t=200ns时
{S[1:0],C0} = 100
t=250ns时
{S[1:0],C0} = 101
t=300ns时
{S[1:0],C0} = 110
t=350ns时
{S[1:0],C0} = 111
Report : area
Design : alu
Version: V-2019.12-SP1
Date : Sat May 24 16:11:55 2019
****************************************
Library(s) Used:
csmc06core (File: /homesh01/users/hkwu/TEMP/ALU/csmc06core.db)

alu t_alu(.s(S), .c0(C0), .m(MODE), .a(A), .b(B), .out(OUT), .cout(COUT)); 每20个时间单位,B加2
endmodule
2019/8/9
8
测试代码要点
尽可能使所有状态都能出现

always #5 C0 = ~C0;
write -f verilog -h -o alu report_area: 面积报告 report_timing -delay max 最长延
时路径报告
2019/8/9
13
DC report
输入命令 “ dc_shell –f alu.scr ” 可得到gate level netlist 以及综合报告
2019/8/9
7
测试代码
`include “4bitalu.v” `timescale 10ns/1ns module alu_test;
仿真时需要包含4bitalu.v这 个文件,即前面的代码文件
时间单位为10ns,精度为1ns
reg MODE;
reg [1:0]S;

always #10 S = S + 1;

always #40 MODE = ~MODE;

always #20 A = A + 2;

always #20 B = B + 1;
例如:
t=0ns 时
{S[1:0],C0}=000
t=50ns时
{S[1:0],C0} = 001
t=100ns时
search_path = {…} target_library = {csmc06core.db}; verilogout_no_tri = "true" designer = “lirui" ; company = “lirui";
2019/8/9
Assign search path
input [1:0]S;
input [3:0]XIN;
input [3:0]YIN;
output [3:0]OUT;
output C1;
reg [3:0] OUT;

always (XIN or YIN or S)

begin

case (S)

2'b00: OUT = XIN & YIN;
相关文档
最新文档