mirror of
https://github.com/YosysHQ/yosys
synced 2025-08-31 15:24:57 +00:00
Add tests for Xilinx UG901 examples
This commit is contained in:
parent
0d037bf9d8
commit
2ae7dec530
89 changed files with 2962 additions and 0 deletions
68
tests/xilinx_ug901/bytewrite_tdp_ram_wf.v
Normal file
68
tests/xilinx_ug901/bytewrite_tdp_ram_wf.v
Normal file
|
@ -0,0 +1,68 @@
|
|||
// True-Dual-Port BRAM with Byte-wide Write Enable
|
||||
// Write-First mode
|
||||
// File: HDL_Coding_Techniques/rams/bytewrite_tdp_ram_wf.v
|
||||
//
|
||||
// ByteWide Write Enable, - WRITE_FIRST mode template - Vivado recomended
|
||||
module bytewrite_tdp_ram_wf
|
||||
#(
|
||||
//----------------------------------------------------------------------
|
||||
parameter NUM_COL = 4,
|
||||
parameter COL_WIDTH = 8,
|
||||
parameter ADDR_WIDTH = 10,
|
||||
// Addr Width in bits : 2**ADDR_WIDTH = RAM Depth
|
||||
parameter DATA_WIDTH = NUM_COL*COL_WIDTH // Data Width in bits
|
||||
//----------------------------------------------------------------------
|
||||
) (
|
||||
input clkA,
|
||||
input enaA,
|
||||
input [NUM_COL-1:0] weA,
|
||||
input [ADDR_WIDTH-1:0] addrA,
|
||||
input [DATA_WIDTH-1:0] dinA,
|
||||
output reg [DATA_WIDTH-1:0] doutA,
|
||||
|
||||
input clkB,
|
||||
input enaB,
|
||||
input [NUM_COL-1:0] weB,
|
||||
input [ADDR_WIDTH-1:0] addrB,
|
||||
input [DATA_WIDTH-1:0] dinB,
|
||||
output reg [DATA_WIDTH-1:0] doutB
|
||||
);
|
||||
|
||||
|
||||
// Core Memory
|
||||
reg [DATA_WIDTH-1:0] ram_block [(2**ADDR_WIDTH)-1:0];
|
||||
|
||||
// Port-A Operation
|
||||
generate
|
||||
genvar i;
|
||||
for(i=0;i<NUM_COL;i=i+1) begin
|
||||
always @ (posedge clkA) begin
|
||||
if(enaA) begin
|
||||
if(weA[i]) begin
|
||||
ram_block[addrA][i*COL_WIDTH +: COL_WIDTH] <= dinA[i*COL_WIDTH +: COL_WIDTH];
|
||||
doutA[i*COL_WIDTH +: COL_WIDTH] <= dinA[i*COL_WIDTH +: COL_WIDTH] ;
|
||||
end else begin
|
||||
doutA[i*COL_WIDTH +: COL_WIDTH] <= ram_block[addrA][i*COL_WIDTH +: COL_WIDTH] ;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
endgenerate
|
||||
|
||||
// Port-B Operation:
|
||||
generate
|
||||
for(i=0;i<NUM_COL;i=i+1) begin
|
||||
always @ (posedge clkB) begin
|
||||
if(enaB) begin
|
||||
if(weB[i]) begin
|
||||
ram_block[addrB][i*COL_WIDTH +: COL_WIDTH] <= dinB[i*COL_WIDTH +: COL_WIDTH];
|
||||
doutB[i*COL_WIDTH +: COL_WIDTH] <= dinB[i*COL_WIDTH +: COL_WIDTH] ;
|
||||
end else begin
|
||||
doutB[i*COL_WIDTH +: COL_WIDTH] <= ram_block[addrB][i*COL_WIDTH +: COL_WIDTH] ;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
endgenerate
|
||||
|
||||
endmodule // bytewrite_tdp_ram_wf
|
Loading…
Add table
Add a link
Reference in a new issue