Skip to content

Commit cc1a690

Browse files
committed
symbolgen
1 parent 886ec70 commit cc1a690

14 files changed

+6970
-4
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
bin
22
.DS_Store
3+
*.pyc
4+
Thumbs.db
5+
symbolgen/*.png

symbolgen/README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Verilog file to symbol PNG generator
2+
------------------------------------
3+
4+
symbolGen attempts to output the visual style from IEEE Symbol guidelines
5+
http://www.ddpp.com/DDPP3_pdf/IEEEsyms.pdf
6+
7+
8+
Setup for Win32
9+
---------------
10+
+ Python 2.7, pycairo 1.8.10, win32 gtk bundle
11+
12+
http://www.python.org/ftp/python/2.7.2/python-2.7.2.msi
13+
14+
http://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/1.8/
15+
http://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/1.8/pycairo-1.8.10.win32-py2.7.msi
16+
17+
http://www.gtk.org/download/win32.php
18+
19+
Unpack the bundle eg. to e:\gtk, then add e:\gtk\bin to path
20+
21+
+ pyparsing
22+
easy_install pyparsing
23+
24+
Setup for Linux
25+
---------------
26+
Ubuntu - it works out of the box.
27+
28+
29+
Verilog parser
30+
--------------
31+
32+
Copyright (c) 2004-2011 Paul T. McGuire. All rights reserved.
33+
34+
35+

symbolgen/hard/lm32_adder.v

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
// =============================================================================
2+
// COPYRIGHT NOTICE
3+
// Copyright 2006 (c) Lattice Semiconductor Corporation
4+
// ALL RIGHTS RESERVED
5+
// This confidential and proprietary software may be used only as authorised by
6+
// a licensing agreement from Lattice Semiconductor Corporation.
7+
// The entire notice above must be reproduced on all authorized copies and
8+
// copies may only be made to the extent permitted by a licensing agreement from
9+
// Lattice Semiconductor Corporation.
10+
//
11+
// Lattice Semiconductor Corporation TEL : 1-800-Lattice (USA and Canada)
12+
// 5555 NE Moore Court 408-826-6000 (other locations)
13+
// Hillsboro, OR 97124 web : http://www.latticesemi.com/
14+
// U.S.A email: [email protected]
15+
// ============================================================================/
16+
// FILE DETAILS
17+
// Project : LatticeMico32
18+
// File : lm32_adder.v
19+
// Title : Integer adder / subtractor with comparison flag generation
20+
// Dependencies : lm32_include.v
21+
// Version : 6.1.17
22+
// : Initial Release
23+
// Version : 7.0SP2, 3.0
24+
// : No Change
25+
// Version : 3.1
26+
// : No Change
27+
// =============================================================================
28+
29+
`include "lm32_include.v"
30+
31+
/////////////////////////////////////////////////////
32+
// Module interface
33+
/////////////////////////////////////////////////////
34+
35+
module lm32_adder (
36+
// ----- Inputs -------
37+
adder_op_x,
38+
adder_op_x_n,
39+
operand_0_x,
40+
operand_1_x,
41+
// ----- Outputs -------
42+
adder_result_x,
43+
adder_carry_n_x,
44+
adder_overflow_x
45+
);
46+
47+
/////////////////////////////////////////////////////
48+
// Inputs
49+
/////////////////////////////////////////////////////
50+
51+
input adder_op_x; // Operating to perform, 0 for addition, 1 for subtraction
52+
input adder_op_x_n; // Inverted version of adder_op_x
53+
input [`LM32_WORD_RNG] operand_0_x; // Operand to add, or subtract from
54+
input [`LM32_WORD_RNG] operand_1_x; // Opearnd to add, or subtract by
55+
56+
/////////////////////////////////////////////////////
57+
// Outputs
58+
/////////////////////////////////////////////////////
59+
60+
output [`LM32_WORD_RNG] adder_result_x; // Result of addition or subtraction
61+
wire [`LM32_WORD_RNG] adder_result_x;
62+
output adder_carry_n_x; // Inverted carry
63+
wire adder_carry_n_x;
64+
output adder_overflow_x; // Indicates if overflow occured, only valid for subtractions
65+
reg adder_overflow_x;
66+
67+
/////////////////////////////////////////////////////
68+
// Internal nets and registers
69+
/////////////////////////////////////////////////////
70+
71+
wire a_sign; // Sign (i.e. positive or negative) of operand 0
72+
wire b_sign; // Sign of operand 1
73+
wire result_sign; // Sign of result
74+
75+
/////////////////////////////////////////////////////
76+
// Instantiations
77+
/////////////////////////////////////////////////////
78+
79+
lm32_addsub addsub (
80+
// ----- Inputs -----
81+
.DataA (operand_0_x),
82+
.DataB (operand_1_x),
83+
.Cin (adder_op_x),
84+
.Add_Sub (adder_op_x_n),
85+
// ----- Ouputs -----
86+
.Result (adder_result_x),
87+
.Cout (adder_carry_n_x)
88+
);
89+
90+
/////////////////////////////////////////////////////
91+
// Combinational Logic
92+
/////////////////////////////////////////////////////
93+
94+
// Extract signs of operands and result
95+
96+
assign a_sign = operand_0_x[`LM32_WORD_WIDTH-1];
97+
assign b_sign = operand_1_x[`LM32_WORD_WIDTH-1];
98+
assign result_sign = adder_result_x[`LM32_WORD_WIDTH-1];
99+
100+
// Determine whether an overflow occured when performing a subtraction
101+
102+
always @(*)
103+
begin
104+
// +ve - -ve = -ve -> overflow
105+
// -ve - +ve = +ve -> overflow
106+
if ( (!a_sign & b_sign & result_sign)
107+
|| (a_sign & !b_sign & !result_sign)
108+
)
109+
adder_overflow_x = `TRUE;
110+
else
111+
adder_overflow_x = `FALSE;
112+
end
113+
114+
endmodule
115+

symbolgen/hard/lm32_addsub.v

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// =============================================================================
2+
// COPYRIGHT NOTICE
3+
// Copyright 2006 (c) Lattice Semiconductor Corporation
4+
// ALL RIGHTS RESERVED
5+
// This confidential and proprietary software may be used only as authorised by
6+
// a licensing agreement from Lattice Semiconductor Corporation.
7+
// The entire notice above must be reproduced on all authorized copies and
8+
// copies may only be made to the extent permitted by a licensing agreement from
9+
// Lattice Semiconductor Corporation.
10+
//
11+
// Lattice Semiconductor Corporation TEL : 1-800-Lattice (USA and Canada)
12+
// 5555 NE Moore Court 408-826-6000 (other locations)
13+
// Hillsboro, OR 97124 web : http://www.latticesemi.com/
14+
// U.S.A email: [email protected]
15+
// =============================================================================/
16+
// FILE DETAILS
17+
// Project : LatticeMico32
18+
// File : lm32_addsub.v
19+
// Title : PMI adder/subtractor.
20+
// Version : 6.1.17
21+
// : Initial Release
22+
// Version : 7.0SP2, 3.0
23+
// : No Change
24+
// Version : 3.1
25+
// : No Change
26+
// =============================================================================
27+
28+
`include "lm32_include.v"
29+
30+
/////////////////////////////////////////////////////
31+
// Module interface
32+
/////////////////////////////////////////////////////
33+
34+
module lm32_addsub (
35+
// ----- Inputs -------
36+
DataA,
37+
DataB,
38+
Cin,
39+
Add_Sub,
40+
// ----- Outputs -------
41+
Result,
42+
Cout
43+
);
44+
45+
/////////////////////////////////////////////////////
46+
// Inputs
47+
/////////////////////////////////////////////////////
48+
49+
input [31:0] DataA;
50+
input [31:0] DataB;
51+
input Cin;
52+
input Add_Sub;
53+
54+
/////////////////////////////////////////////////////
55+
// Outputs
56+
/////////////////////////////////////////////////////
57+
58+
output [31:0] Result;
59+
wire [31:0] Result;
60+
output Cout;
61+
wire Cout;
62+
63+
/////////////////////////////////////////////////////
64+
// Instantiations
65+
/////////////////////////////////////////////////////
66+
67+
generate
68+
if (`LATTICE_FAMILY == "SC" || `LATTICE_FAMILY == "SCM") begin
69+
wire [32:0] tmp_addResult = DataA + DataB + Cin;
70+
wire [32:0] tmp_subResult = DataA - DataB - !Cin;
71+
72+
assign Result = (Add_Sub == 1) ? tmp_addResult[31:0] : tmp_subResult[31:0];
73+
assign Cout = (Add_Sub == 1) ? tmp_addResult[32] : !tmp_subResult[32];
74+
end else begin
75+
pmi_addsub #(// ----- Parameters -------
76+
.pmi_data_width (32),
77+
.pmi_result_width (32),
78+
.pmi_sign ("off"),
79+
.pmi_family (`LATTICE_FAMILY),
80+
.module_type ("pmi_addsub"))
81+
addsub (// ----- Inputs -------
82+
.DataA (DataA),
83+
.DataB (DataB),
84+
.Cin (Cin),
85+
.Add_Sub (Add_Sub),
86+
// ----- Outputs -------
87+
.Result (Result),
88+
.Cout (Cout),
89+
.Overflow ());
90+
end
91+
endgenerate
92+
93+
endmodule

0 commit comments

Comments
 (0)