Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2ad1dd7

Browse files
committedMar 15, 2025
boards/openroad: README
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent 39e4d3a commit 2ad1dd7

File tree

4 files changed

+233
-0
lines changed

4 files changed

+233
-0
lines changed
 

‎boards/openroad/README.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
OpenROAD ASAP7 PDK configuration
2+
================================
3+
4+
TL;DR Install Bazel and run command below to build and view darksocv in the GUI, Bazel handles all depedencies.
5+
6+
Demonstrates how to set up an [bazel-orfs](https://github.com/The-OpenROAD-Project/bazel-orfs) to build darksocv with[OpenROAD-flow-scripts](https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts)
7+
8+
To build and view [Install Bazelisk](https://bazel.build/install/bazelisk) and run:
9+
10+
bazel run //boards/openroad:darksocv_cts /tmp/cts gui_cts
11+
12+
Register to register histogram
13+
------------------------------
14+
15+
![alt text](reg2reg-histogram.png)
16+
17+
Estimated routing congestion
18+
----------------------------
19+
20+
![alt text](routing-congestion.png)
21+
22+
Ideas for future work
23+
=====================
24+
25+
- reduce clock period
26+
- darkram.v should consist of serveral SRAMs connected together to be
27+
a more accurate representation
28+
- create a mock SRAM representation with somewhat realistic timing
29+
- add IO constraints to place pins on one edge of the SRAMs and top level
30+
- reduce area
31+
32+
[MegaBoom](https://github.com/The-OpenROAD-Project/megaboom) demonstrates a number of techniques to study a design and set up mock SRAMs.

‎boards/openroad/darkram.v

+201
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
/*
2+
* Copyright (c) 2018, Marcelo Samsoniuk
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
*
8+
* * Redistributions of source code must retain the above copyright notice, this
9+
* list of conditions and the following disclaimer.
10+
*
11+
* * Redistributions in binary form must reproduce the above copyright notice,
12+
* this list of conditions and the following disclaimer in the documentation
13+
* and/or other materials provided with the distribution.
14+
*
15+
* * Neither the name of the copyright holder nor the names of its
16+
* contributors may be used to endorse or promote products derived from
17+
* this software without specific prior written permission.
18+
*
19+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
`timescale 1ns / 1ps
32+
33+
// Mock SRAM by using fewer address bits to get some reasonable speed and size
34+
`define MLEN 8
35+
36+
module darkram
37+
(
38+
input CLK, // clock
39+
input RES, // reset
40+
input HLT, // halt
41+
42+
input IDREQ,
43+
input [31:0] IADDR,
44+
output [31:0] IDATA,
45+
output IDACK,
46+
47+
input XDREQ,
48+
input XRD,
49+
input XWR,
50+
input [3:0] XBE,
51+
input [31:0] XADDR,
52+
input [31:0] XATAI,
53+
output [31:0] XATAO,
54+
output XDACK,
55+
56+
output [3:0] DEBUG
57+
);
58+
59+
// ro/rw memories
60+
61+
reg [31:0] MEM [0:2**`MLEN/4-1]; // ro memory
62+
63+
// memory initialization
64+
65+
integer i;
66+
initial
67+
begin
68+
`ifdef SIMULATION
69+
$display("dpram: unified BRAM w/ %0dx32-bit",2**`MLEN/4);
70+
`ifdef __WAITSTATE__
71+
$display("dpram: waitstates=%0d enabled (default=1)",`__WAITSTATE__);
72+
`endif
73+
`ifdef __RMW_CYCLE__
74+
$display("dpram: RMW cycle enabled.",);
75+
`endif
76+
77+
for(i=0;i!=2**`MLEN/4;i=i+1)
78+
begin
79+
MEM[i] = 32'd0;
80+
end
81+
`endif
82+
83+
// workaround for vivado: no path in simulation and .mem extension
84+
85+
`ifdef XILINX_SIMULATOR
86+
$readmemh("darksocv.mem",MEM);
87+
`elsif MODEL_TECH
88+
$readmemh("../../../../src/darksocv.mem",MEM);
89+
`else
90+
$readmemh("../../src/darksocv.mem",MEM,0);
91+
`endif
92+
end
93+
94+
// instruction memory
95+
`ifdef __HARVARD__
96+
`ifdef __ICACHE__
97+
98+
reg [3:0] ITACK = 0;
99+
reg [31:0] ROMFF = 0;
100+
101+
always@(posedge CLK)
102+
begin
103+
`ifdef __WAITSTATE__
104+
ITACK <= RES ? 0 : ITACK ? ITACK-1 : IDREQ ? `__WAITSTATE__ : 0;
105+
`else
106+
ITACK <= RES ? 0 : ITACK ? ITACK-1 : IDREQ ? 1 : 0;
107+
`endif
108+
109+
ROMFF <= MEM[IADDR[`MLEN-1:2]];
110+
end
111+
112+
assign IDATA = ROMFF;
113+
assign IDACK = ITACK==1;
114+
115+
`else
116+
117+
reg [3:0] ITACK = 0;
118+
reg [31:0] ROMFF = 0;
119+
120+
always@(posedge CLK)
121+
begin
122+
`ifdef __WAITSTATE__
123+
ITACK <= RES ? 0 : ITACK ? ITACK-1 : IDREQ ? `__WAITSTATE__ : 0; // i-bus wait-state
124+
`endif
125+
126+
ROMFF <= MEM[IADDR[`MLEN-1:2]];
127+
// if(!RES && !HLT) $display("bram: addr=%x inst=%x\n",IADDR,ROMFF);
128+
end
129+
130+
assign IDATA = ROMFF;
131+
132+
`ifdef __WAITSTATE__
133+
assign IDACK = ITACK==1;
134+
`else
135+
assign IDACK = IDREQ;
136+
`endif
137+
138+
`endif
139+
`endif
140+
141+
// data memory
142+
143+
reg [3:0] DTACK = 0;
144+
reg [31:0] RAMFF = 0;
145+
146+
always@(posedge CLK) // stage #1.0
147+
begin
148+
`ifdef __RMW_CYCLE__
149+
`ifdef __WAITSTATE__
150+
DTACK <= RES ? 0 : DTACK ? DTACK-1 : XDREQ && (XRD||XWR) ? `__WAITSTATE__ : 0;
151+
`else
152+
DTACK <= RES ? 0 : DTACK ? DTACK-1 : XDREQ && (XRD||XWR) ? 1 : 0;
153+
`endif
154+
`else
155+
`ifdef __WAITSTATE__
156+
DTACK <= RES ? 0 : DTACK ? DTACK-1 : XDREQ && XRD ? `__WAITSTATE__ : 0;
157+
`else
158+
DTACK <= RES ? 0 : DTACK ? DTACK-1 : XDREQ && XRD ? 1 : 0;
159+
`endif
160+
`endif
161+
162+
RAMFF <= MEM[XADDR[`MLEN-1:2]];
163+
164+
//individual byte/word/long selection, thanks to HYF!
165+
166+
`ifdef __RMW_CYCLE__
167+
168+
// read-modify-write operation w/ 1 wait-state:
169+
170+
if(XWR && XDREQ)
171+
begin
172+
MEM[XADDR[`MLEN-1:2]] <=
173+
{
174+
XBE[3] ? XATAI[3 * 8 + 7: 3 * 8] : RAMFF[3 * 8 + 7: 3 * 8],
175+
XBE[2] ? XATAI[2 * 8 + 7: 2 * 8] : RAMFF[2 * 8 + 7: 2 * 8],
176+
XBE[1] ? XATAI[1 * 8 + 7: 1 * 8] : RAMFF[1 * 8 + 7: 1 * 8],
177+
XBE[0] ? XATAI[0 * 8 + 7: 0 * 8] : RAMFF[0 * 8 + 7: 0 * 8]
178+
};
179+
end
180+
181+
`else
182+
// write-only operation w/ 0 wait-states:
183+
184+
if(XWR && XDREQ && XBE[3]) MEM[XADDR[`MLEN-1:2]][3 * 8 + 7: 3 * 8] <= XATAI[3 * 8 + 7: 3 * 8];
185+
if(XWR && XDREQ && XBE[2]) MEM[XADDR[`MLEN-1:2]][2 * 8 + 7: 2 * 8] <= XATAI[2 * 8 + 7: 2 * 8];
186+
if(XWR && XDREQ && XBE[1]) MEM[XADDR[`MLEN-1:2]][1 * 8 + 7: 1 * 8] <= XATAI[1 * 8 + 7: 1 * 8];
187+
if(XWR && XDREQ && XBE[0]) MEM[XADDR[`MLEN-1:2]][0 * 8 + 7: 0 * 8] <= XATAI[0 * 8 + 7: 0 * 8];
188+
`endif
189+
end
190+
191+
assign XATAO = RAMFF;
192+
193+
`ifdef __RMW_CYCLE__
194+
assign XDACK = DTACK==1;
195+
`else
196+
assign XDACK = DTACK==1 ||(XDREQ&&XWR);
197+
`endif
198+
199+
assign DEBUG = { XDREQ,XRD,XWR,XDACK };
200+
201+
endmodule

‎boards/openroad/reg2reg-histogram.png

602 KB
Loading
721 KB
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.