Skip to content

Commit 7b0df44

Browse files
committed
Added Template Info
1 parent 812b68f commit 7b0df44

35 files changed

+3077
-96
lines changed

.hdl_checker/cache.json

Lines changed: 2280 additions & 0 deletions
Large diffs are not rendered by default.

Adders/FA.v

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
1+
////////////////////////////////////////////////////////////////////////
2+
//
3+
// Copyright (C) 2020 Akilesh Kannan <[email protected]>
4+
//
5+
// File: FA.v
6+
// Modified: 2020-07-16
7+
// Description: 1-Bit Full Adder module
8+
// - Uses primitives for sum and carry outputs
9+
//
10+
// License: MIT
11+
//
12+
////////////////////////////////////////////////////////////////////////
13+
14+
`default_nettype None
15+
16+
`timescale 1ns/1ps
17+
118
primitive carryOut (output Cout, input A, input B, input Cin);
2-
/* Truth Table for carry out */
19+
20+
// Truth Table for carry out
321
table
422
// A B Cin Cout
523
1 1 ? : 1 ;
@@ -12,7 +30,8 @@ primitive carryOut (output Cout, input A, input B, input Cin);
1230
endprimitive
1331

1432
primitive sumOut (output sum, input A, input B, input Cin);
15-
/* Truth Table for sum */
33+
34+
// Truth Table for sum
1635
table
1736
// A B Cin sum
1837
1 1 1 : 1 ;
@@ -27,7 +46,8 @@ primitive sumOut (output sum, input A, input B, input Cin);
2746
endprimitive
2847

2948
module FA(output Cout, output sum, input A, input B, input Cin);
30-
/* instantiating sum and carry primitives */
49+
50+
// instantiating sum and carry primitives
3151
sumOut s(sum, A, B, Cin);
3252
carryOut co(Cout, A, B, Cin);
3353
endmodule

Adders/HA.v

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
1+
////////////////////////////////////////////////////////////////////////
2+
//
3+
// Copyright (C) 2020 Akilesh Kannan <[email protected]>
4+
//
5+
// File: HA.v
6+
// Modified: 2020-07-16
7+
// Description: 1-Bit Half Adder Module
8+
//
9+
//
10+
// License: MIT
11+
//
12+
////////////////////////////////////////////////////////////////////////
13+
14+
`default_nettype None
15+
16+
`timescale 1ns/1ps
17+
118
primitive outSum(output sum, input A, input B);
2-
/* Truth Table for sum */
19+
20+
// Truth Table for sum
321
table
422
// A B sum
523
0 0 : 0 ;
@@ -10,7 +28,8 @@ primitive outSum(output sum, input A, input B);
1028
endprimitive
1129

1230
primitive outCarry(output carry, input A, input B);
13-
/* Truth Table for carry out */
31+
32+
// Truth Table for carry out
1433
table
1534
// A B carry
1635
0 0 : 0 ;
@@ -21,7 +40,8 @@ primitive outCarry(output carry, input A, input B);
2140
endprimitive
2241

2342
module HA (output carry, output sum, input A, input B);
24-
/* instantiating sum and carry primitives */
43+
44+
// instantiating sum and carry primitives
2545
outSum s(sum, A, B);
2646
outCarry c(carry, A, B);
2747
endmodule

Adders/nBitCarryLookAheadAdder.v

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,42 @@
1+
////////////////////////////////////////////////////////////////////////
2+
//
3+
// Copyright (C) 2020 Akilesh Kannan <[email protected]>
4+
//
5+
// File: nBitCarryLookAheadAdder.v
6+
// Modified: 2020-07-16
7+
// Description: N-Bit Carry Look Ahead Adder
8+
//
9+
//
10+
// License: MIT
11+
//
12+
////////////////////////////////////////////////////////////////////////
13+
14+
`default_nettype None
15+
16+
`timescale 1ns/1ps
17+
118
module nBitCarryLookAheadAdder #(parameter n = 4)(output[n:0] total, input[n-1:0] A, input[n-1:0] B);
19+
220
wire[n-1:0] gi, pi, sum;
321
wire[n:0] ci;
422

523
assign ci[0] = 1'b0;
24+
625
genvar i;
726
generate
8-
for(i = 0;i < n;i = i+1)
9-
begin: giAndpi
10-
assign gi[i] = A[i]&B[i];
11-
assign pi[i] = A[i]^B[i];
12-
assign ci[i+1] = gi[i]|(pi[i]&ci[i]);
13-
end
27+
for(i = 0;i < n;i = i+1) begin: giAndpi
28+
assign gi[i] = A[i]&B[i];
29+
assign pi[i] = A[i]^B[i];
30+
assign ci[i+1] = gi[i]|(pi[i]&ci[i]);
31+
end
1432
endgenerate
33+
1534
genvar j;
1635
generate
17-
for(j = 0;j < n;j = j+1)
18-
begin: calculation
19-
FA adder(.Cout(), .sum(sum[j]), .A(A[j]), .B(B[j]), .Cin(ci[j]));
20-
end
36+
for(j = 0;j < n;j = j+1) begin: calculation
37+
FA adder(.Cout(), .sum(sum[j]), .A(A[j]), .B(B[j]), .Cin(ci[j]));
38+
end
2139
endgenerate
40+
2241
assign total = {ci[n], sum[n-1:0]};
2342
endmodule

Adders/nBitRippleCarryAdder.v

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
1+
////////////////////////////////////////////////////////////////////////
2+
//
3+
// Copyright (C) 2020 Akilesh Kannan <[email protected]>
4+
//
5+
// File: nBitRippleCarryAdder.v
6+
// Modified: 2020-07-16
7+
// Description: N-Bit Ripple Carry Adder
8+
//
9+
//
10+
// License: MIT
11+
//
12+
////////////////////////////////////////////////////////////////////////
13+
14+
`default_nettype None
15+
16+
`timescale 1ns/1ps
17+
118
module nBitRippleCarryAdder #(parameter n = 4)(output[n:0] total, input[n-1:0] A, input[n-1:0] B);
19+
220
wire[n-1:0] carryMiddle, sum;
21+
322
genvar i;
423
generate
5-
for(i = 0;i < n;i = i+1)
6-
begin: genAdder
7-
if(i == 0)
8-
HA f(carryMiddle[0], sum[0], A[0], B[0]);
9-
else
10-
FA f(carryMiddle[i], sum[i], A[i], B[i], carryMiddle[i-1]);
11-
end
12-
assign total = {carryMiddle[n-1], sum[n-1:0]};
24+
for(i = 0;i < n;i = i+1) begin: genAdder
25+
if(i == 0)
26+
HA f(carryMiddle[0], sum[0], A[0], B[0]);
27+
else
28+
FA f(carryMiddle[i], sum[i], A[i], B[i], carryMiddle[i-1]);
29+
end
1330
endgenerate
31+
32+
assign total = {carryMiddle[n-1], sum[n-1:0]};
1433
endmodule

Counters/nBitCounter.v

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,37 @@
1+
////////////////////////////////////////////////////////////////////////
2+
//
3+
// Copyright (C) 2020 Akilesh Kannan <[email protected]>
4+
//
5+
// File: nBitCounter.v
6+
// Modified: 2020-07-16
7+
// Description: N-Bit Counter, with customisable increment
8+
//
9+
//
10+
// License: MIT
11+
//
12+
////////////////////////////////////////////////////////////////////////
13+
14+
`default_nettype None
15+
16+
`timescale 1ns/1ps
17+
118
module nBitCounter #(parameter n = 32, parameter inc = 1, parameter seed = 0) (output reg[n-1:0] count, input clk, input rst, input[n-1:0] pl, input load);
2-
/* initially set count to start/seed */
19+
20+
// initially set count to start/seed
321
initial begin
422
count = seed;
523
end
24+
625
always @ (posedge clk, rst, load) begin
7-
/* if load input is active, stop counting and take in the load */
26+
// if load input is active, stop counting and take in the load
827
if(load)
928
count = pl;
10-
/* if reset is active, reset to 0 */
29+
30+
// if reset is active, reset to 0
1131
else if(rst)
1232
count = 0;
13-
/* else, increment count by increment value */
33+
34+
// else, increment count by increment value
1435
else
1536
count = count + inc;
1637
end

Counters/nBitJohnsonCounter.v

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
1+
////////////////////////////////////////////////////////////////////////
2+
//
3+
// Copyright (C) 2020 Akilesh Kannan <[email protected]>
4+
//
5+
// File: nBitJohnsonCounter.v
6+
// Modified: 2020-07-16
7+
// Description: N-Bit Johnson Counter
8+
//
9+
//
10+
// License: MIT
11+
//
12+
////////////////////////////////////////////////////////////////////////
13+
14+
`default_nettype None
15+
16+
`timescale 1ns/1ps
17+
118
module nBitJohnsonCounter #(parameter integer n = 8) (output reg[n-1:0] JC, input clk);
2-
/* initially feed in 1 to register */
19+
20+
// initially feed in 1 to register
321
initial begin
422
JC = 1;
523
end
6-
/* every clock edge, shift the bit to right nd connect inverted o/p of last to i/p of first */
24+
25+
// every clock edge, shift the bit to right nd connect inverted o/p of last to i/p of first
726
always @(posedge clk) begin
827
JC = {~JC[0], JC[n-1:1]};
928
end

FFs/DFF/DFF.v

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
1+
////////////////////////////////////////////////////////////////////////
2+
//
3+
// Copyright (C) 2020 Akilesh Kannan <[email protected]>
4+
//
5+
// File: DFF.v
6+
// Modified: 2020-07-16
7+
// Description: D-Flip Flop
8+
// - No Clear
9+
//
10+
// License: MIT
11+
//
12+
////////////////////////////////////////////////////////////////////////
13+
14+
`default_nettype None
15+
16+
`timescale 1ns/1ps
17+
118
module DFF(output reg Q, input D, input clk);
2-
/* DFF is positive edge-triggered */
19+
// DFF is positive edge-triggered
320
always@(posedge clk) begin
421
Q <= D;
522
end

FFs/DFF/DFF_AsyncClear.v

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
1+
////////////////////////////////////////////////////////////////////////
2+
//
3+
// Copyright (C) 2020 Akilesh Kannan <[email protected]>
4+
//
5+
// File: DFF_AsyncClear.v
6+
// Modified: 2020-07-16
7+
// Description: D-Flip Flop
8+
// - Asynchronous Clear
9+
//
10+
// License: MIT
11+
//
12+
////////////////////////////////////////////////////////////////////////
13+
14+
`default_nettype None
15+
16+
`timescale 1ns/1ps
17+
118
module DFF_AsyncClear(output reg Q, input D, input clk, input clr);
2-
/* DFF is positive edge-triggered */
19+
20+
// DFF is positive edge-triggered
321
always @ (posedge clk, clr) begin
4-
/* if clr becomes 1, immediately clear FF o/p to 0*/
22+
// if clr becomes 1, immediately clear FF o/p to 0
523
if(clr)
624
Q <= 1'b0;
725
else

FFs/DFF/DFF_SyncClear.v

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
1+
////////////////////////////////////////////////////////////////////////
2+
//
3+
// Copyright (C) 2020 Akilesh Kannan <[email protected]>
4+
//
5+
// File: DFF_SyncClear.v
6+
// Modified: 2020-07-16
7+
// Description: D-Flip Flop
8+
// - Synchronous Clear
9+
//
10+
// License: MIT
11+
//
12+
////////////////////////////////////////////////////////////////////////
13+
14+
`default_nettype None
15+
16+
`timescale 1ns/1ps
17+
118
module DFF_SyncClear(output reg Q, input D, input clk, input clr);
2-
/* DFF is positive edge-triggered */
19+
20+
// DFF is positive edge-triggered
321
always @ (posedge clk) begin
4-
/* check if clr is 1, ONLY AT POSITIVE CLOCK EDGE, then clear o/p */
22+
// check if clr is 1, ONLY AT POSITIVE CLOCK EDGE, then clear o/p
523
if(clr)
624
Q = 1'b0;
725
else

FFs/JKFF/JKFF.v

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
1+
////////////////////////////////////////////////////////////////////////
2+
//
3+
// Copyright (C) 2020 Akilesh Kannan <[email protected]>
4+
//
5+
// File: JKFF.v
6+
// Modified: 2020-07-16
7+
// Description: J-K Flip Flop
8+
// - No clear
9+
//
10+
// License: MIT
11+
//
12+
////////////////////////////////////////////////////////////////////////
13+
14+
`default_nettype None
15+
16+
`timescale 1ns/1ps
17+
118
module JKFF (output reg Q, input J, input K, input clk);
19+
220
initial begin
321
Q = 0;
422
end
23+
524
always @ (posedge clk) begin
625
case({J,K})
726
2'b00: Q <= Q;

FFs/JKFF/JKFF_AsyncClear.v

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
1+
////////////////////////////////////////////////////////////////////////
2+
//
3+
// Copyright (C) 2020 Akilesh Kannan <[email protected]>
4+
//
5+
// File: JKFF_AsyncClear.v
6+
// Modified: 2020-07-16
7+
// Description: J-K Flip Flop
8+
// - Asynchronous clear
9+
//
10+
// License: MIT
11+
//
12+
////////////////////////////////////////////////////////////////////////
13+
14+
`default_nettype None
15+
16+
`timescale 1ns/1ps
17+
118
module JKFF_AsyncClear (output reg Q, input J, input K, input clr, input clk);
19+
220
initial begin
321
Q = 0;
422
end
23+
524
always @ (posedge clk, posedge clr) begin
625
if(clr)
726
Q <= 0;

0 commit comments

Comments
 (0)