Professional Documents
Culture Documents
Verilog Module
Simulated Output:
RTL Schematic:
XOR Gate:
Basic gates:
Selected Device
: 3s400tq144-4
Number of Slices
: 4 out of 4656
0%
: 7 out of 9312
0%
Number of IOs
:9
: 9 out of 158
5%
Timing Detail :
Timing constraint: Default path analysis
Total number of paths / destination ports: 13 / 7
------------------------------------------------------------------------Delay:
Source:
A (PAD)
Destination:
nor2 (PAD)
Net
---------------------------------------- -----------IBUF:I->O
LUT2:I0->O
OBUF:I->O
---------------------------------------Total
a. Half adder:
Verilog module:
module halfadd(a,b,sum,cy);
input a,b;
output sum,cy;
assign sum = a ^ b;
assign cy = a & b;
endmodule
4
Simulated Waveform:
Selected Device
: 3s400tq144-4
Number of Slices
: 1 out of 4656
0%
: 2 out of 9312
0%
Number of IOs
:4
: 4 out of 158
2%
Timing Detail:
Timing constraint: Default path analysis
Total number of paths / destination ports: 4 / 2
------------------------------------------------------------------------Delay:
Source:
Destination:
Data Path: a to cy
Gate
Cell:in->out
Net
---------------------------------------- -----------IBUF:I->O
2 1.106 0.532
a_IBUF (a_IBUF)
LUT2:I0->O
1 0.612 0.357
cy1 (cy_OBUF)
OBUF:I->O
3.169
cy_OBUF (cy)
---------------------------------------Total
RTL Schematic:
b. Full Adder:
Verilog Module:
module fuladd(a,b,c, sum,cy);
input a,b,c;
output sum,cy;
assign sum = (a^b)^c;
assign cy = (a&b)|(b&c)|(a&c);
endmodule
Simulated Waveform:
RTL Schematic:
: 3s400tq144-4
Number of Slices
: 1 out of 4656
0%
: 2 out of 9312
0%
Number of IOs
:5
: 5 out of 158
3%
Timing Detail:
Timing constraint: Default path analysis
Total number of paths / destination ports: 6 / 2
------------------------------------------------------------------------Delay:
Source:
Destination:
cy (PAD)
Data Path: b to cy
Gate
Cell:in->out
Net
---------------------------------------- -----------IBUF:I->O
1.106
LUT3:I0->O
OBUF:I->O
---------------------------------------Total
c. Half Subtractor:
Verilog Module:
module halfsub(a,b,diff,borr);
input a,b;
output diff,borr;
assign diff = a ^ b;
assign borr = (~a) & b;
endmodule
Simulated waveform:
: 3s400tq144-4
Number of Slices
: 1 out of 4656
0%
: 2 out of 9312
0%
Number of IOs
:4
: 4 out of 158
2%
Timing Detail:
Timing constraint: Default path analysis
Total number of paths / destination ports: 4 / 2
------------------------------------------------------------------------Delay:
Source:
Destination:
Net
---------------------------------------- -----------IBUF:I->O
2 1.106 0.532
a_IBUF (a_IBUF)
LUT2:I0->O
1 0.612 0.357
borr1 (borr_OBUF)
OBUF:I->O
3.169
borr_OBUF (borr)
---------------------------------------Total
RTL Schematic:
11
d. Full Subtractor:
Verilog Module:
module fullsub(a,b,c,diff,borr);
input a,b,c;
output diff,borr;
assign diff=(a^b)^c;
assign borr = ((~(a^b))&c)|((~a)&b);
endmodule
Simulated Waveform:
: 3s400tq144-4
Number of Slices
: 1 out of 4656
0%
: 2 out of 9312
0%
Number of IOs
:5
: 5 out of 158
12
3%
Timing Detail:
Timing constraint: Default path analysis
Total number of paths / destination ports: 6 / 2
------------------------------------------------------------------------Delay:
Source:
z (PAD)
Destination:
borr (PAD)
Net
---------------------------------------- -----------IBUF:I->O
2 1.106 0.532
z_IBUF (z_IBUF)
LUT3:I0->O
1 0.612 0.357
borr1 (borr_OBUF)
OBUF:I->O
3.169
borr_OBUF (borr)
---------------------------------------Total
RTL Schematic:
13
14
: 3s400tq144-4
Number of Slices
: 4 out of 4656
0%
: 8 out of 9312
0%
Number of IOs
: 14
: 14 out of 158
8%
Timing Detail:
Timing constraint: Default path analysis
Total number of paths / destination ports: 33 / 5
------------------------------------------------------------------------Delay:
Source:
b<0> (PAD)
Destination:
cout (PAD)
15
Gate
Cell:in->out
Net
---------------------------------------- -----------IBUF:I->O
2 1.106 0.532
b_0_IBUF (b_0_IBUF)
LUT3:I0->O
2 0.612 0.449
f1/cy1 (w<0>)
LUT3:I1->O
2 0.612 0.449
f2/cy1 (w<1>)
LUT3:I1->O
2 0.612 0.449
f3/cy1 (w<2>)
LUT3:I1->O
1 0.612 0.357
f4/cy1 (cout_OBUF)
OBUF:I->O
3.169
cout_OBUF (cout)
---------------------------------------Total
RTL Schematic:
16
17
Verilog Module:
module fourbit(a,b,cin,s,cout);
input [0:3] a,b; input cin;
output [0:3]s;
output cout;
wire [0:3]w;
xor x1(w[0],b[0],cin),
x2(w[1],b[1],cin),
x3(w[2],b[2],cin),
x4(w3],b[3],cin);
parallel_adder p1(a,w,cin,s,cout);
endmodule
Simulated Output:
18
Selected Device
: 3s400tq144-4
Number of Slices
: 4 out of 4656
0%
: 8 out of 9312
0%
Number of IOs
: 14
: 14 out of 158
8%
Timing Detail:
Net
---------------------------------------- -----------IBUF:I->O
7 1.106 0.671
cin_IBUF (cin_IBUF)
LUT3:I1->O
2 0.612 0.383
p1/f1/cy1 (p1/w<0>)
LUT4:I3->O
2 0.612 0.383
p1/f2/cy1 (p1/w<1>)
LUT4:I3->O
2 0.612 0.383
p1/f3/cy1 (p1/w<2>)
LUT4:I3->O
1 0.612 0.357
p1/f4/cy1 (cout_OBUF)
OBUF:I->O
3.169
cout_OBUF (cout)
---------------------------------------Total
RTL Schematic:
20
21
22
Simulated Output:
23
Selected Device
: 3s400tq144-4
Number of Slices
: 5 out of 4656
0%
: 9 out of 9312
0%
Number of IOs
: 11
: 11 out of 158
6%
Timing Detail:
Source:
Destination:
a<3> (PAD)
x (PAD)
Net
---------------------------------------- -----------IBUF:I->O
5 1.106 0.690
a_3_IBUF (a_3_IBUF)
LUT4:I0->O
1 0.612 0.426
x453 (x4_map21)
LUT2:I1->O
1 0.612 0.357
x454 (x_OBUF)
OBUF:I->O
3.169
x_OBUF (x)
---------------------------------------Total
24
RTL Schematic:
25
Verilog Module:
module paritygen(x,y,z,p,c);
input x,y,z;
inout p;
output c;
wire w1,w2,w3;
xor x1(w1,x,y),x2(w2,w1,z);
not n1(p,w2);
xor x3(w3,w2,p);
not n2(c,w3);
endmodule
Simulated Output:
26
: 3s400tq144-4
Number of Slices
: 1 out of 4656
0%
: 1 out of 9312
0%
Number of IOs
:5
: 5 out of 158
3%
Timing Detail:
Timing constraint: Default path analysis
Total number of paths / destination ports: 3 / 1
------------------------------------------------------------------------Delay:
Source:
y (PAD)
Destination:
p (PAD)
Data Path: y to p
Gate
Cell:in->out
Net
---------------------------------------- -----------IBUF:I->O
1 1.106
0.509
y_IBUF (y_IBUF)
LUT3:I0->O
1 0.612
0.357
p1 (p_OBUF)
3.169
p_OBUF (p)
OBUF:I->O
---------------------------------------Total
RTL Schematic:
27
Verilog Module:
module multi(m,a,b);
input [0:1]a,b;
output [0:3] m;
wire [0:3]w;
and a1(m[0],a[0],b[0]),
a2(w[0],a[1],b[1]),
a3(w[1],a[0],b[1]),
a4(w[2],a[1],b[1]);
halfadd h1(m[1],w[3],w[0],w[1]),
h2(m[2],m[3],w[3],[w2]);
endmodule
28
Simulated Output:
Selected Device
: 3s400tq144-4
Number of Slices
: 1 out of 4656
0%
: 1 out of 9312
0%
Number of IOs
:8
: 6 out of 158
29
3%
Timing Detail:
Net
------------------------------------------------------------------------------IBUF:I->O
LUT2:I0->O
OBUF:I->O
Total
RTL Schematic:
30
31
Verilog Module:
module bingray(a,b,c,d,w,x,y,z);
input a,b,c,d;
output w,x,y,z;
buf b1(w,a);
xor x1(x,a,b),
x2(y,b,c),
x3(z,c,d);
endmodule
Simulated Output:
32
Selected Device
: 3s400tq144-4
Number of Slices
: 2 out of 4656
0%
: 3 out of 9312
0%
Number of IOs
:8
: 8 out of 158
5%
Timing Detail:
Timing constraint: Default path analysis
Total number of paths / destination ports: 7 / 4
Delay:
Source:
Destination:
Data Path: b to x
Gate Net
Cell:in->out
fanout
-----------------------------------------------------------------------------------IBUF:I->O
LUT2:I0->O
OBUF:I->O
Total
RTL Schematic:
33
34
Simulated Output:
: 3s400tq144-4
Number of Slices
: 2 out of 4656
0%
: 3 out of 9312
0%
Number of IOs
:8
: 8 out of 158
35
5%
Timing Detail:
Timing constraint: Default path analysis
Total number of paths / destination ports: 10 / 4
------------------------------------------------------------------------Delay:
Source:
b (PAD)
Destination:
x (PAD)
Data Path: b to x
Gate
Cell:in->out
Net
---------------------------------------- -----------------------------------------IBUF:I->O
1.106 0.603
b_IBUF (b_IBUF)
LUT2:I0->O
0.612 0.357
Mxor_x_Result1 (x_OBUF)
OBUF:I->O
3.169
x_OBUF (x)
----------------------------------------------------------------------------------Total
RTL Schematic:
36
37
Multiplexer
Verilog Module:
module mux(en,a,sel,y);
input en;
input [3:0]a;
input [1:0]sel;
output y;
reg y;
always@(en or a)
begin
if(!en)
y = 1'b0;
else case(sel)
2'b00: y=a[0];
2'b01: y=a[1];
2'b10: y=a[2];
2'b11: y=a[3];
endcase
end
endmodule
Simulated Output:
38
RTL Schematic:
Selected Device
: 3s400tq144-4
Number of Slices
: 1 out of 4656
0%
: 2 out of 9312
0%
Number of IOs
:8
: 8 out of 158
5%
Timing Detail:
Source:
Destination:
sel<0> (PAD)
y (PAD)
Net
---------------------------------------- -----------IBUF:I->O
1.106
0.532
LUT4:I0->O
0.612 0.000
sel_0_IBUF (sel_0_IBUF)
y_F (N6)
39
MUXF5:I0->O 1
0.278 0.357
y (y_OBUF)
3.169
y_OBUF (y)
OBUF:I->O
---------------------------------------Total
RTL Schematic:
40
Decoder
Verilog Module:
module decoder(en, ain, yout);
input en;
input [0:1] ain;
output [0:3] yout;
reg [0:3] yout;
always@(en or ain)
begin
if(!en)
yout = 4'b0;
else
case (ain)
2'b00: yout = 4'b0001;
2'b01: yout = 4'b0010;
2'b10: yout = 4'b0100;
2'b11: yout = 4'b1000;
endcase
end
endmodule
Simulated output:
41
Selected Device:
3s400tq144-4
Number of Slices:
2 out of 3584
0%
4 out of 7168
0%
Number of IOs:
7 out of
97
7%
RTL Schematic:
42
Timing Details:
Delay:
Source:
en (PAD)
Destination:
yout<0> (PAD)
Net
---------------------------------------------------------------------------------IBUF:I->O
LUT3:I0->O
OBUF:I->O
---------------------------------------------------------------------------------Total
43
a. Encoder
Verilog Module:
module encoder(en, ain, out);
input en;
input [0:7] ain;
output [0:2] out;
reg [0:2] out;
always @(en or ain)
begin
if(!en)
out = 3'b0;
else
case(ain)
8'b00000001:out = 3'b000;
8'b00000010:out = 3'b001;
8'b00000100:out = 3'b010;
8'b00001000:out = 3'b011;
8'b00010000:out = 3'b100;
8'b00100000:out = 3'b101;
8'b01000000:out = 3'b110;
8'b10000000:out = 3'b111;
default:out = 3'b000;
endcase
end
endmodule
44
Simulated output:
45
RTL Schematic:
Sub Section:
46
Selected Device :
3s400tq144-4
Number of Slices:
4 out of 3584
0%
8 out of 7168
0%
Number of IOs:
12
12 out of
97 12%
Timing Details:
Delay:
Source:
Destination:
ain<0> (PAD)
out<0> (PAD)
Net
------------------------------------------------------------------------------------IBUF:I->O
LUT4:I0->O
LUT4:I3->O
LUT3:I1->O
OBUF:I->O
-------------------------------------------------------------------------------Total
Verilog Module:
module halfmux(a,b, sum,cy);
input a,b;
output sum,cy;
wire [0:1] w;
assign w = {a,b};
mux m1(0,1,1,0,w,sum),m2(0,0,0,1,w,cy);
endmodule
Mux Module:
module halfmux(a,b, sum,cy);
input a,b;
output sum,cy;
wire [0:1] w;
assign w = {a,b};
mux m1(0,1,1,0,w,sum),m2(0,0,0,1,w,cy);
endmodule
48
Simulated Output:
RTL Schematic:
: 3s400tq144-4
Number of Slices
: 1 out of 3584
0%
: 2 out of 7168
0%
Number of IOs
:4
: 4 out of
97
49
4%
Timing Detail:
Delay:
Source:
Destination:
cy (PAD)
Data Path: b to cy
Gate
Cell:in->out
Net
---------------------------------------- -----------IBUF:I->O
0.821 1.216
b_IBUF (b_IBUF)
LUT2:I0->O
0.551 0.801
m2/Mmux_y11 (cy_OBUF)
OBUF:I->O
5.644
cy_OBUF (cy)
---------------------------------------Total
a. JK Flip Flop
Verilog Module:
module jkff(q,qbar,j,k,clk);
output q,qbar;
input j,k,clk;
reg q=1'b0;
always @(negedge clk)
if(j==0&&k==0)
q=q;
else if(j==0&&k==1)
q = 0;
50
else if(j==1&&k==0)
q = 1;
else
q=~q;
end
assign qbar = ~q;
endmodule
Simulated Output:
51
RTL Schematic:
: 3s400tq144-4
Number of Slices
: 2 out of 2448
0%
0%
: 3 out of 4896
0%
Number of IOs
:5
: 5 out of 158
3%
Number of GCLKs
: 1 out of
4%
24
Timing Detail:
Timing constraint: Default period analysis for Clock 'clk'
Clock period: 1.875ns (frequency: 533.234MHz)
Total number of paths / destination ports: 1 / 1
------------------------------------------------------------------------Delay:
Source:
q (FF)
52
Source Clock:
Data Path: q to q
Gate
Cell:in->out
Net
---------------------------------------- -----------FDE_1:C->Q
3 0.514 0.481
q (q_OBUF)
LUT3:I2->O
1 0.612 0.000
q_mux00001 (q_mux0000)
FDE_1:D
0.268
---------------------------------------Total
b. T Flip Flop
Verilog Module:
module tff(q,qbar,t,clk);
output q,qbar;
input t,clk;
reg q = 0;
always @(posedge clk)
if(t)
q = ~q;
else
q = q;
assign qbar = ~q;
endmodule
53
Simulated Output:
RTL Schematic:
54
Selected Device
: 3s400tq144-4
Number of Slices
: 1 out of 2448
0%
0%
: 1 out of 4896
0%
Number of IOs
:4
: 4 out of 158
2%
Number of GCLKs
: 1 out of
4%
24
Timing Detail:
Timing constraint: Default period analysis for Clock 'clk'
Clock period: 2.154ns (frequency: 464.274MHz)
Total number of paths / destination ports: 1 / 1
------------------------------------------------------------------------Delay:
Source:
q (FF), Destination:
Source Clock:
q (FF)
Data Path: q to q
Gate
Cell:in->out
Net
---------------------------------------- -----------FDE:C->Q
2 0.514 0.380
q (q_OBUF)
INV:I->O
2 0.612 0.380
qbar1_INV_0 (qbar_OBUF)
FDE:D
Total
0.268
55
c. D Flip Flop
Verilog Module:
module dff(q,d,clk);
input d,clk;
output q;
reg q;
always @(posedge clk)
q = d;
endmodule
Simulated Output:
56
RTL Schematic:
: 3s400tq144-4
Number of Slices
: 1 out of 2448
0%
0%
: 1 out of 4896
0%
Number of IOs
:4
: 4 out of 158
2%
:2
Number of GCLKs
: 1 out of
24
4%
Timing Detail:
Timing constraint: Default OFFSET IN BEFORE for Clock 'clk'
Total number of paths / destination ports: 2 / 2
------------------------------------------------------------------------Offset:
Source:
Destination:
Net
---------------------------------------- -----------IBUF:I->O
FD:D
0.268
---------------------------------------Total
Verilog Module:
module shiftreg(d,clk,z);
input d,clk;
output z;
parameter NUM = 4;
reg [1:NUM]q;
integer p;
always @(negedge clk)
begin
for(p=1;p<NUM;p=p+1)
q[p+1] = q[p];
q[1]=d;
end
assign z=q[NUM];
endmodule
58
Simulated Output:
RTL Schematic:
: 3s400tq144-4
Number of Slices
: 1 out of 2448
0%
: 1 out of 4896
0%
: 1 out of 4896
0%
:0
:1
Number of IOs
:3
: 3 out of 158
1%
Number of GCLKs
: 1 out of
4%
59
24
Timing Detail:
Net
---------------------------------------- -----------SRL16_1:CLK->Q
FD_1:D
0.268
q_4
---------------------------------------Total
60
a. Down Counter:
Verilog Module:
module downcounter(q,clk);
output [0:3]q;
input clk;
wire w2,w3,w4,w5,w6;
not n1(w4,q[1]),
n2(w5,q[2]),
n3(w6,q[3]);
and a1(w2,w5,w6),
a2(w3,w2,w4);
tff t0(q[3],1,clk),
t1(q[2],w6,clk),
t2(q[1],w2,clk),
t3(q[0],w3,clk);
endmodule
TFF:
module tff(q,qbar,t,clk);
output q,qbar;
input t,clk;
reg q = 0;
always @(posedge clk)
if(t)
q = ~q;
else
q = q;
assign qbar = ~q;
endmodule
61
Simulated Output:
RTL Schematic:
62
Selected Device
: 3s400tq144-4
Number of Slices
: 3 out of 2448
0%
0%
: 6 out of 4896
0%
Number of IOs
:5
: 5 out of 158
3%
Number of GCLKs
: 1 out of
4%
24
Timing Detail:
t2/q (FF)
63
Net
---------------------------------------- -----------FDE:C->Q
LUT2:I0->O
FDE:CE
0.483
t2/q
---------------------------------------Total
b. UP Counter:
Verilog Module:
module upcounter(q,clk);
output [0:3]q;
input clk;
wire w2,w3;
and a1(w2,q[2],q[3]),
a2(w3,w2,q[1]);
tff t0(q[3],,1,clk),
t1(q[2],,q[3],clk),
t2(q[1],,w2,clk),
t3(q[0],,w3,clk);
endmodule
64
TFF:
module tff(q,qbar,t,clk);
output q,qbar;
input t,clk;
reg q = 0;
always @(posedge clk)
if(t)
q = ~q;
else
q = q;
assign qbar = ~q;
endmodule
Simulated Output:
65
RTL Schematic:
Selected Device
: 3s400tq144-4
Number of Slices
: 3 out of 2448
0%
0%
: 6 out of 4896
0%
Number of IOs
:5
: 5 out of 158
3%
Number of GCLKs
: 1 out of
4%
24
66
Timing Detail:
Source:
Source Clock:
t2/q (FF)
Net
---------------------------------------- -----------FDE:C->Q
LUT2:I0->O
FDE:CE
0.483
Total
t2/q
67
Verilog Module:
module asdowncounter(q,clk);
output [3:0]q;
input clk;
tff t0(q[0],1,clk),
t1(q[1],1,q[0]),
t2(q[2],1,q[1]),
t3(q[3],1,q[2]);
endmodule
TFF:
module tff(q,qbar,t,clk);
output q,qbar;
input t,clk;
reg q = 0;
always @(posedge clk)
if(t)
q = ~q;
else
q = q;
assign qbar = ~q;
endmodule
Simulated Output:
68
RTL Schematic:
69
Selected Device
: 3s400tq144-4
Number of Slices
: 2 out of 2448
0%
0%
: 4 out of 4896
0%
Number of IOs
:5
: 5 out of 158
Number of GCLKs
: 1out of
24
3%
4%
Timing Detail:
Net
---------------------------------------- -----------FDE:C->Q
INV:I->O
FDE:D
Total
t3/q
70
71
Verilog Module:
module real_time_clk(clk,clear,hour1,hour2,minute1,minute2,second1, second2, hour_A2,
min_A1,sec_A0,load,data_in);
input clk,clear;
output reg [6:0]hour1,hour2,minute1,minute2,second1,second2;
input load; input hour_A2,min_A1,sec_A0;
input [7:0]data_in;
reg clk_sec,clk_msec;
reg [7:0]sec,min,hr;
integer timer_count1=0,timer_count2=0;
always@(posedge clk)
begin
if(timer_count1==3999)
begin
timer_count1=0; clk_msec=1'b1;
end
else
begin
timer_count1=timer_count1+1;
clk_msec=1'b0;
end
end
always@(posedge clk_msec)
begin
if(timer_count2==999)
begin
timer_count2=0;
clk_sec=1'b1;
end
else
begin
timer_count2=timer_count2+1;
clk_sec=1'b0;
72
end
end
always@(negedge clk_sec)
begin
if(~clear)
begin
sec=0;
min=0;
hr=0;
end
else
if(~load)
begin
if(hour_A2)
begin
if(hr[7:4] == 4'b0010)
begin
if(hr[3:0] < 4'b0100)
hr = data_in;
end
else if(hr[7:4] < 4'b0010)
hr = data_in;
else
hr = 8'b0;
end
if(min_A1)
begin
if(min[7:4] < 4'b0110)
min = data_in;
else
min = 8'b0;
end
if(sec_A0)
begin
73
end
else
sec[7:4]=sec[7:4]+1;
end
else
sec[3:0]=sec[3:0]+1; //seconds count completed
end
end
always@(sec)
begin
case (sec[3:0])
4'b0000: second1=7'b1111110;
4'b0001: second1=7'b0110000;
4'b0010: second1=7'b1101101;
4'b0011: second1=7'b1111001;
4'b0100: second1=7'b0110011;
4'b0101: second1=7'b1011011;
4'b0110: second1=7'b1011111;
4'b0111: second1=7'b1110000;
4'b1000: second1=7'b1111111;
4'b1001: second1=7'b1111011;
default: second1=7'b0;
endcase
end
always@(sec)
begin
case(sec[7:4])
4'b0000: second2=7'b1111110;
4'b0001: second2=7'b0110000;
4'b0010: second2=7'b1101101;
4'b0011: second2=7'b1111001;
4'b0100: second2=7'b0110011;
4'b0101: second2=7'b1011011;
4'b0110: second2=7'b1011111;
4'b0111: second2=7'b1110000;
75
4'b1000: second2=7'b1111111;
4'b1001: second2=7'b1111011;
default: second2=7'b0;
endcase
end
always@(min)
begin
case(min[3:0])
4'b0000: minute1=7'b1111110;
4'b0001: minute1=7'b0110000;
4'b0010: minute1=7'b1101101;
4'b0011: minute1=7'b1111001;
4'b0100: minute1=7'b0110011;
4'b0101: minute1=7'b1011011;
4'b0110: minute1=7'b1011111;
4'b0111: minute1=7'b1110000;
4'b1000: minute1=7'b1111111;
4'b1001: minute1=7'b1111011;
default: minute1=7'b0;
endcase
end
always@(min)
begin
case(min[7:4])
4'b0000: minute2=7'b1111110;
4'b0001: minute2=7'b0110000;
4'b0010: minute2=7'b1101101;
4'b0011: minute2=7'b1111001;
4'b0100: minute2=7'b0110011;
4'b0101: minute2=7'b1011011;
4'b0110: minute2=7'b1011111;
4'b0111: minute2=7'b1110000;
76
4'b1000: minute2=7'b1111111;
4'b1001: minute2=7'b1111011;
default: minute2=7'b0;
endcase
end
always@(hr)
begin
case(hr[3:0])
4'b0000: hour1=7'b1111110;
4'b0001: hour1=7'b0110000;
4'b0010: hour1=7'b1101101;
4'b0011: hour1=7'b1111001;
4'b0100: hour1=7'b0110011;
4'b0101: hour1=7'b1011011;
4'b0110: hour1=7'b1011111;
4'b0111: hour1=7'b1110000;
4'b1000: hour1=7'b1111111;
4'b1001: hour1=7'b1111011;
default: hour1=7'b0;
endcase
end
always@(hr)
begin
case(hr[7:4])
4'b0000: hour2=7'b1111110;
4'b0001: hour2=7'b0110000;
4'b0010: hour2=7'b1101101;
4'b0011: hour2=7'b1111001;
4'b0100: hour2=7'b0110011;
4'b0101: hour2=7'b1011011;
4'b0110: hour2=7'b1011111;
4'b0111: hour2=7'b1110000;
77
4'b1000: hour2=7'b1111111;
4'b1001: hour2=7'b1111011;
default: hour2=7'b0;
endcase
end
endmodule
Simulated Output:
78
RTL Schematic:
Counter Section:
79
Sub Section:
Sub Section:
Sub Section:
Selected Device
: 3s400tq144-4
Number of Slices
: 58 out of 2448
2%
0%
Number of IOs
: 56
Number of GCLKs
: 1 out of
24
80
4%
2%
Timing Detail:
Source:
Destination:
hr_3 (FF)
hr_6 (FF)
Source Clock:
clk falling
Net
---------------------------------------- -----------FDRE_1:C->Q
11 0.514 0.945
hr_3 (hr_3)
LUT3:I0->O
2 0.612 0.383
hr_7_cmp_eq0001_SW0_SW0 (N375)
LUT4:I3->O
8 0.612 0.646
hr_7_cmp_eq0001 (hr_7_cmp_eq0001)
hr_7_not000120_SW0 (N393)
LUT4:I3->O
4 0.612 0.499
hr_7_not000120 (hr_7_not0001)
FDRE_1:CE
0.483
hr_6
---------------------------------------Total
81
83
Verilog Module:
module traffic_verilog(seg_1,seg_2,R1,R2,R3,G1,G2,G3,Y1,Y2,Y3,PR,PG,clk,rst);
output reg R1,R2,R3,G1,G2,G3,Y1,Y2,Y3,PR,PG;
output reg [6:0]seg_1,seg_2;
input clk,rst;
integer timer_count1 = 0,timer_count2 = 0;
reg clk_msec,clk_sec;
reg [7:0]count;
reg [1:0]state = 2'b0;
always@(posedge clk)
begin
if(timer_count1==3999)
begin
timer_count1=0;
clk_msec=1'b1;
end
else
begin
timer_count1=timer_count1+1;
clk_msec=1'b0;
end
end
always@(posedge clk_msec)
begin
if(timer_count2==999)
begin
timer_count2=0;
clk_sec=1'b1;
end
else
begin
timer_count2=timer_count2+1;
clk_sec=1'b0;
84
end
end
always@(posedge clk_sec)
begin
if(~rst)
begin
R1 = 1'b1; G1 = 1'b0; Y1 = 1'b0;
R2 = 1'b1; G2 = 1'b0; Y2 = 1'b0;
R3 = 1'b1; G3 = 1'b0; Y3 = 1'b0;
state=2'b00;
end
else
begin
case(state)
2'b00://SIGNAL AT SIGNAL LIGHTS ONE
begin
if(count==8'b00100101)
begin
R1 = 1'b0; G1 = 1'b1; Y1 = 1'b0;
end
if(count==8'b00101001)
begin
G1 = 1'b1; Y1 = 1'b0;
state=2'b01;
end
else
state=2'b00;
end
else
state=2'b11;
end
endcase
end
end
count[3:0]=count[3:0]+1;
end
end
always@(count)
begin
case(count[3:0])
4'b0000:seg_1 = 8'b1111110; //0
4'b0001:seg_1 = 8'b0110000; //1
4'b0010:seg_1 = 8'b1101101; //2
4'b0011:seg_1 = 8'b1111001; //3
4'b0100:seg_1 = 8'b0110011; //4
4'b0101:seg_1 = 8'b1011011; //5
4'b0110:seg_1 = 8'b1011111; //6
4'b0111:seg_1 = 8'b1110000; //7
4'b1000:seg_1 = 8'b1111111; //8
4'b1001:seg_1 = 8'b1111011; //9
default:seg_1 = 8'b0000000; //off
endcase
case(count[7:4])
4'b0000:seg_2 = 8'b1111110; //0
4'b0001:seg_2 = 8'b0110000; //1
4'b0010:seg_2 = 8'b1101101; //2
4'b0011:seg_2 = 8'b1111001; //3
4'b0100:seg_2 = 8'b0110011; //4
4'b0101:seg_2 = 8'b1011011; //5
4'b0110:seg_2 = 8'b1011111; //6
4'b0111:seg_2 = 8'b1110000; //7
4'b1000:seg_2 = 8'b1111111; //8
4'b1001:seg_2 = 8'b1111011; //9
default:seg_2 = 8'b0000000; //off
endcase
end
endmodule
88
RTL Schematic:
Simulated Output:
89
: 3s400tq144-4
Number of Slices
: 71 out of 3584
1%
1%
Number of IOs
: 27
: 27 out of
97 27%
Number of GCLKs
: 2 out of
8 25%
1%
91
Verilog Module:
module serial_AS_verilog(clk,addr,load,clear,data_in,calc,result);
input clk,clear,calc,load;
input [3:0]addr;
input [11:0]data_in;
output reg [11:0]result;
reg [11:0]ram[7:0];
reg [11:0]temp;
reg [2:0]count = 3'b000;
always@(negedge clk)
begin
if(clk)
case(count)
3'b000: begin
temp = ram[0] + ram[1];
count = count + 1'b1;
end
3'b001: begin
temp = (temp + ram[2]);
count = 3'b010;
end
3'b010: begin
temp = (temp + ram[3]);
count = 3'b011;
end
3'b011: begin
temp = (temp + ram[4]);
count = 3'b100;
end
3'b100: begin
temp = (temp + ram[5]);
count = 3'b101;
end
3'b101: begin
92
93
Procedure:
Download the programme into FPGA kit and connect the FRC connectors as specified. On
card1 load the 12bit numbers by using the switches SW0 to SW11 and selection of 8
numbers are made one by one by selecting lines assigned A0, A1,\, A2 and after selecting
each 12 bit number by pressing the LOAD switch you can enter the values. For each
locations of 8 numbers and after loading all values keep pressing CALC switch the result
can be verified by LEDs on board.
Selected Device
: 3s400tq144-4
Number of Slices
3%
1%
2%
Number of IOs
: 32
: 31 out of
97 31%
Number of GCLKs
: 1 out of
8 12%
94
RTL SCHEMATIC:
Timing Detail:
All values displayed in nanoseconds (ns)
Timing constraint: Default period analysis for Clock 'clk'
Clock period: 15.412ns (frequency: 64.884MHz)
Total number of paths / destination ports: 2801 / 27
------------------------------------------------------------------------Delay:
Source:
Destination:
Source Clock:
ram_2_0 (FF)
temp_11 (FF)
clk rising
Net
---------------------------------------- -----------FDRE:C->Q
LUT3:I1->O
95
MUXF5:I0->O
(temp_mux0001<0>1_map11)
LUT4:I3->O
LUT4:I3->O
MUXCY:S->O
(Madd_temp_mux0000_cy<0>)
MUXCY:CI->O
(Madd_temp_mux0000_cy<1>)
MUXCY:CI->O
(Madd_temp_mux0000_cy<2>)
MUXCY:CI->O
(Madd_temp_mux0000_cy<3>)
MUXCY:CI->O
(Madd_temp_mux0000_cy<4>)
MUXCY:CI->O
(Madd_temp_mux0000_cy<5>)
MUXCY:CI->O
(Madd_temp_mux0000_cy<6>)
MUXCY:CI->O
(Madd_temp_mux0000_cy<7>)
MUXCY:CI->O
(Madd_temp_mux0000_cy<8>)
MUXCY:CI->O
(Madd_temp_mux0000_cy<9>)
MUXCY:CI->O
(Madd_temp_mux0000_cy<10>)
XORCY:CI->O
(temp_mux0000<11>)
FDE_1:D
0.203
temp_11
---------------------------------------Total
96
Source:
addr<0> (PAD)
Destination:
result_4 (FF)
Net
---------------------------------------- -----------IBUF:I->O
LUT3:I0->O
MUXF5:I1->O
MUXF6:I1->O
LUT4:I2->O
MUXF5:I0->O
FDE:D
Total
result_10
================================================================
Timing constraint: Default OFFSET OUT AFTER for Clock 'clk'
Total number of paths / destination ports: 12 / 12
Offset:
Source:
Destination:
Source Clock:
Net
---------------------------------------- -----------FDE:C->Q
OBUF:I->O
result_11_OBUF (result<11>)
---------------------------------------Total
98
Connections:
1. Connect FRC 1 of main board connector to CN8 of Card1.
2. Connect FRC 2 of main board connector to CN7 of Card1.
3. Connect FRC 7 of main board connector to CN6 of Card1.
4. Connect FRC 6 of main board connector to CN5 of Card1.
5. Connect FRC 4 of main board connector to CN4 of Card1.
6. Connect FRC 5 of main board connector to CN1 of Card1.
Verilog Code:
module parallel (clk, addr, load, clear, data_in, calc, result);
input clk, clear, calc, load;
input [2:0] addr;
input [11:0] data_in;
output reg[11:0] result;
reg [11:0]ram[7:0];
wire[11:0] temp;
always@(posedge clk)
begin
if(~clear)
begin
ram[0]=12b0;
ram[1]=12b0;
ram[2]=12b0;
ram[3]=12b0;
ram[4]=12b0;
ram[5]=12b0;
ram[6]=12b0;
ram[7]=12b0;
end
else if(!load)
ram[addr] =data_in;
end
99
assign temp = ram[0] + ram[1] + ram[2] + ram[3] + ram[4] + ram[5] + ram[6] + ram[7];
always@(posedge clk)
begin
if(~load)
result = data_in;
else if(~calc)
result=temp;
else
result=ram[addr];
end
endmodule
Simulated Output:
100
RTL Schematic:
101
Selected Device
: 3s400tq144-4
Number of Slices
3%
1%
2%
Number of IOs
: 31
: 31 out of
97 31%
Number of GCLKs
: 1 out of
8 12%
Clock Information:
Clock Signal
clk
| BUFGP
|108 |
Timing Detail:
Delay:
Source:
Destination:
ram_1_1 (FF)
result_11 (FF)
Source Clock:
clk rising
Net
---------------------------------------- -----------FDRE:C->Q
LUT3:I0->O
(Madd_temp_addsub0001C)
LUT4:I3->O
MUXCY:S->O
(Madd_temp_addsub0001_Madd_cy<2>)
MUXCY:CI->O
(Madd_temp_addsub0001_Madd_cy<3>)
MUXCY:CI->O
(Madd_temp_addsub0001_Madd_cy<4>)
102
MUXCY:CI->O
(Madd_temp_addsub0001_Madd_cy<5>)
XORCY:CI->O
(temp_addsub0001<6>)
LUT3:I2->O
(Madd_temp_addsub0003C5)
MUXCY:DI->O
(Madd_temp_addsub0003_Madd_cy<7>)
XORCY:CI->O
(temp_addsub0003<8>)
LUT3:I2->O
(Madd_temp_addsub0005C7)
MUXCY:DI->O
(Madd_temp_addsub0005_Madd_cy<9>)
XORCY:CI->O
(temp_addsub0005<10>)
LUT2:I1->O
MUXCY:S->O
XORCY:CI->O
LUT3:I2->O
FD:D
result_11
---------------------------------------Total
================================================================
Timing constraint: Default OFFSET IN BEFORE for Clock 'clk'
Total number of paths / destination ports: 806 / 300
------------------------------------------------------------------------Offset:
Source:
Destination:
103
Gate
Cell:in->out
Net
---------------------------------------- -----------IBUF:I->O
LUT3:I0->O
MUXF5:I1->O
MUXF6:I1->O
LUT4:I3->O
LUT3:I0->O
FD:D
0.203
result_10
---------------------------------------Total
================================================================
Timing constraint: Default OFFSET OUT AFTER for Clock 'clk'
Total number of paths / destination ports: 12 / 12
------------------------------------------------------------------------Offset:
Source:
Destination:
Source Clock:
Net
---------------------------------------- -----------FD:C->Q
OBUF:I->O
result_11_OBUF (result<11>)
---------------------------------------Total
104
Verilog Module:
module buffer(a, y);
input [0:7] a;
output [0:7] y;
reg[7:0] y;
always@(a)
begin
y = a;
end
endmodule
Simulated Output:
105
RTL Schematic:
Selected Device
: 3s400tq144-4
Number of Slices
: 0 out of 3584
Number of IOs
: 16
: 16 out of
0%
97 16%
106
Timing Detail:
Net
---------------------------------------- -----------IBUF:I->O
OBUF:I->O
---------------------------------------Total
108