Hard Memories
Hard Memories
endmodule // memory
ENSAM Casa – Département GE – BABA 3 modifié le 18 Sep. 2024
iCE40 EBRAM – Exemple 1 – Testbench
`timescale 1ns/10ps // 1ns unit & precision 10ps
module memory_tb();
wire [7:0] r_data;
reg clk=0;
reg w_en=0;
reg r_en=0;
reg [3:0] w_addr;
reg [3:0] r_addr;
reg [7:0] w_data;
localparam DURATION = 10000;
always begin
#41.67
clk = ~clk;
end
ENSAM Casa – Département GE – BABA 4 modifié le 18 Sep. 2024
iCE40 EBRAM – Exemple 1 – Testbench
memory uut(.clk(clk), .w_en(w_en), .r_en(r_en),
.w_addr(w_addr), .r_addr(r_addr), .w_data(w_data),
.r_data(r_data) );
initial begin
// test 1: read from address 0x0f (should be garbage)
#(2*41.67)
r_addr = 'h0f;
r_en = 1;
#(2*41.67)
r_addr = 0;
r_en = 0;
// test 2: write to address 0x0f and read it back
#(2*41.67)
ENSAM Casa – Département GE – BABA 5 modifié le 18 Sep. 2024
iCE40 EBRAM – Exemple 1 – Testbench
w_addr = 'h0f;
w_data = 'hA5;
w_en = 1;
#(2*41.67)
w_addr = 0;
w_data = 0;
w_en = 0;
#(2*41.67)
r_addr = 'h0f;
r_en = 1;
#(2*41.67)
r_addr = 0;
r_en = 0;
end // initial begin
ENSAM Casa – Département GE – BABA 6 modifié le 18 Sep. 2024
iCE40 EBRAM – Exemple 1 – Testbench
// run simulation
initial begin
// create simulation output file
$dumpfile("memory_tb.vcd");
$dumpvars(0, memory_tb);
// wait for a given amount of time for simulation to complete
#(DURATION)
// notify and end simulation
$display(" Finished ");
$finish;
end // initial begin
endmodule // memory_tb
Number of wires: 30
Number of wire bits: 92
Number of public wires: 30
Number of public wire bits: 92
Number of ports: 7
Number of port bits: 27
Number of memories: 0
Number of memory bits: 0
Number of processes: 0
Number of cells: 36
SB_DFF 13
SB_DFFE 9
SB_LUT4 13
SB_RAM40_4K 1
SB_SPRAM256KA spram (
.ADDRESS(addr),.DATAIN(data_in),
.MASKWREN({wren, wren, wren, wren}),
.WREN(wren),
.CHIPSELECT(1'b1),
.CLOCK(clk),
.STANDBY(1'b0), .SLEEP(1'b0), .POWEROFF(1'b1),
.DATAOUT(ram_data_out));
ENSAM Casa – Département GE – BABA 11 modifié le 18 Sep. 2024
iCE40 SPRAM – Exemple – SB_SPRAM256KA
SB_RGBA_DRV rgb (
.CURREN(1'b1),
.RGBLEDEN(1'b1),
.RGB0PWM(~led[1]), // Green
.RGB1PWM(~led[0]), // Red
.RGB2PWM(~led[2]), // Blue
.RGB0(rgb[0]), .RGB1(rgb[1]), .RGB2(rgb[2])
);