-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vexriscv BRAM support #352
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module mult_18x18 ( | ||
input [0:17] A, | ||
input [0:17] B, | ||
output [0:35] Y | ||
); | ||
parameter A_SIGNED = 0; | ||
parameter B_SIGNED = 0; | ||
parameter A_WIDTH = 0; | ||
parameter B_WIDTH = 0; | ||
parameter Y_WIDTH = 0; | ||
|
||
mult_18 #() _TECHMAP_REPLACE_ ( | ||
.A (A), | ||
.B (B), | ||
.Y (Y) ); | ||
|
||
endmodule |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,220 @@ | ||
//----------------------------- | ||
// Dual-port RAM 128x8 bit (1Kbit) | ||
// Core logic | ||
//----------------------------- | ||
module dpram_128x8_core ( | ||
input wclk, | ||
input wen, | ||
input [0:6] waddr, | ||
input [0:7] data_in, | ||
input rclk, | ||
input ren, | ||
input [0:6] raddr, | ||
output [0:7] data_out ); | ||
|
||
reg [0:7] ram[0:127]; | ||
reg [0:7] internal; | ||
|
||
assign data_out = internal; | ||
|
||
always @(posedge wclk) begin | ||
if(wen) begin | ||
ram[waddr] <= data_in; | ||
end | ||
end | ||
|
||
always @(posedge rclk) begin | ||
if(ren) begin | ||
internal <= ram[raddr]; | ||
end | ||
end | ||
|
||
endmodule | ||
|
||
//----------------------------- | ||
// Dual-port RAM 128x8 bit (1Kbit) wrapper | ||
// where the read clock and write clock | ||
// are combined to a unified clock | ||
//----------------------------- | ||
module dpram_128x8 ( | ||
input clk, | ||
input wen, | ||
input ren, | ||
input [0:6] waddr, | ||
input [0:6] raddr, | ||
input [0:7] data_in, | ||
output [0:7] data_out ); | ||
|
||
dpram_128x8_core memory_0 ( | ||
.wclk (clk), | ||
.wen (wen), | ||
.waddr (waddr), | ||
.data_in (data_in), | ||
.rclk (clk), | ||
.ren (ren), | ||
.raddr (raddr), | ||
.data_out (data_out) ); | ||
|
||
endmodule | ||
|
||
//----------------------------- | ||
// 18-bit multiplier | ||
//----------------------------- | ||
module mult_18( | ||
input [0:17] A, | ||
input [0:17] B, | ||
output [0:35] Y | ||
); | ||
|
||
assign Y = A * B; | ||
|
||
endmodule | ||
|
||
//----------------------------- | ||
// Native D-type flip-flop | ||
//----------------------------- | ||
(* abc9_flop, lib_whitebox *) | ||
module dff( | ||
output reg Q, | ||
input D, | ||
(* clkbuf_sink *) | ||
(* invertible_pin = "IS_C_INVERTED" *) | ||
input C | ||
); | ||
parameter [0:0] INIT = 1'b0; | ||
parameter [0:0] IS_C_INVERTED = 1'b0; | ||
initial Q = INIT; | ||
case(|IS_C_INVERTED) | ||
1'b0: | ||
always @(posedge C) | ||
Q <= D; | ||
1'b1: | ||
always @(negedge C) | ||
Q <= D; | ||
endcase | ||
endmodule | ||
|
||
//----------------------------- | ||
// D-type flip-flop with active-high asynchronous reset | ||
//----------------------------- | ||
(* abc9_flop, lib_whitebox *) | ||
module dffr( | ||
output reg Q, | ||
input D, | ||
input R, | ||
(* clkbuf_sink *) | ||
(* invertible_pin = "IS_C_INVERTED" *) | ||
input C | ||
); | ||
parameter [0:0] INIT = 1'b0; | ||
parameter [0:0] IS_C_INVERTED = 1'b0; | ||
initial Q = INIT; | ||
case(|IS_C_INVERTED) | ||
1'b0: | ||
always @(posedge C or posedge R) | ||
if (R == 1'b1) | ||
Q <= 1'b0; | ||
else | ||
Q <= D; | ||
1'b1: | ||
always @(negedge C or posedge R) | ||
if (R == 1'b1) | ||
Q <= 1'b0; | ||
else | ||
Q <= D; | ||
endcase | ||
endmodule | ||
|
||
//----------------------------- | ||
// D-type flip-flop with active-high asynchronous set | ||
//----------------------------- | ||
(* abc9_flop, lib_whitebox *) | ||
module dffs( | ||
output reg Q, | ||
input D, | ||
input S, | ||
(* clkbuf_sink *) | ||
(* invertible_pin = "IS_C_INVERTED" *) | ||
input C | ||
); | ||
parameter [0:0] INIT = 1'b0; | ||
parameter [0:0] IS_C_INVERTED = 1'b0; | ||
initial Q = INIT; | ||
case(|IS_C_INVERTED) | ||
1'b0: | ||
always @(posedge C or posedge S) | ||
if (S == 1'b1) | ||
Q <= 1'b1; | ||
else | ||
Q <= D; | ||
1'b1: | ||
always @(negedge C or posedge S) | ||
if (S == 1'b1) | ||
Q <= 1'b1; | ||
else | ||
Q <= D; | ||
endcase | ||
endmodule | ||
|
||
//----------------------------- | ||
// D-type flip-flop with active-low asynchronous reset | ||
//----------------------------- | ||
(* abc9_flop, lib_whitebox *) | ||
module dffrn( | ||
output reg Q, | ||
input D, | ||
input RN, | ||
(* clkbuf_sink *) | ||
(* invertible_pin = "IS_C_INVERTED" *) | ||
input C | ||
); | ||
parameter [0:0] INIT = 1'b0; | ||
parameter [0:0] IS_C_INVERTED = 1'b0; | ||
initial Q = INIT; | ||
case(|IS_C_INVERTED) | ||
1'b0: | ||
always @(posedge C or negedge RN) | ||
if (RN == 1'b0) | ||
Q <= 1'b0; | ||
else | ||
Q <= D; | ||
1'b1: | ||
always @(negedge C or negedge RN) | ||
if (RN == 1'b0) | ||
Q <= 1'b0; | ||
else | ||
Q <= D; | ||
endcase | ||
endmodule | ||
|
||
//----------------------------- | ||
// D-type flip-flop with active-low asynchronous set | ||
//----------------------------- | ||
(* abc9_flop, lib_whitebox *) | ||
module dffsn( | ||
output reg Q, | ||
input D, | ||
input SN, | ||
(* clkbuf_sink *) | ||
(* invertible_pin = "IS_C_INVERTED" *) | ||
input C | ||
); | ||
parameter [0:0] INIT = 1'b0; | ||
parameter [0:0] IS_C_INVERTED = 1'b0; | ||
initial Q = INIT; | ||
case(|IS_C_INVERTED) | ||
1'b0: | ||
always @(posedge C or negedge SN) | ||
if (SN == 1'b0) | ||
Q <= 1'b1; | ||
else | ||
Q <= D; | ||
1'b1: | ||
always @(negedge C or negedge SN) | ||
if (SN == 1'b0) | ||
Q <= 1'b1; | ||
else | ||
Q <= D; | ||
endcase | ||
endmodule | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Basic DFF | ||
module \$_DFF_P_ (D, C, Q); | ||
input D; | ||
input C; | ||
output Q; | ||
parameter _TECHMAP_WIREINIT_Q_ = 1'bx; | ||
dff _TECHMAP_REPLACE_ (.Q(Q), .D(D), .C(C)); | ||
endmodule | ||
|
||
// Async active-high reset | ||
module \$_DFF_PP0_ (D, C, R, Q); | ||
input D; | ||
input C; | ||
input R; | ||
output Q; | ||
parameter _TECHMAP_WIREINIT_Q_ = 1'bx; | ||
dffr _TECHMAP_REPLACE_ (.Q(Q), .D(D), .C(C), .R(R)); | ||
endmodule | ||
|
||
// Async active-high set | ||
module \$_DFF_PP1_ (D, C, R, Q); | ||
input D; | ||
input C; | ||
input R; | ||
output Q; | ||
parameter _TECHMAP_WIREINIT_Q_ = 1'bx; | ||
dffs _TECHMAP_REPLACE_ (.Q(Q), .D(D), .C(C), .S(R)); | ||
endmodule | ||
|
||
// Async active-low reset | ||
module \$_DFF_PN0_ (D, C, R, Q); | ||
input D; | ||
input C; | ||
input R; | ||
output Q; | ||
parameter _TECHMAP_WIREINIT_Q_ = 1'bx; | ||
dffrn _TECHMAP_REPLACE_ (.Q(Q), .D(D), .C(C), .RN(R)); | ||
endmodule | ||
|
||
// Async active-low set | ||
module \$_DFF_PN1_ (D, C, R, Q); | ||
input D; | ||
input C; | ||
input R; | ||
output Q; | ||
parameter _TECHMAP_WIREINIT_Q_ = 1'bx; | ||
dffsn _TECHMAP_REPLACE_ (.Q(Q), .D(D), .C(C), .SN(R)); | ||
endmodule |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = | ||
# Configuration file for running experiments | ||
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = | ||
# timeout_each_job : FPGA Task script splits fpga flow into multiple jobs | ||
# Each job execute fpga_flow script on combination of architecture & benchmark | ||
# timeout_each_job is timeout for each job | ||
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = | ||
|
||
[GENERAL] | ||
run_engine=openfpga_shell | ||
power_tech_file = ${PATH:OPENFPGA_PATH}/openfpga_flow/tech/PTM_45nm/45nm.xml | ||
power_analysis = false | ||
spice_output=false | ||
verilog_output=true | ||
timeout_each_job = 20*60 | ||
fpga_flow=yosys_vpr | ||
|
||
[OpenFPGA_SHELL] | ||
openfpga_shell_template=${PATH:OPENFPGA_PATH}/openfpga_flow/openfpga_shell_scripts/write_full_testbench_example_script.openfpga | ||
openfpga_arch_file=${PATH:OPENFPGA_PATH}/openfpga_flow/openfpga_arch/k4_frac_N4_adder_chain_40nm_cc_openfpga.xml | ||
openfpga_sim_setting_file=${PATH:OPENFPGA_PATH}/openfpga_flow/openfpga_simulation_settings/auto_sim_openfpga.xml | ||
openfpga_vpr_device_layout=auto | ||
openfpga_fast_configuration= | ||
|
||
[ARCHITECTURES] | ||
arch0=${PATH:OPENFPGA_PATH}/openfpga_flow/vpr_arch/k4_frac_N4_tileable_adder_chain_40nm.xml | ||
|
||
[BENCHMARKS] | ||
bench0=${PATH:OPENFPGA_PATH}/openfpga_flow/benchmarks/processor/picorv32/picorv32.v | ||
|
||
[SYNTHESIS_PARAM] | ||
bench0_top = picorv32 | ||
bench0_chan_width = 300 | ||
|
||
[SCRIPT_PARAM_MIN_ROUTE_CHAN_WIDTH] | ||
end_flow_with_test= |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1 @@ | ||||
/home/apond/sofa/SCRIPT/skywater_openfpga_task | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do not put skywater task run in OpenFPGA repo. They are covered in the SOFA repository.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I thought I deleted the skywater_openfpga_task symlink; I'll delete it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each file in this directory is binded to a specific architecture, so that for each architecture, we can customize the synthesis options to the most. Please avoid a generic naming. Suggest to rename this file to
k4_frac_N8_tileable_adder_chain_dpram1K_dsp18_fracff_40nm_dsp_map.v
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouln't that lead to redundancy though? If I have two architectures like this:
k4_frac_N8_tileable_adder_chain_dpram1K_dsp18_fracff_40nm_dsp_map.v
vs
k4_frac_N8_tileable_adder_chain_dsp18_fracff_40nm_dsp_map.v (no BRAM)
Wouldn't that lead to duplicate multiplier map code? Couldn't those two architectures just use a single dsp18 map since they both have the same multiplier design?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. I believe it is time to rework this directory and create rules when adding new technology libraries for yosys.
My current plan is
<arch_nam>_dsp_map.v
,<arch_name>_bram_map.v
etc. As such, it is easy for users to pick technology libraries because the rules are simple.k4_frac_N8_tileable_adder_chain_dpram1K_dsp18_fracff_40nm_dsp_map.v
contains the actual codes, whilek4_frac_N8_tileable_adder_chain_dsp18_fracff_40nm_dsp_map.v
is a symbolic link.openfpga_yosys_techlib
directory, it may become a mess.Let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh so you are planning on having a directory (for example, k4_frac_N8_tileable_adder_chain_dpram1K_dsp18_fracff_40nm) with the openfpga arch, vpr arch, dsp_map, bram_map, etc all in that directory?