mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-23 00:55:32 +00:00
Merging attribute rules into a single match block; Adding tests
This commit is contained in:
parent
266993408a
commit
b35559fc33
5 changed files with 3465 additions and 86 deletions
88
tests/arch/common/memory_attributes/attributes_test.v
Normal file
88
tests/arch/common/memory_attributes/attributes_test.v
Normal file
|
@ -0,0 +1,88 @@
|
|||
`default_nettype none
|
||||
module block_ram #(parameter DATA_WIDTH=4, ADDRESS_WIDTH=10)
|
||||
(input wire write_enable, clk,
|
||||
input wire [DATA_WIDTH-1:0] data_in,
|
||||
input wire [ADDRESS_WIDTH-1:0] address_in,
|
||||
output wire [DATA_WIDTH-1:0] data_out);
|
||||
|
||||
localparam WORD = (DATA_WIDTH-1);
|
||||
localparam DEPTH = (2**ADDRESS_WIDTH-1);
|
||||
|
||||
reg [WORD:0] data_out_r;
|
||||
reg [WORD:0] memory [0:DEPTH];
|
||||
|
||||
always @(posedge clk) begin
|
||||
if (write_enable)
|
||||
memory[address_in] <= data_in;
|
||||
data_out_r <= memory[address_in];
|
||||
end
|
||||
|
||||
assign data_out = data_out_r;
|
||||
endmodule // block_ram
|
||||
|
||||
`default_nettype none
|
||||
module distributed_ram #(parameter DATA_WIDTH=8, ADDRESS_WIDTH=4)
|
||||
(input wire write_enable, clk,
|
||||
input wire [DATA_WIDTH-1:0] data_in,
|
||||
input wire [ADDRESS_WIDTH-1:0] address_in,
|
||||
output wire [DATA_WIDTH-1:0] data_out);
|
||||
|
||||
localparam WORD = (DATA_WIDTH-1);
|
||||
localparam DEPTH = (2**ADDRESS_WIDTH-1);
|
||||
|
||||
reg [WORD:0] data_out_r;
|
||||
reg [WORD:0] memory [0:DEPTH];
|
||||
|
||||
always @(posedge clk) begin
|
||||
if (write_enable)
|
||||
memory[address_in] <= data_in;
|
||||
data_out_r <= memory[address_in];
|
||||
end
|
||||
|
||||
assign data_out = data_out_r;
|
||||
endmodule // distributed_ram
|
||||
|
||||
`default_nettype none
|
||||
module distributed_ram_manual #(parameter DATA_WIDTH=8, ADDRESS_WIDTH=4)
|
||||
(input wire write_enable, clk,
|
||||
input wire [DATA_WIDTH-1:0] data_in,
|
||||
input wire [ADDRESS_WIDTH-1:0] address_in,
|
||||
output wire [DATA_WIDTH-1:0] data_out);
|
||||
|
||||
localparam WORD = (DATA_WIDTH-1);
|
||||
localparam DEPTH = (2**ADDRESS_WIDTH-1);
|
||||
|
||||
reg [WORD:0] data_out_r;
|
||||
(* ram_style = "block" *) reg [WORD:0] memory [0:DEPTH];
|
||||
|
||||
always @(posedge clk) begin
|
||||
if (write_enable)
|
||||
memory[address_in] <= data_in;
|
||||
data_out_r <= memory[address_in];
|
||||
end
|
||||
|
||||
assign data_out = data_out_r;
|
||||
endmodule // distributed_ram
|
||||
|
||||
`default_nettype none
|
||||
module distributed_ram_manual_syn #(parameter DATA_WIDTH=8, ADDRESS_WIDTH=4)
|
||||
(input wire write_enable, clk,
|
||||
input wire [DATA_WIDTH-1:0] data_in,
|
||||
input wire [ADDRESS_WIDTH-1:0] address_in,
|
||||
output wire [DATA_WIDTH-1:0] data_out);
|
||||
|
||||
localparam WORD = (DATA_WIDTH-1);
|
||||
localparam DEPTH = (2**ADDRESS_WIDTH-1);
|
||||
|
||||
reg [WORD:0] data_out_r;
|
||||
(* synthesis, ram_block *) reg [WORD:0] memory [0:DEPTH];
|
||||
|
||||
always @(posedge clk) begin
|
||||
if (write_enable)
|
||||
memory[address_in] <= data_in;
|
||||
data_out_r <= memory[address_in];
|
||||
end
|
||||
|
||||
assign data_out = data_out_r;
|
||||
endmodule // distributed_ram
|
||||
|
47
tests/arch/common/memory_attributes/attributes_test.ys
Normal file
47
tests/arch/common/memory_attributes/attributes_test.ys
Normal file
|
@ -0,0 +1,47 @@
|
|||
# Check that blockram memory without parameters is not modified
|
||||
read_verilog attributes_test.v
|
||||
hierarchy -top block_ram
|
||||
synth_xilinx -top block_ram
|
||||
cd block_ram # Constrain all select calls below inside the top module
|
||||
select -assert-count 1 t:RAMB18E1
|
||||
|
||||
# Check that distributed memory without parameters is not modified
|
||||
design -reset
|
||||
read_verilog attributes_test.v
|
||||
hierarchy -top distributed_ram
|
||||
synth_xilinx -top distributed_ram
|
||||
cd distributed_ram # Constrain all select calls below inside the top module
|
||||
select -assert-count 8 t:RAM32X1D
|
||||
|
||||
# Set ram_style distributed to blockram memory; will be implemented as distributed
|
||||
design -reset
|
||||
read_verilog attributes_test.v
|
||||
prep
|
||||
setattr -mod -set ram_style "distributed" block_ram
|
||||
synth_xilinx -top block_ram
|
||||
cd block_ram # Constrain all select calls below inside the top module
|
||||
select -assert-count 32 t:RAM128X1D
|
||||
|
||||
# Set synthesis, logic_block to blockram memory; will be implemented as distributed
|
||||
design -reset
|
||||
read_verilog attributes_test.v
|
||||
prep
|
||||
setattr -mod -set logic_block 1 block_ram
|
||||
synth_xilinx -top block_ram
|
||||
cd block_ram # Constrain all select calls below inside the top module
|
||||
select -assert-count 0 t:RAMB18E1
|
||||
select -assert-count 32 t:RAM128X1D
|
||||
|
||||
# Set ram_style block to a distributed memory; will be implemented as blockram
|
||||
design -reset
|
||||
read_verilog attributes_test.v
|
||||
synth_xilinx -top distributed_ram_manual
|
||||
cd distributed_ram_manual # Constrain all select calls below inside the top module
|
||||
select -assert-count 1 t:RAMB18E1
|
||||
|
||||
# Set synthesis, ram_block block to a distributed memory; will be implemented as blockram
|
||||
design -reset
|
||||
read_verilog attributes_test.v
|
||||
synth_xilinx -top distributed_ram_manual_syn
|
||||
cd distributed_ram_manual_syn # Constrain all select calls below inside the top module
|
||||
select -assert-count 1 t:RAMB18E1
|
3238
tests/arch/common/memory_attributes/log
Normal file
3238
tests/arch/common/memory_attributes/log
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue