[HDL] Add SPRAM module to generic yosys tech lib for openfpga usage

This commit is contained in:
tangxifan 2021-03-16 18:04:31 -06:00
parent 73b06256d0
commit cea43c2c45
2 changed files with 38 additions and 8 deletions

View File

@ -0,0 +1,15 @@
//---------------------------------------
// 1-bit adder
//---------------------------------------
module adder(
input cin,
input a,
input b,
output cout,
output sumout );
assign sumout = a ^ b ^ cin;
assign cout = (a & b) | ((a | b) & cin);
endmodule

View File

@ -48,15 +48,30 @@ module dual_port_sram (
endmodule
module adder(
input cin,
input a,
input b,
output cout,
output sumout );
//---------------------------------------
// A single-port 32x8bit RAM
// This module is tuned for VTR's benchmarks
//---------------------------------------
module single_port_ram (
input clk,
input we,
input [4:0] addr,
input [7:0] data,
output [7:0] out );
reg [7:0] ram[31:0];
reg [7:0] internal;
assign sumout = a ^ b ^ cin;
assign cout = (a & b) | ((a | b) & cin);
assign out = internal;
always @(posedge clk) begin
if(wen) begin
ram[addr] <= data;
end
if(ren) begin
internal <= ram[addr];
end
end
endmodule