Skip to content

Commit a5ba9af

Browse files
committed
[Infra]: - add blockbox attribute to SPRAM/DPRAM
- remove arm_core reg init values - modify synthesis.ys to perform formal synthesis Signed-off-by: Seyed Alireza Damghani <[email protected]>
1 parent 929f3bb commit a5ba9af

File tree

12 files changed

+751
-233
lines changed

12 files changed

+751
-233
lines changed

vtr_flow/benchmarks/verilog/arm_core.v

Lines changed: 206 additions & 204 deletions
Large diffs are not rendered by default.

vtr_flow/benchmarks/verilog/diffeq1.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
reg looping;
2121

2222
assign temp = u_var * DXport;
23-
always @(posedge clk)
23+
always @(posedge clk or posedge reset)
2424
begin
2525
if (reset == 1'b1)
2626
begin

vtr_flow/benchmarks/verilog/koios/robot_rl.v

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ endmodule // Max
194194

195195

196196

197-
// SimpleDualPortRAM_generic : 4 RAM banks ( = no. of actions) with a depth of 12 ( = no. of states). Writes during training. Reads during inferfence.
198-
module SimpleDualPortRAM_generic
197+
// Simpledual_port_ram_generic : 4 RAM banks ( = no. of actions) with a depth of 12 ( = no. of states). Writes during training. Reads during inferfence.
198+
module Simpledual_port_ram_generic
199199
(clk,
200200
enb,
201201
wr_din,
@@ -275,7 +275,7 @@ dual_port_ram u_dual_port_ram(
275275

276276
assign rd_dout = data_int;
277277

278-
endmodule // SimpleDualPortRAM_generic
278+
endmodule // Simpledual_port_ram_generic
279279

280280
// Q_Hw: connects all the blocks and incorporates pipelining for appropriate syncing.
281281
module Q_HW
@@ -545,7 +545,7 @@ assign Data_Type_Conversion_out1_3 = Data_Type_Conversion_out1_3;
545545
.out0(Max_out1), // int16
546546
.clk(clk));
547547

548-
SimpleDualPortRAM_generic #(.AddrWidth(4),
548+
Simpledual_port_ram_generic #(.AddrWidth(4),
549549
.DataWidth(32)
550550
)
551551
u_Simple_Dual_Port_RAM_System_bank3 (.clk(clk),
@@ -557,7 +557,7 @@ assign Data_Type_Conversion_out1_3 = Data_Type_Conversion_out1_3;
557557
.rd_dout(pre_rd_out)
558558
);
559559

560-
SimpleDualPortRAM_generic #(.AddrWidth(4),
560+
Simpledual_port_ram_generic #(.AddrWidth(4),
561561
.DataWidth(32)
562562
)
563563
u_Simple_Dual_Port_RAM_System_bank2 (.clk(clk),
@@ -569,7 +569,7 @@ assign Data_Type_Conversion_out1_3 = Data_Type_Conversion_out1_3;
569569
.rd_dout(pre_rd_out_1)
570570
);
571571

572-
SimpleDualPortRAM_generic #(.AddrWidth(4),
572+
Simpledual_port_ram_generic #(.AddrWidth(4),
573573
.DataWidth(32)
574574
)
575575
u_Simple_Dual_Port_RAM_System_bank1 (.clk(clk),

vtr_flow/benchmarks/verilog/mcml.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18329,7 +18329,7 @@ single_port_ram sinp_replace(.clk (clock), .addr (pindex), .data (blank), .we (1
1832918329

1833018330
defparam cosp_replace.ADDR_WIDTH = 10;
1833118331
defparam cosp_replace.DATA_WIDTH = 32;
18332-
single_port_ram cosp_replace(.clk (clock), .addr (pindex), .data (blank), .we (1'b0), .out (cosp));
18332+
singlePortRam cosp_replace(.clk (clock), .addr (pindex), .data (blank), .we (1'b0), .out (cosp));
1833318333

1833418334

1833518335
endmodule

vtr_flow/misc/synthesis.ys

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,79 @@
1-
# XXX is replaced with filename by run_vtr_flow.pl
1+
# XXX is replaced with filename by the run_vtr_flow script
22
read_verilog -nolatches XXX
33

44
# These commands follow the generic `synth'
55
# command script inside Yosys
66
# The -libdir argument allows Yosys to search the current
77
# directory for any definitions to modules it doesn't know
88
# about, such as hand-instantiated (not inferred) memories
9-
hierarchy -check -auto-top -libdir . -libdir TTT
9+
hierarchy -check -auto-top -libdir .
1010
proc
1111

1212
# Check that there are no combinational loops
1313
scc -select
1414
select -assert-none %
1515
select -clear
1616

17+
18+
opt_expr
19+
opt_clean
20+
check
21+
opt -nodffe -nosdff
22+
fsm
1723
opt
1824
wreduce
19-
# Do not transform $add/$mul ops to $alu and $macc cells
20-
#alumacc
25+
peepopt
26+
opt_clean
2127
share
2228
opt
23-
fsm
24-
opt -fast
2529
memory -nomap
26-
opt_clean
27-
# But instead of using the `memory_map' command,
28-
# we map any memories, multipliers, and adders into
29-
# VTR primitives (e.g. single_port_ram)
3030
opt -full
3131

3232
# Transform all async FFs into synchronous ones
3333
techmap -map +/adff2dff.v
34+
techmap -map TTT/../../../ODIN_II/techlib/adffe2dff.v
35+
3436
# Map multipliers, DSPs, and add/subtracts according to yosys_models.v
3537
techmap -map YYY */t:$mul */t:$mem */t:$sub */t:$add
38+
opt -fast -full
39+
3640
memory_map
3741
# Taking care to remove any undefined muxes that
3842
# are introduced to promote resource sharing
3943
opt -full
44+
4045
# Then techmap all other `complex' blocks into basic
4146
# (lookup table) logic
4247
techmap
4348
opt -fast
4449

4550
flatten
46-
# Perform technology-mapping using ABC
47-
techmap -map YYY */t:$lut
48-
opt -fast
49-
5051
# Turn all DFFs into simple latches
5152
dffunmap
53+
opt -fast -noff
5254

5355
# We read the definitions for all the VTR primitives
5456
# as blackboxes
5557
read_verilog -lib TTT/adder.v
5658
read_verilog -lib TTT/multiply.v
57-
read_verilog -lib -ignore_redef TTT/single_port_ram.v
58-
read_verilog -lib -ignore_redef TTT/dual_port_ram.v
59+
read_verilog -lib SSS #(SSS) will be replaced by single_port_ram.v by python script
60+
read_verilog -lib DDD #(DDD) will be replaced by dual_port_ram.v by python script
61+
62+
# Rename singlePortRam to single_port_ram
63+
# Rename dualPortRam to dualZ_port_ram
64+
# rename function of Yosys not work here
65+
# since it may outcome hierarchy error
66+
read_verilog SSR #(SSR) will be replaced by spram_rename.v by python script
67+
read_verilog DDR #(DDR) will be replaced by dpram_rename.v by python script
68+
5969

6070
# Lastly, check the hierarchy for any unknown modules,
6171
# and purge all modules (including blackboxes) that
6272
# aren't used
6373
hierarchy -check -purge_lib
6474
tee -o /dev/stdout stat
6575

76+
6677
# Then write it out as a blif file, remembering to call
6778
# the internal `$true'/`$false' signals vcc/gnd, but
6879
# switch `-impltf' doesn't output them

vtr_flow/misc/yosyslib/dpram_rename.v

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
`timescale 1ps/1ps
2+
3+
`define MEM_MAXADDR PPP
4+
`define MEM_MAXDATA 36
5+
6+
// depth and data may need to be splited
7+
module dualPortRam(clk, we1, we2, addr1, addr2, data1, data2, out1, out2);
8+
parameter ADDR_WIDTH = 1;
9+
parameter DATA_WIDTH = 1;
10+
11+
input clk;
12+
input we1, we2;
13+
input [ADDR_WIDTH-1:0] addr1, addr2;
14+
input [DATA_WIDTH-1:0] data1, data2;
15+
16+
output reg [DATA_WIDTH-1:0] out1, out2;
17+
18+
19+
dual_port_ram uut (
20+
.clk(clk),
21+
.we1(we1),
22+
.we2(we2),
23+
.addr1(addr1),
24+
.addr2(addr2),
25+
.data1(data1),
26+
.data2(data2),
27+
.out1(out1),
28+
.out2(out2)
29+
);
30+
31+
endmodule
32+
33+
34+
35+
(* blackbox *)
36+
module dual_port_ram(clk, data2, data1, addr2, addr1, we2, we1, out2, out1);
37+
localparam ADDR_WIDTH = `MEM_MAXADDR;
38+
localparam DATA_WIDTH = 1;
39+
40+
input clk;
41+
input we1, we2;
42+
input [ADDR_WIDTH-1:0] addr1, addr2;
43+
input data1, data2;
44+
45+
output reg out1, out2;
46+
/*
47+
reg [DATA_WIDTH-1:0] RAM [(1<<ADDR_WIDTH)-1:0];
48+
49+
always @(posedge clk)
50+
begin
51+
if (we1)
52+
RAM[addr1] <= data1;
53+
if (we2)
54+
RAM[addr2] <= data2;
55+
56+
out1 <= RAM[addr1];
57+
out2 <= RAM[addr2];
58+
end
59+
*/
60+
endmodule

vtr_flow/misc/yosyslib/dualPortRam.v

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
`timescale 1ps/1ps
2+
3+
`define MEM_MAXADDR PPP
4+
`define MEM_MAXDATA 36
5+
6+
// depth and data may need to be splited
7+
module dualPortRam(clk, we1, we2, addr1, addr2, data1, data2, out1, out2);
8+
parameter ADDR_WIDTH = 1;
9+
parameter DATA_WIDTH = 1;
10+
11+
input clk;
12+
input we1, we2;
13+
input [ADDR_WIDTH-1:0] addr1, addr2;
14+
input [DATA_WIDTH-1:0] data1, data2;
15+
16+
output reg [DATA_WIDTH-1:0] out1, out2;
17+
18+
genvar i;
19+
generate
20+
// split in depth
21+
if (ADDR_WIDTH > `MEM_MAXADDR)
22+
begin
23+
24+
wire [ADDR_WIDTH-2:0] new_addr1 = addr1[ADDR_WIDTH-2:0];
25+
wire [ADDR_WIDTH-2:0] new_addr2 = addr2[ADDR_WIDTH-2:0];
26+
27+
wire [DATA_WIDTH-1:0] out1_h, out1_l;
28+
wire [DATA_WIDTH-1:0] out2_h, out2_l;
29+
30+
31+
defparam uut_h.ADDR_WIDTH = ADDR_WIDTH-1;
32+
defparam uut_h.DATA_WIDTH = DATA_WIDTH;
33+
dualPortRam uut_h (
34+
.clk(clk),
35+
.we1(we1),
36+
.we2(we2),
37+
.addr1(new_addr1),
38+
.addr2(new_addr2),
39+
.data1(data1),
40+
.data2(data2),
41+
.out1(out1_h),
42+
.out2(out2_h)
43+
);
44+
45+
defparam uut_l.ADDR_WIDTH = ADDR_WIDTH-1;
46+
defparam uut_l.DATA_WIDTH = DATA_WIDTH;
47+
dualPortRam uut_l (
48+
.clk(clk),
49+
.we1(we1),
50+
.we2(we2),
51+
.addr1(new_addr1),
52+
.addr2(new_addr2),
53+
.data1(data1),
54+
.data2(data2),
55+
.out1(out1_l),
56+
.out2(out2_l)
57+
);
58+
59+
reg additional_bit;
60+
always @(posedge clk) additional_bit <= addr[ADDR_WIDTH-1];
61+
assign out1 = (additional_bit) ? out1_h : out1_l;
62+
assign out2 = (additional_bit) ? out2_h : out2_l;
63+
64+
end else begin
65+
for (i = 0; i < DATA_WIDTH; i = i + 1) begin:single_bit_data
66+
dual_port_ram uut (
67+
.clk(clk),
68+
.we1(we1),
69+
.we2(we2),
70+
.addr1(addr1),
71+
.addr2(addr2),
72+
.data1(data1[i]),
73+
.data2(data2[i]),
74+
.out1(out1[i]),
75+
.out2(out2[i])
76+
);
77+
end
78+
end
79+
endgenerate
80+
81+
endmodule
82+
83+
84+
85+
(* blackbox *)
86+
module dual_port_ram(clk, data2, data1, addr2, addr1, we2, we1, out2, out1);
87+
localparam ADDR_WIDTH = `MEM_MAXADDR;
88+
localparam DATA_WIDTH = 1;
89+
90+
input clk;
91+
input we1, we2;
92+
input [ADDR_WIDTH-1:0] addr1, addr2;
93+
input data1, data2;
94+
95+
output reg out1, out2;
96+
/*
97+
reg [DATA_WIDTH-1:0] RAM [(1<<ADDR_WIDTH)-1:0];
98+
99+
always @(posedge clk)
100+
begin
101+
if (we1)
102+
RAM[addr1] <= data1;
103+
if (we2)
104+
RAM[addr2] <= data2;
105+
106+
out1 <= RAM[addr1];
107+
out2 <= RAM[addr2];
108+
end
109+
*/
110+
endmodule

0 commit comments

Comments
 (0)